eth/connmanager: get sync status

Signed-off-by: Csaba Kiraly <csaba.kiraly@gmail.com>
This commit is contained in:
Csaba Kiraly 2025-03-26 00:12:23 +01:00
parent 61b26a93c5
commit 628c5e5b7b
2 changed files with 7 additions and 2 deletions

View file

@ -405,7 +405,7 @@ func (s *Ethereum) Start() error {
s.handler.Start(s.p2pServer.MaxPeers)
// Start the connection manager
s.connman.Start(s.p2pServer)
s.connman.Start(s.p2pServer, s.Synced)
// start log indexer
s.filterMaps.Start()

View file

@ -49,6 +49,7 @@ type connManager struct {
connmanConfig
srv *p2p.Server
peersFunc getPeersFunc
syncFunc getSyncFunc
// the peerDrop timer introduces churn if we are close to limit capacity
peerDropTimer *mclock.Alarm
@ -62,6 +63,9 @@ type connManager struct {
// callback type to get the list of connected peers.
type getPeersFunc func() []*p2p.Peer
// callback type to get sync status.
type getSyncFunc func() bool
type connmanConfig struct {
maxDialPeers int // maximum number of dialed peers
log log.Logger
@ -97,10 +101,11 @@ func newConnManager(config *connmanConfig) *connManager {
return cm
}
func (cm *connManager) Start(srv *p2p.Server) {
func (cm *connManager) Start(srv *p2p.Server, syncFunc getSyncFunc) {
cm.wg.Add(1)
cm.srv = srv
cm.peersFunc = srv.Peers
cm.syncFunc = syncFunc
cm.sub = srv.SubscribeEvents(cm.peerEventCh)
go cm.loop()
}