[epoch] fix IsLastBlock if block is less than epoch block

Signed-off-by: Leo Chen <leo@harmony.one>
pull/1246/head
Leo Chen 5 years ago
parent e08d634082
commit 38cd570c0d
  1. 1
      core/blockchain.go
  2. 2
      internal/configs/sharding/localnet.go
  3. 2
      internal/configs/sharding/mainnet.go
  4. 2
      internal/configs/sharding/testnet.go

@ -224,6 +224,7 @@ func (bc *BlockChain) ValidateNewBlock(block *types.Block) error {
}
// IsEpochBlock returns whether this block is the first block of an epoch.
// TODO: lc this is not used
func IsEpochBlock(block *types.Block) bool {
return block.NumberU64()%ShardingSchedule.BlocksPerEpoch() == 0
}

@ -48,6 +48,8 @@ func (ls localnetSchedule) CalcEpochNumber(blockNum uint64) *big.Int {
func (ls localnetSchedule) IsLastBlock(blockNum uint64) bool {
blocks := ls.BlocksPerEpoch()
switch {
case blockNum < localnetEpochBlock1-1:
return false
case blockNum == localnetEpochBlock1-1:
return true
default:

@ -44,6 +44,8 @@ func (ms mainnetSchedule) CalcEpochNumber(blockNum uint64) *big.Int {
func (ms mainnetSchedule) IsLastBlock(blockNum uint64) bool {
blocks := ms.BlocksPerEpoch()
switch {
case blockNum < mainnetEpochBlock1-1:
return false
case blockNum == mainnetEpochBlock1-1:
return true
default:

@ -49,6 +49,8 @@ func (ts testnetSchedule) CalcEpochNumber(blockNum uint64) *big.Int {
func (ts testnetSchedule) IsLastBlock(blockNum uint64) bool {
blocks := ts.BlocksPerEpoch()
switch {
case blockNum < testnetEpochBlock1-1:
return false
case blockNum == testnetEpochBlock1-1:
return true
default:

Loading…
Cancel
Save