Merge pull request #3222 from nspcc-dev/doc/contracts-storage-seek-call-improvement
doc/Mention prefix trimming in `Seek` operations where applicable
This commit is contained in:
commit
1f84756c21
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)
|
||||
}
|
||||
|
||||
// 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) {
|
||||
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
|
||||
// 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) {
|
||||
rng.Prefix = slice.Copy(dao.makeStorageItemKey(id, rng.Prefix)) // f() can use dao too.
|
||||
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
|
||||
// seek over contract storage.
|
||||
// seek over contract storage. Prefix is trimmed in the resulting pair's key.
|
||||
ContractStorageSeeker interface {
|
||||
SeekStorage(id int32, prefix []byte, cont func(k, v []byte) bool)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue