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 {
|
|
|
|
log.Error(err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
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-06-02 14:29:39 +00:00
|
|
|
log.Errorf("%+v", err)
|
2019-11-19 12:57:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|