Merge pull request #116 from filecoin-project/fix/mining-restart
fix chain progression after restarting process
This commit is contained in:
commit
af73ae0b89
@ -28,7 +28,6 @@ var log = logging.Logger("chain")
|
||||
|
||||
type Syncer struct {
|
||||
// The heaviest known tipset in the network.
|
||||
head *types.TipSet
|
||||
|
||||
// The interface for accessing and putting tipsets into local storage
|
||||
store *store.ChainStore
|
||||
@ -67,7 +66,6 @@ func NewSyncer(cs *store.ChainStore, bsync *BlockSync, self peer.ID) (*Syncer, e
|
||||
Genesis: gent,
|
||||
Bsync: bsync,
|
||||
peerHeads: make(map[peer.ID]*types.TipSet),
|
||||
head: cs.GetHeaviestTipSet(),
|
||||
store: cs,
|
||||
self: self,
|
||||
}, nil
|
||||
@ -270,10 +268,6 @@ func (syncer *Syncer) Sync(maybeHead *store.FullTipSet) error {
|
||||
return errors.Wrap(err, "failed to put synced tipset to chainstore")
|
||||
}
|
||||
|
||||
if syncer.store.Weight(maybeHead.TipSet()) > syncer.store.Weight(syncer.head) {
|
||||
fmt.Println("Accepted new head: ", maybeHead.Cids())
|
||||
syncer.head = maybeHead.TipSet()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -513,7 +507,7 @@ func persistMessages(bs bstore.Blockstore, bstips []*BSTipSet) error {
|
||||
}
|
||||
|
||||
func (syncer *Syncer) collectChain(fts *store.FullTipSet) error {
|
||||
curHeight := syncer.head.Height()
|
||||
curHeight := syncer.store.GetHeaviestTipSet().Height()
|
||||
|
||||
headers, err := syncer.collectHeaders(fts.TipSet(), curHeight)
|
||||
if err != nil {
|
||||
|
@ -55,11 +55,9 @@ func ChainBlockservice(bs dtypes.ChainBlockstore, rem dtypes.ChainExchange) dtyp
|
||||
func ChainStore(lc fx.Lifecycle, bs dtypes.ChainBlockstore, ds dtypes.MetadataDS) *store.ChainStore {
|
||||
chain := store.NewChainStore(bs, ds)
|
||||
|
||||
lc.Append(fx.Hook{
|
||||
OnStart: func(ctx context.Context) error {
|
||||
return chain.Load()
|
||||
},
|
||||
})
|
||||
if err := chain.Load(); err != nil {
|
||||
log.Warnf("loading chain state from disk: %s", err)
|
||||
}
|
||||
|
||||
return chain
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user