mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2025-01-07 18:21:20 +00:00
d1aa843ea6
Former-commit-id: 5febe72a5a1936ce643488067e0990da810f1f5e [formerly 74c85fc99b259d064b5181f91cddf945e3d7b988] Former-commit-id: 0cc6d451b5eee6e459597ad114a85bacc7a953f1
38 lines
651 B
Go
38 lines
651 B
Go
package sharding
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/ethereum/go-ethereum/common"
|
|
)
|
|
|
|
type shardKV struct {
|
|
// Shard state storage is a mapping of hashes to RLP encoded values.
|
|
kv map[common.Hash][]byte
|
|
}
|
|
|
|
func makeShardKV() *shardKV {
|
|
return &shardKV{kv: make(map[common.Hash][]byte)}
|
|
}
|
|
|
|
func (sb *shardKV) Get(k common.Hash) ([]byte, error) {
|
|
v, ok := sb.kv[k]
|
|
if !ok {
|
|
return nil, fmt.Errorf("key not found: %v", k)
|
|
}
|
|
return v, nil
|
|
}
|
|
|
|
func (sb *shardKV) Has(k common.Hash) bool {
|
|
v := sb.kv[k]
|
|
return v != nil
|
|
}
|
|
|
|
func (sb *shardKV) Put(k common.Hash, v []byte) {
|
|
sb.kv[k] = v
|
|
}
|
|
|
|
func (sb *shardKV) Delete(k common.Hash) {
|
|
delete(sb.kv, k)
|
|
}
|