mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
cmd/devp2p: make -eth-network filter actually work
This commit is contained in:
parent
d9f697c03c
commit
00d05619d8
1 changed files with 13 additions and 13 deletions
|
|
@ -23,6 +23,7 @@ import (
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/core/forkid"
|
"github.com/ethereum/go-ethereum/core/forkid"
|
||||||
"github.com/ethereum/go-ethereum/p2p/enr"
|
"github.com/ethereum/go-ethereum/p2p/enr"
|
||||||
|
"github.com/ethereum/go-ethereum/params"
|
||||||
"github.com/ethereum/go-ethereum/rlp"
|
"github.com/ethereum/go-ethereum/rlp"
|
||||||
"gopkg.in/urfave/cli.v1"
|
"gopkg.in/urfave/cli.v1"
|
||||||
)
|
)
|
||||||
|
|
@ -154,19 +155,18 @@ func minAgeFilter(args []string) (nodeFilter, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func ethFilter(args []string) (nodeFilter, error) {
|
func ethFilter(args []string) (nodeFilter, error) {
|
||||||
// var config *params.ChainConfig
|
var filter func(forkid.ID) error
|
||||||
// switch args[0] {
|
switch args[0] {
|
||||||
// case "mainnet":
|
case "mainnet":
|
||||||
// config = params.MainnetChainConfig
|
filter = forkid.NewStaticFilter(params.MainnetChainConfig, params.MainnetGenesisHash)
|
||||||
// case "rinkeby":
|
case "rinkeby":
|
||||||
// config = params.RinkebyChainConfig
|
filter = forkid.NewStaticFilter(params.RinkebyChainConfig, params.RinkebyGenesisHash)
|
||||||
// case "goerli":
|
case "goerli":
|
||||||
// config = params.GoerliChainConfig
|
filter = forkid.NewStaticFilter(params.GoerliChainConfig, params.GoerliGenesisHash)
|
||||||
// default:
|
default:
|
||||||
// return nil, fmt.Errorf("unknown network %q", args[0])
|
return nil, fmt.Errorf("unknown network %q", args[0])
|
||||||
// }
|
}
|
||||||
|
|
||||||
forkFilter := forkid.NewFilter(nil)
|
|
||||||
f := func(n nodeJSON) bool {
|
f := func(n nodeJSON) bool {
|
||||||
var eth struct {
|
var eth struct {
|
||||||
ForkID forkid.ID
|
ForkID forkid.ID
|
||||||
|
|
@ -175,7 +175,7 @@ func ethFilter(args []string) (nodeFilter, error) {
|
||||||
if n.N.Load(enr.WithEntry("eth", ð)) != nil {
|
if n.N.Load(enr.WithEntry("eth", ð)) != nil {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
return forkFilter(eth.ForkID) == nil
|
return filter(eth.ForkID) == nil
|
||||||
}
|
}
|
||||||
return f, nil
|
return f, nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue