Commit 9739a038 authored by suyanlong's avatar suyanlong

Add db key

parent 51b6b278
package key
import (
"fmt"
)
const (
blockKey = "block-"
blockHashKey = "block-hash-"
blockHeightKey = "block-height-"
blockTxSetKey = "block-tx-set-"
interchainMetaKey = "interchain-meta-"
receiptKey = "receipt-"
transactionKey = "tx-"
transactionMetaKey = "tx-meta-"
chainMetaKey = "chain-meta"
accountKey = "account-"
codeKey = "code-"
journalKey = "journal-"
)
func CompositeKey(prefix string, value interface{}) []byte {
return append([]byte(prefix), []byte(fmt.Sprintf("%v", value))...)
}
package key
import (
"testing"
"github.com/magiconair/properties/assert"
)
func TestCompositeKey(t *testing.T) {
assert.Equal(t, CompositeKey(blockKey, 1), []byte("block-1"))
assert.Equal(t, CompositeKey(blockHashKey, "0x112233"), []byte("block-hash-0x112233"))
assert.Equal(t, CompositeKey(transactionKey, "0x112233"), []byte("tx-0x112233"))
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment