From b524c0eab553c148a308e21dbffa2ba2fd94a79e Mon Sep 17 00:00:00 2001 From: Raul Jordan Date: Thu, 3 May 2018 16:31:28 -0500 Subject: [PATCH] sharding: make shard func Former-commit-id: bbb2c9cf92add01dd21480ddf76d14d93c5ca193 [formerly 8a52bd1e5370434ac174968a4767f47ae310a35f] Former-commit-id: 31256de9b910d8e4131b19ef69d7815df025f362 --- sharding/shard.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/sharding/shard.go b/sharding/shard.go index 2ecaf185b..38bbac376 100644 --- a/sharding/shard.go +++ b/sharding/shard.go @@ -14,6 +14,17 @@ type Shard struct { shardID *big.Int } +// MakeShard creates an instance of a Shard struct given a shardID. +func MakeShard(shardID *big.Int) *Shard { + // Swappable. + shardDB := &shardKV{kv: make(map[common.Hash][]byte)} + + return &Shard{ + shardID: shardID, + shardDB: shardDB, + } +} + // ValidateShardID checks if header belongs to shard. func (s *Shard) ValidateShardID(h *CollationHeader) error { if s.shardID.Cmp(h.shardID) != 0 {