mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2025-01-07 18:21:20 +00:00
e79e9f43a3
Former-commit-id: 5cba9cefd8d480ec9856ce3059b089f32ca4efce [formerly 24ec21a5989261e155d88b19c4df07b501b97942] Former-commit-id: 97a654f56e99a83eb4aeb11349e5c0ac9ad0caec
42 lines
620 B
Go
42 lines
620 B
Go
package sharding
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/ethereum/go-ethereum/common"
|
|
)
|
|
|
|
type shardKV struct {
|
|
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 := sb.kv[k]
|
|
if v == nil {
|
|
return nil, fmt.Errorf("Key Not Found")
|
|
}
|
|
return v, nil
|
|
}
|
|
|
|
func (sb *shardKV) Has(k common.Hash) bool {
|
|
v := sb.kv[k]
|
|
if v == nil {
|
|
return false
|
|
}
|
|
return true
|
|
}
|
|
|
|
func (sb *shardKV) Put(k common.Hash, v []byte) {
|
|
sb.kv[k] = v
|
|
return
|
|
}
|
|
|
|
func (sb *shardKV) Delete(k common.Hash) {
|
|
delete(sb.kv, k)
|
|
return
|
|
}
|