eth: enforce chain above CHT before accepting txs into the pool

This commit is contained in:
Péter Szilágyi
2019-04-26 12:11:22 +03:00
parent 3873a7314d
commit ed47f29bc8
2 changed files with 33 additions and 7 deletions

View File

@ -202,8 +202,17 @@ func (pm *ProtocolManager) synchronise(peer *peer) {
log.Info("Fast sync complete, auto disabling")
atomic.StoreUint32(&pm.fastSync, 0)
}
atomic.StoreUint32(&pm.acceptTxs, 1) // Mark initial sync done
if head := pm.blockchain.CurrentBlock(); head.NumberU64() > 0 {
// If we've successfully finished a sync cycle and passed any required checkpoint,
// enable accepting transactions from the network.
head := pm.blockchain.CurrentBlock()
if head.NumberU64() >= pm.checkpointNumber {
// Checkpoint passed, sanity check the timestamp to have a fallback mechanism
// for non-checkpointed (number = 0) private networks.
if head.Time() >= uint64(time.Now().AddDate(0, -1, 0).Unix()) {
atomic.StoreUint32(&pm.acceptTxs, 1)
}
}
if head.NumberU64() > 0 {
// We've completed a sync cycle, notify all peers of new state. This path is
// essential in star-topology networks where a gateway node needs to notify
// all its out-of-date peers of the availability of a new block. This failure