core/forkid: add NewStaticFilter

This commit is contained in:
Felix Lange 2019-10-17 14:49:42 +02:00
parent 4ca202d988
commit d9f697c03c

View file

@ -80,7 +80,7 @@ func newID(config *params.ChainConfig, genesis common.Hash, head uint64) ID {
return ID{Hash: checksumToBytes(hash), Next: next} return ID{Hash: checksumToBytes(hash), Next: next}
} }
// NewFilter creates an filter that returns if a fork ID should be rejected or not // NewFilter creates a filter that returns if a fork ID should be rejected or not
// based on the local chain's status. // based on the local chain's status.
func NewFilter(chain *core.BlockChain) func(id ID) error { func NewFilter(chain *core.BlockChain) func(id ID) error {
return newFilter( return newFilter(
@ -92,6 +92,12 @@ func NewFilter(chain *core.BlockChain) func(id ID) error {
) )
} }
// NewStaticFilter creates a filter at block zero.
func NewStaticFilter(config *params.ChainConfig, genesis common.Hash) func(id ID) error {
head := func() uint64 { return 0 }
return newFilter(config, genesis, head)
}
// newFilter is the internal version of NewFilter, taking closures as its arguments // newFilter is the internal version of NewFilter, taking closures as its arguments
// instead of a chain. The reason is to allow testing it without having to simulate // instead of a chain. The reason is to allow testing it without having to simulate
// an entire blockchain. // an entire blockchain.