mirror of
https://source.quilibrium.com/quilibrium/ceremonyclient.git
synced 2024-12-25 16:15:17 +00:00
QOL: improve peer connectivity
This commit is contained in:
parent
d74b267f1e
commit
f0a90f6913
@ -51,7 +51,7 @@ func (e *CeremonyDataClockConsensusEngine) handleMessage(
|
||||
msg,
|
||||
)
|
||||
if err != nil {
|
||||
e.logger.Error(
|
||||
e.logger.Debug(
|
||||
"could not process message for engine",
|
||||
zap.Error(err),
|
||||
zap.String("engine_name", name),
|
||||
|
@ -696,7 +696,10 @@ func (e *CeremonyDataClockConsensusEngine) commitLongestPath() (
|
||||
e.logger.Info(
|
||||
"committing candidate",
|
||||
zap.Uint64("frame_number", s.FrameNumber),
|
||||
zap.Binary("prover", s.GetPublicKeySignatureEd448().PublicKey.KeyValue),
|
||||
zap.Binary(
|
||||
"prover",
|
||||
s.GetPublicKeySignatureEd448().PublicKey.KeyValue,
|
||||
),
|
||||
)
|
||||
|
||||
addr, err := s.GetAddress()
|
||||
|
@ -98,7 +98,7 @@ func (e *CeremonyDataClockConsensusEngine) handleClockFramesResponse(
|
||||
}
|
||||
|
||||
if !bytes.Equal(peerID, e.syncingTarget) {
|
||||
e.logger.Warn(
|
||||
e.logger.Debug(
|
||||
"received clock frames response from unexpected target",
|
||||
zap.Binary("peer_id", peerID),
|
||||
zap.Binary("expected_peer_id", e.syncingTarget),
|
||||
|
@ -76,7 +76,11 @@ func NewBlossomSub(
|
||||
|
||||
logger.Info("established peer id", zap.String("peer_id", h.ID().String()))
|
||||
|
||||
go discoverPeers(p2pConfig, ctx, logger, h)
|
||||
kademliaDHT := initDHT(ctx, p2pConfig, logger, h)
|
||||
routingDiscovery := routing.NewRoutingDiscovery(kademliaDHT)
|
||||
util.Advertise(ctx, routingDiscovery, string(BITMASK_ALL))
|
||||
|
||||
go discoverPeers(p2pConfig, ctx, logger, h, routingDiscovery)
|
||||
|
||||
// TODO: turn into an option flag for console logging, this is too noisy for
|
||||
// default logging behavior
|
||||
@ -319,18 +323,15 @@ func discoverPeers(
|
||||
ctx context.Context,
|
||||
logger *zap.Logger,
|
||||
h host.Host,
|
||||
routingDiscovery *routing.RoutingDiscovery,
|
||||
) {
|
||||
logger.Info("initiating peer discovery")
|
||||
|
||||
kademliaDHT := initDHT(ctx, p2pConfig, logger, h)
|
||||
routingDiscovery := routing.NewRoutingDiscovery(kademliaDHT)
|
||||
util.Advertise(ctx, routingDiscovery, string(BITMASK_ALL))
|
||||
|
||||
peerCount := 0
|
||||
discover := func(peerCount int) {
|
||||
for peerCount < p2pConfig.MinPeers {
|
||||
peerChan, err := routingDiscovery.FindPeers(ctx, string(BITMASK_ALL))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
logger.Error("could not find peers", zap.Error(err))
|
||||
}
|
||||
|
||||
for peer := range peerChan {
|
||||
@ -355,6 +356,16 @@ func discoverPeers(
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
discover(0)
|
||||
|
||||
go func() {
|
||||
for {
|
||||
time.Sleep(30 * time.Second)
|
||||
discover(len(h.Network().Peers()))
|
||||
}
|
||||
}()
|
||||
|
||||
logger.Info("completed initial peer discovery")
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user