2019-11-19 12:57:16 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
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"
|
|
|
|
|
|
|
|
aapi "github.com/filecoin-project/lotus/api"
|
|
|
|
)
|
|
|
|
|
|
|
|
func subBlocks(ctx context.Context, api aapi.FullNode, st *storage) {
|
|
|
|
sub, err := api.SyncIncomingBlocks(ctx)
|
|
|
|
if err != nil {
|
|
|
|
log.Error(err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
for bh := range sub {
|
|
|
|
err := st.storeHeaders(map[cid.Cid]*types.BlockHeader{
|
|
|
|
bh.Cid(): bh,
|
|
|
|
}, false)
|
|
|
|
if err != nil {
|
|
|
|
log.Error(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|