diff --git a/eth/backend.go b/eth/backend.go index a79b047365..fde6b2e1a4 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -62,6 +62,16 @@ import ( gethversion "github.com/ethereum/go-ethereum/version" ) +const ( + // This is the fairness knob for the discovery mixer. When looking for peers, we'll + // wait this long for a single source of candidates before moving on and trying other + // sources. If this timeout expires, the source will be skipped in this round, but it + // will continue to fetch in the background and will have a chance with a new timeout + // in the next rounds, giving it overall more time but a proportionally smaller share. + // We expect a normal source to produce ~10 candidates per second. + discmixTimeout = 100 * time.Millisecond +) + // Config contains the configuration options of the ETH protocol. // Deprecated: use ethconfig.Config instead. type Config = ethconfig.Config @@ -169,7 +179,7 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) { networkID: networkID, gasPrice: config.Miner.GasPrice, p2pServer: stack.Server(), - discmix: enode.NewFairMix(0), + discmix: enode.NewFairMix(discmixTimeout), shutdownTracker: shutdowncheck.NewShutdownTracker(chainDb), } bcVersion := rawdb.ReadDatabaseVersion(chainDb) diff --git a/p2p/server.go b/p2p/server.go index 30b7a63017..da3495a1f6 100644 --- a/p2p/server.go +++ b/p2p/server.go @@ -47,8 +47,9 @@ const ( // This is the fairness knob for the discovery mixer. When looking for peers, we'll // wait this long for a single source of candidates before moving on and trying other - // sources. - discmixTimeout = 5 * time.Second + // sources. Currently there is only one source at the Server level, so this has no effect. + // Check the fairMox tineout in the Backend for the actual timeout. + discmixTimeout = 100 * time.Millisecond // Connectivity defaults. defaultMaxPendingPeers = 50