mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-22 19:50:36 +00:00
Fixes to sentry (#1698)
Co-authored-by: Alexey Sharp <alexeysharp@Alexeys-iMac.local>
This commit is contained in:
parent
eb64d4738d
commit
a3cf656b68
@ -375,6 +375,7 @@ func grpcSentryServer(ctx context.Context, sentryAddr string) (*SentryServerImpl
|
|||||||
}
|
}
|
||||||
grpcServer = grpc.NewServer(opts...)
|
grpcServer = grpc.NewServer(opts...)
|
||||||
sentryServer := &SentryServerImpl{
|
sentryServer := &SentryServerImpl{
|
||||||
|
ctx: ctx,
|
||||||
receiveCh: make(chan StreamMsg, 1024),
|
receiveCh: make(chan StreamMsg, 1024),
|
||||||
receiveUploadCh: make(chan StreamMsg, 1024),
|
receiveUploadCh: make(chan StreamMsg, 1024),
|
||||||
}
|
}
|
||||||
@ -545,7 +546,7 @@ func (ss *SentryServerImpl) SendMessageById(_ context.Context, inreq *proto_sent
|
|||||||
peerID := string(gointerfaces.ConvertH512ToBytes(inreq.PeerId))
|
peerID := string(gointerfaces.ConvertH512ToBytes(inreq.PeerId))
|
||||||
rwRaw, ok := ss.peerRwMap.Load(peerID)
|
rwRaw, ok := ss.peerRwMap.Load(peerID)
|
||||||
if !ok {
|
if !ok {
|
||||||
return &proto_sentry.SentPeers{}, fmt.Errorf("peer not found: %s", inreq.PeerId)
|
return &proto_sentry.SentPeers{}, fmt.Errorf("peer not found: %s", peerID)
|
||||||
}
|
}
|
||||||
rw, _ := rwRaw.(p2p.MsgReadWriter)
|
rw, _ := rwRaw.(p2p.MsgReadWriter)
|
||||||
var msgcode uint64
|
var msgcode uint64
|
||||||
|
@ -117,7 +117,10 @@ func (cs *ControlServerImpl) sendHeaderRequest(ctx context.Context, req *headerd
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (cs *ControlServerImpl) randSentryIndex() (int, bool, func() (int, bool)) {
|
func (cs *ControlServerImpl) randSentryIndex() (int, bool, func() (int, bool)) {
|
||||||
i := rand.Intn(len(cs.sentries) - 1)
|
var i int
|
||||||
|
if len(cs.sentries) > 1 {
|
||||||
|
i = rand.Intn(len(cs.sentries) - 1)
|
||||||
|
}
|
||||||
to := i
|
to := i
|
||||||
return i, true, func() (int, bool) {
|
return i, true, func() (int, bool) {
|
||||||
i = (i + 1) % len(cs.sentries)
|
i = (i + 1) % len(cs.sentries)
|
||||||
|
@ -69,7 +69,7 @@ func StageLoop(
|
|||||||
// but call .Begin() after hearer/body download stages
|
// but call .Begin() after hearer/body download stages
|
||||||
var tx ethdb.DbWithPendingMutations
|
var tx ethdb.DbWithPendingMutations
|
||||||
if canRunCycleInOneTransaction {
|
if canRunCycleInOneTransaction {
|
||||||
tx, err = tx.Begin(context.Background(), ethdb.RW)
|
tx, err = db.Begin(context.Background(), ethdb.RW)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user