Merge pull request #20140 from karalabe/eth64-handshake-forkid

eth: eth/64 - extend handshake with with fork id
This commit is contained in:
Péter Szilágyi
2019-10-30 13:21:25 +02:00
committed by GitHub
7 changed files with 305 additions and 59 deletions

View File

@ -50,6 +50,9 @@ type ID struct {
Next uint64 // Block number of the next upcoming fork, or 0 if no forks are known
}
// Filter is a fork id filter to validate a remotely advertised ID.
type Filter func(id ID) error
// NewID calculates the Ethereum fork ID from the chain config and head.
func NewID(chain *core.BlockChain) ID {
return newID(
@ -82,7 +85,7 @@ func newID(config *params.ChainConfig, genesis common.Hash, head uint64) ID {
// NewFilter creates a filter that returns if a fork ID should be rejected or not
// based on the local chain's status.
func NewFilter(chain *core.BlockChain) func(id ID) error {
func NewFilter(chain *core.BlockChain) Filter {
return newFilter(
chain.Config(),
chain.Genesis().Hash(),