From ffb63a93ff47073782794eb579b3d6ad77ad528c Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Mon, 21 Jun 2021 09:09:06 -0700 Subject: [PATCH] fix(lotus-sim): make 'fund' easier to understand --- cmd/lotus-sim/simulation/stages/funding_stage.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/cmd/lotus-sim/simulation/stages/funding_stage.go b/cmd/lotus-sim/simulation/stages/funding_stage.go index a0d9f4a22..f57f85293 100644 --- a/cmd/lotus-sim/simulation/stages/funding_stage.go +++ b/cmd/lotus-sim/simulation/stages/funding_stage.go @@ -81,13 +81,15 @@ func (fs *FundingStage) SendAndFund(bb *blockbuilder.BlockBuilder, msg *types.Me return res, err } -func (fs *FundingStage) fund(bb *blockbuilder.BlockBuilder, target address.Address, times int) error { +// fund funds the target actor with 'TargetFunds << shift' FIL. The "shift" parameter allows us to +// keep doubling the amount until the intended operation succeeds. +func (fs *FundingStage) fund(bb *blockbuilder.BlockBuilder, target address.Address, shift int) error { amt := TargetFunds - if times > 0 { - if times >= 8 { - times = 8 // cap + if shift > 0 { + if shift >= 8 { + shift = 8 // cap } - amt = big.Lsh(amt, uint(times)) + amt = big.Lsh(amt, uint(shift)) } _, err := bb.PushMessage(&types.Message{ From: fs.fundAccount,