Skip to content

Commit

Permalink
refactor: low discovery interval (#1435)
Browse files Browse the repository at this point in the history
* try 1ms discovery interval on mainnet node 1

* deploy to mainnet 2

* deploy to mainnet 3

* deploy to mainnet 3

* Revert "deploy to mainnet 3"

This reverts commit 38a1746.

* Revert "deploy to mainnet 3"

This reverts commit 4d9e8dc.

* deploy different interval mechanism to node 1

* add domain type filtering (mainnet node 1)

* 100ms discovery interval

* comment

* deploy to node 2

* deploy to mainnet 3 & 4

* revert deployments

* deploy to holesky prod

* revert deployments
  • Loading branch information
moshe-blox authored Jun 16, 2024
1 parent 39046e4 commit 5933360
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions network/discovery/dv5_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
)

var (
defaultDiscoveryInterval = time.Second
defaultDiscoveryInterval = time.Millisecond * 100
publishENRTimeout = time.Minute

publishStateReady = int32(0)
Expand Down Expand Up @@ -215,7 +215,7 @@ func (dvs *DiscV5Service) initDiscV5Listener(logger *zap.Logger, discOpts *Optio
// by a random walking on the underlying DHT.
//
// handler will act upon new node.
// interval enables to control the rate of new nodes that we find.
// interval enables to control the rate of discovered nodes that we accept.
// filters will be applied on each new node before the handler is called,
// enabling to apply custom access control for different scenarios.
func (dvs *DiscV5Service) discover(ctx context.Context, handler HandleNewPeer, interval time.Duration, filters ...NodeFilter) {
Expand All @@ -226,15 +226,10 @@ func (dvs *DiscV5Service) discover(ctx context.Context, handler HandleNewPeer, i
// selfID is used to exclude current node
selfID := dvs.dv5Listener.LocalNode().Node().ID().TerminalString()

t := time.NewTimer(interval)
defer t.Stop()
wait := func() {
t.Reset(interval)
<-t.C
}
ticker := time.NewTicker(interval)
defer ticker.Stop()

for ctx.Err() == nil {
wait()
exists := iterator.Next()
if !exists {
continue
Expand All @@ -252,6 +247,11 @@ func (dvs *DiscV5Service) discover(ctx context.Context, handler HandleNewPeer, i
AddrInfo: *ai,
Node: n,
})
select {
case <-ticker.C:
case <-ctx.Done():
return
}
}
}
}
Expand Down

0 comments on commit 5933360

Please sign in to comment.