fix(chainwatch): Restore IncomingBlockSync listening
This commit is contained in:
parent
95a75daf9f
commit
7290431cb0
@ -11,16 +11,17 @@ import (
|
|||||||
func (s *Syncer) subBlocks(ctx context.Context) {
|
func (s *Syncer) subBlocks(ctx context.Context) {
|
||||||
sub, err := s.node.SyncIncomingBlocks(ctx)
|
sub, err := s.node.SyncIncomingBlocks(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error(err)
|
log.Errorf("opening incoming block channel: %+v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log.Infow("Capturing incoming blocks")
|
||||||
for bh := range sub {
|
for bh := range sub {
|
||||||
err := s.storeHeaders(map[cid.Cid]*types.BlockHeader{
|
err := s.storeHeaders(map[cid.Cid]*types.BlockHeader{
|
||||||
bh.Cid(): bh,
|
bh.Cid(): bh,
|
||||||
}, false, time.Now())
|
}, false, time.Now())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf("%+v", err)
|
log.Errorf("storing incoming block header: %+v", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -160,11 +160,8 @@ func (s *Syncer) Start(ctx context.Context) {
|
|||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// continue to keep the block headers table up to date.
|
// capture all reported blocks
|
||||||
notifs, err := s.node.ChainNotify(ctx)
|
go s.subBlocks(ctx)
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
// we need to ensure that on a restart we don't reprocess the whole flarping chain
|
// we need to ensure that on a restart we don't reprocess the whole flarping chain
|
||||||
var sinceEpoch uint64
|
var sinceEpoch uint64
|
||||||
@ -177,6 +174,13 @@ func (s *Syncer) Start(ctx context.Context) {
|
|||||||
sinceEpoch = uint64(height)
|
sinceEpoch = uint64(height)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// continue to keep the block headers table up to date.
|
||||||
|
notifs, err := s.node.ChainNotify(ctx)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
for notif := range notifs {
|
for notif := range notifs {
|
||||||
for _, change := range notif {
|
for _, change := range notif {
|
||||||
|
Loading…
Reference in New Issue
Block a user