txn: fix subtle transaction inheritence bugs

This fixes subtle bugs with transaction inheritence. Since we were not
passing the inherited state to moved value, we were sometimes committing
transactions more than once.

Changelog-Fixed: Fix many nostrdb transaction related crashes
This commit is contained in:
William Casarin
2024-01-26 14:03:49 -08:00
parent f190b6414c
commit e3642b92d1
8 changed files with 53 additions and 42 deletions

View File

@@ -85,8 +85,8 @@ class Profiles {
ndb.search_profile(query, limit: limit, txn: txn)
}
func lookup(id: Pubkey) -> NdbTxn<Profile?>? {
guard let txn = ndb.lookup_profile(id) else {
func lookup(id: Pubkey, txn_name: String? = nil) -> NdbTxn<Profile?>? {
guard let txn = ndb.lookup_profile(id, txn_name: txn_name) else {
return nil
}
return txn.map({ pr in pr?.profile })