feat(lotus-sim): allow walking back past the start
This commit is contained in:
parent
f6043a0250
commit
ec3f969e9a
@ -257,16 +257,16 @@ type AppliedMessage struct {
|
|||||||
// Walk walks the simulation's chain from the current head back to the first tipset.
|
// Walk walks the simulation's chain from the current head back to the first tipset.
|
||||||
func (sim *Simulation) Walk(
|
func (sim *Simulation) Walk(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
maxLookback int64,
|
lookback int64,
|
||||||
cb func(sm *stmgr.StateManager,
|
cb func(sm *stmgr.StateManager,
|
||||||
ts *types.TipSet,
|
ts *types.TipSet,
|
||||||
stCid cid.Cid,
|
stCid cid.Cid,
|
||||||
messages []*AppliedMessage) error,
|
messages []*AppliedMessage) error,
|
||||||
) error {
|
) error {
|
||||||
store := sim.Chainstore.ActorStore(ctx)
|
store := sim.Chainstore.ActorStore(ctx)
|
||||||
minEpoch := abi.ChainEpoch(0)
|
minEpoch := sim.start.Height()
|
||||||
if maxLookback != 0 {
|
if lookback != 0 {
|
||||||
minEpoch = sim.head.Height() - abi.ChainEpoch(maxLookback)
|
minEpoch = sim.head.Height() - abi.ChainEpoch(lookback)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Given tha loading messages and receipts can be a little bit slow, we do this in parallel.
|
// Given tha loading messages and receipts can be a little bit slow, we do this in parallel.
|
||||||
@ -314,7 +314,7 @@ func (sim *Simulation) Walk(
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
i := 0
|
i := 0
|
||||||
for !ts.Equals(sim.start) && ctx.Err() == nil && ts.Height() > minEpoch {
|
for ctx.Err() == nil && ts.Height() > minEpoch {
|
||||||
select {
|
select {
|
||||||
case workQs[i] <- &work{ts, stCid, recCid}:
|
case workQs[i] <- &work{ts, stCid, recCid}:
|
||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
|
Loading…
Reference in New Issue
Block a user