Switch over to use use blocks from nostrdb
This is still kind of broken until queries are switched over to nostrdb. Will do this next Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
committed by
Daniel D’Aquino
parent
208b3331ca
commit
28a06af534
@@ -206,13 +206,28 @@ class Ndb {
|
||||
self.ndb = db
|
||||
return true
|
||||
}
|
||||
|
||||
func lookup_blocks_by_key_with_txn<Y>(_ key: NoteKey, txn: NdbTxn<Y>) -> NdbBlocks? {
|
||||
guard let blocks = ndb_get_blocks_by_key(self.ndb.ndb, &txn.txn, key) else {
|
||||
return nil
|
||||
}
|
||||
|
||||
return NdbBlocks(ptr: blocks)
|
||||
}
|
||||
|
||||
func lookup_blocks_by_key(_ key: NoteKey) -> NdbTxn<NdbBlocks?>? {
|
||||
NdbTxn(ndb: self) { txn in
|
||||
lookup_blocks_by_key_with_txn(key, txn: txn)
|
||||
}
|
||||
}
|
||||
|
||||
func lookup_note_by_key_with_txn<Y>(_ key: NoteKey, txn: NdbTxn<Y>) -> NdbNote? {
|
||||
var size: Int = 0
|
||||
guard let note_p = ndb_get_note_by_key(&txn.txn, key, &size) else {
|
||||
return nil
|
||||
}
|
||||
return NdbNote(note: note_p, size: size, owned: false, key: key)
|
||||
let ptr = ndb_note_ptr(ptr: note_p)
|
||||
return NdbNote(note: ptr, size: size, owned: false, key: key)
|
||||
}
|
||||
|
||||
func text_search(query: String, limit: Int = 128, order: NdbSearchOrder = .newest_first) -> [NoteKey] {
|
||||
@@ -403,7 +418,8 @@ class Ndb {
|
||||
let note_p = ndb_get_note_by_id(&txn.txn, baseAddress, &size, &key) else {
|
||||
return nil
|
||||
}
|
||||
return NdbNote(note: note_p, size: size, owned: false, key: key)
|
||||
let ptr = ndb_note_ptr(ptr: note_p)
|
||||
return NdbNote(note: ptr, size: size, owned: false, key: key)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user