Compare commits
1 Commits
d412991452
...
465d0b10f1
Author | SHA1 | Date |
---|---|---|
Airat Arifullin | 465d0b10f1 |
|
@ -112,9 +112,6 @@ func mapKey(kind Kind, name []byte) []byte {
|
|||
// a storage key shortening long names. Short entity
|
||||
// names are also mapped to prevent collisions in the map.
|
||||
func mapToNumeric(ctx storage.Context, kind Kind, name []byte) (mapped int, mappingExists bool) {
|
||||
mapped = 0
|
||||
mappingExists = false
|
||||
|
||||
mKey := mapKey(kind, name)
|
||||
numericID := storage.Get(ctx, mKey)
|
||||
if numericID == nil {
|
||||
|
@ -246,7 +243,12 @@ func ListChainsByPrefix(entity Kind, entityName string, prefix []byte) [][]byte
|
|||
|
||||
func IteratorChainsByPrefix(entity Kind, entityName string, prefix []byte) iterator.Iterator {
|
||||
ctx := storage.GetReadOnlyContext()
|
||||
id, _ := mapToNumeric(ctx, entity, []byte(entityName))
|
||||
id, mappingExists := mapToNumeric(ctx, entity, []byte(entityName))
|
||||
if !mappingExists {
|
||||
// All exising numeric mappings starts with 1. So, if id is set to 0, then
|
||||
// iterator will iterate over empty list of chains.
|
||||
id = 0
|
||||
}
|
||||
keyPrefix := storageKey(entity, id, prefix)
|
||||
return storage.Find(ctx, keyPrefix, storage.ValuesOnly)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue