mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-11-25 03:47:18 +00:00
*: mention prefix trimming in Seek
operations where applicable
Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
parent
7362fd94e6
commit
62b710868b
3 changed files with 4 additions and 3 deletions
|
@ -2149,7 +2149,7 @@ func (bc *Blockchain) GetStorageItem(id int32, key []byte) state.StorageItem {
|
||||||
return bc.dao.GetStorageItem(id, key)
|
return bc.dao.GetStorageItem(id, key)
|
||||||
}
|
}
|
||||||
|
|
||||||
// SeekStorage performs seek operation over contract storage.
|
// SeekStorage performs seek operation over contract storage. Prefix is trimmed in the resulting pair's key.
|
||||||
func (bc *Blockchain) SeekStorage(id int32, prefix []byte, cont func(k, v []byte) bool) {
|
func (bc *Blockchain) SeekStorage(id int32, prefix []byte, cont func(k, v []byte) bool) {
|
||||||
bc.dao.Seek(id, storage.SeekRange{Prefix: prefix}, cont)
|
bc.dao.Seek(id, storage.SeekRange{Prefix: prefix}, cont)
|
||||||
}
|
}
|
||||||
|
|
|
@ -380,7 +380,8 @@ func (dao *Simple) DeleteStorageItem(id int32, key []byte) {
|
||||||
|
|
||||||
// Seek executes f for all storage items matching the given `rng` (matching the given prefix and
|
// Seek executes f for all storage items matching the given `rng` (matching the given prefix and
|
||||||
// starting from the point specified). If the key or the value is to be used outside of f, they
|
// starting from the point specified). If the key or the value is to be used outside of f, they
|
||||||
// may not be copied. Seek continues iterating until false is returned from f.
|
// may not be copied. Seek continues iterating until false is returned from f. A requested prefix
|
||||||
|
// (if any non-empty) is trimmed before passing to f.
|
||||||
func (dao *Simple) Seek(id int32, rng storage.SeekRange, f func(k, v []byte) bool) {
|
func (dao *Simple) Seek(id int32, rng storage.SeekRange, f func(k, v []byte) bool) {
|
||||||
rng.Prefix = slice.Copy(dao.makeStorageItemKey(id, rng.Prefix)) // f() can use dao too.
|
rng.Prefix = slice.Copy(dao.makeStorageItemKey(id, rng.Prefix)) // f() can use dao too.
|
||||||
dao.Store.Seek(rng, func(k, v []byte) bool {
|
dao.Store.Seek(rng, func(k, v []byte) bool {
|
||||||
|
|
|
@ -114,7 +114,7 @@ type (
|
||||||
}
|
}
|
||||||
|
|
||||||
// ContractStorageSeeker is the interface `findstorage*` handlers need to be able to
|
// ContractStorageSeeker is the interface `findstorage*` handlers need to be able to
|
||||||
// seek over contract storage.
|
// seek over contract storage. Prefix is trimmed in the resulting pair's key.
|
||||||
ContractStorageSeeker interface {
|
ContractStorageSeeker interface {
|
||||||
SeekStorage(id int32, prefix []byte, cont func(k, v []byte) bool)
|
SeekStorage(id int32, prefix []byte, cont func(k, v []byte) bool)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue