From ff1db75f143b87aac923db3b4ccb2c5e403bc105 Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Tue, 9 Jan 2024 08:39:52 -0500 Subject: [PATCH] fix: need to run OnNewPeer in a goroutine --- service/p2p.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/service/p2p.go b/service/p2p.go index ead595b..0be9e83 100644 --- a/service/p2p.go +++ b/service/p2p.go @@ -205,7 +205,15 @@ func (p *P2PImpl) ConnectToNode(connectionUris []*url.URL, retried bool) error { } peer.SetId(id) - return p.OnNewPeer(peer, true) + + go func() { + err := p.OnNewPeer(peer, true) + if err != nil { + p.logger.Error("failed to add peer", zap.Error(err)) + } + }() + return nil + } func (p *P2PImpl) OnNewPeer(peer net.Peer, verifyId bool) error {