Created
June 18, 2019 03:45
-
-
Save dicarlo2/d9ec8592d453ec334a8fbd341a592772 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const getStorageItemKeyMin = ({ hash, prefix }: StorageItemsKey): Buffer => { | |
if (hash === undefined || hash.length === 0) { | |
return bytewise.encode(bytewise.sorts.array.bound.lower([storageItemKeyPrefix])); | |
} | |
if (prefix === undefined || prefix.length === 0) { | |
return bytewise.encode(bytewise.sorts.array.bound.lower([storageItemKeyPrefix, common.uInt160ToBuffer(hash)])); | |
} | |
return bytewise.encode( | |
bytewise.sorts.array.bound.lower([ | |
storageItemKeyPrefix, | |
common.uInt160ToBuffer(hash), | |
bytewise.sorts.binary.bound.lower(prefix), | |
]), | |
); | |
}; | |
const getStorageItemKeyMax = ({ hash, prefix }: StorageItemsKey): Buffer => { | |
if (hash === undefined || hash.length === 0) { | |
return bytewise.encode(bytewise.sorts.array.bound.upper([storageItemKeyPrefix])); | |
} | |
if (prefix === undefined || prefix.length === 0) { | |
return bytewise.encode(bytewise.sorts.array.bound.upper([storageItemKeyPrefix, common.uInt160ToBuffer(hash)])); | |
} | |
return bytewise.encode( | |
bytewise.sorts.array.bound.upper([ | |
storageItemKeyPrefix, | |
common.uInt160ToBuffer(hash), | |
bytewise.sorts.binary.bound.upper(prefix), | |
]), | |
); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment