From 98888def16116ef0a8ec14df73d2b8964234647d Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Mon, 10 Aug 2020 16:58:38 +0300 Subject: [PATCH] cli/server: drop key mangler from dumper It's no longer needed (yay!) --- cli/server/dump.go | 42 ++---------------------------------------- 1 file changed, 2 insertions(+), 40 deletions(-) diff --git a/cli/server/dump.go b/cli/server/dump.go index 303c7e903..ccf958087 100644 --- a/cli/server/dump.go +++ b/cli/server/dump.go @@ -25,42 +25,6 @@ type storageOp struct { Value string `json:"value,omitempty"` } -// NEO has some differences of key storing (that should go away post-preview2). -// ours format: contract's ID (uint32le) + key -// theirs format: contract's ID (uint32le) + key with 16 between every 16 bytes, padded to len 16. -func toNeoStorageKey(key []byte) []byte { - if len(key) < 4 { - panic("invalid key in storage") - } - - // Prefix is a contract's ID in LE. - nkey := make([]byte, 4, len(key)) - copy(nkey, key[:4]) - key = key[4:] - - index := 0 - remain := len(key) - for remain >= 16 { - nkey = append(nkey, key[index:index+16]...) - nkey = append(nkey, 16) - index += 16 - remain -= 16 - } - - if remain > 0 { - nkey = append(nkey, key[index:]...) - } - - padding := 16 - remain - for i := 0; i < padding; i++ { - nkey = append(nkey, 0) - } - - nkey = append(nkey, byte(remain)) - - return nkey -} - // batchToMap converts batch to a map so that JSON is compatible // with https://github.com/NeoResearch/neo-storage-audit/ func batchToMap(index uint32, batch *storage.MemBatch) blockDump { @@ -77,10 +41,9 @@ func batchToMap(index uint32, batch *storage.MemBatch) blockDump { op = "Changed" } - key = toNeoStorageKey(key[1:]) ops = append(ops, storageOp{ State: op, - Key: hex.EncodeToString(key), + Key: hex.EncodeToString(key[1:]), Value: hex.EncodeToString(batch.Put[i].Value), }) } @@ -91,10 +54,9 @@ func batchToMap(index uint32, batch *storage.MemBatch) blockDump { continue } - key = toNeoStorageKey(key[1:]) ops = append(ops, storageOp{ State: "Deleted", - Key: hex.EncodeToString(key), + Key: hex.EncodeToString(key[1:]), }) }