sharding: make shard func

Former-commit-id: bbb2c9cf92add01dd21480ddf76d14d93c5ca193 [formerly 8a52bd1e5370434ac174968a4767f47ae310a35f]
Former-commit-id: 31256de9b910d8e4131b19ef69d7815df025f362
This commit is contained in:
Raul Jordan 2018-05-03 16:31:28 -05:00
parent 1793e7d21d
commit b524c0eab5

View File

@ -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 {