Compare commits
No commits in common. "1e0c853d40e74331080c493406600ce667313f3a" and "3c212c061222947e4d326538fda53bf0127d17dd" have entirely different histories.
1e0c853d40
...
3c212c0612
1
.gitignore
vendored
1
.gitignore
vendored
@ -1 +0,0 @@
|
|||||||
.vscode
|
|
@ -8,13 +8,12 @@ const ()
|
|||||||
|
|
||||||
// DecodeKey specifically only decodes user data keys stored as bytes into its respective session ID and data type
|
// DecodeKey specifically only decodes user data keys stored as bytes into its respective session ID and data type
|
||||||
// TODO: Replace return data type with imported data types from the common package once lib-gdbm dependency is removed.
|
// TODO: Replace return data type with imported data types from the common package once lib-gdbm dependency is removed.
|
||||||
// Note: 0x2e was added herehttps://holbrook.no/src/go-vise/file/db/db.go.html#l147, so we discard the last 3 bytes
|
|
||||||
func DecodeKey(key []byte) (uint16, string) {
|
func DecodeKey(key []byte) (uint16, string) {
|
||||||
if key[0] != keyPrefix {
|
if key[0] != keyPrefix {
|
||||||
return 0, ""
|
return 0, ""
|
||||||
}
|
}
|
||||||
|
|
||||||
return binary.BigEndian.Uint16(key[len(key)-2:]), string(key[1 : len(key)-3])
|
return binary.BigEndian.Uint16(key[len(key)-2:]), string(key[1 : len(key)-2])
|
||||||
}
|
}
|
||||||
|
|
||||||
// DecodeValue returns the utf-8 string representation of the value stored in the storage backend
|
// DecodeValue returns the utf-8 string representation of the value stored in the storage backend
|
||||||
|
@ -21,10 +21,10 @@ func TestDecodeKey(t *testing.T) {
|
|||||||
{
|
{
|
||||||
"blockchain_address",
|
"blockchain_address",
|
||||||
args{
|
args{
|
||||||
keyBytesHex: "202b3235343731313737373733342e0001",
|
keyBytesHex: "202b3235343731313030303132330001",
|
||||||
},
|
},
|
||||||
want{
|
want{
|
||||||
sessionID: "+254711777734",
|
sessionID: "+254711000123",
|
||||||
dataType: ACCOUNT_BLOCKCHAIN_ADDRESS,
|
dataType: ACCOUNT_BLOCKCHAIN_ADDRESS,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user