lotus/cmd/lotus-chainwatch/syncer/blockssub.go

27 lines
437 B
Go
Raw Normal View History

package syncer
2019-11-19 12:57:16 +00:00
import (
"context"
"time"
2019-11-19 21:26:25 +00:00
2019-11-19 12:57:16 +00:00
"github.com/filecoin-project/lotus/chain/types"
"github.com/ipfs/go-cid"
)
func (s *Syncer) subBlocks(ctx context.Context) {
sub, err := s.node.SyncIncomingBlocks(ctx)
2019-11-19 12:57:16 +00:00
if err != nil {
log.Error(err)
return
}
for bh := range sub {
err := s.storeHeaders(map[cid.Cid]*types.BlockHeader{
2019-11-19 12:57:16 +00:00
bh.Cid(): bh,
}, false, time.Now())
2019-11-19 12:57:16 +00:00
if err != nil {
log.Errorf("%+v", err)
2019-11-19 12:57:16 +00:00
}
}
}