2020-07-14 20:02:44 +00:00
|
|
|
package syncer
|
2019-11-19 12:57:16 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2020-07-14 20:02:44 +00:00
|
|
|
"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"
|
|
|
|
)
|
|
|
|
|
2020-07-14 20:02:44 +00:00
|
|
|
func (s *Syncer) subBlocks(ctx context.Context) {
|
|
|
|
sub, err := s.node.SyncIncomingBlocks(ctx)
|
2019-11-19 12:57:16 +00:00
|
|
|
if err != nil {
|
2020-09-01 02:46:28 +00:00
|
|
|
log.Errorf("opening incoming block channel: %+v", err)
|
2019-11-19 12:57:16 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2020-09-01 02:46:28 +00:00
|
|
|
log.Infow("Capturing incoming blocks")
|
2019-11-19 12:57:16 +00:00
|
|
|
for bh := range sub {
|
2020-07-14 20:02:44 +00:00
|
|
|
err := s.storeHeaders(map[cid.Cid]*types.BlockHeader{
|
2019-11-19 12:57:16 +00:00
|
|
|
bh.Cid(): bh,
|
2020-07-14 20:02:44 +00:00
|
|
|
}, false, time.Now())
|
2019-11-19 12:57:16 +00:00
|
|
|
if err != nil {
|
2020-09-01 02:46:28 +00:00
|
|
|
log.Errorf("storing incoming block header: %+v", err)
|
2019-11-19 12:57:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|