|
|
|
@ -135,6 +135,7 @@ func Shuffle(list []types.NodeID) { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// GetBlockNumberFromEpoch calculates the block number where epoch sharding information is stored
|
|
|
|
|
// TODO lc - use ShardingSchedule function
|
|
|
|
|
func GetBlockNumberFromEpoch(epoch uint64) uint64 { |
|
|
|
|
number := epoch * ShardingSchedule.BlocksPerEpoch() // currently we use the first block in each epoch
|
|
|
|
|
return number |
|
|
|
@ -142,13 +143,14 @@ func GetBlockNumberFromEpoch(epoch uint64) uint64 { |
|
|
|
|
|
|
|
|
|
// GetLastBlockNumberFromEpoch calculates the last block number for the given
|
|
|
|
|
// epoch. TODO ek – this is a temp hack.
|
|
|
|
|
// TODO lc - use ShardingSchedule function
|
|
|
|
|
func GetLastBlockNumberFromEpoch(epoch uint64) uint64 { |
|
|
|
|
return (epoch+1)*ShardingSchedule.BlocksPerEpoch() - 1 |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// GetEpochFromBlockNumber calculates the epoch number the block belongs to
|
|
|
|
|
func GetEpochFromBlockNumber(blockNumber uint64) uint64 { |
|
|
|
|
return blockNumber / ShardingSchedule.BlocksPerEpoch() |
|
|
|
|
return ShardingSchedule.CalcEpochNumber(blockNumber).Uint64() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// GetShardingStateFromBlockChain will retrieve random seed and shard map from beacon chain for given a epoch
|
|
|
|
|