chore: export vm.ShouldBurn
This commit is contained in:
parent
c3d94f8aa9
commit
7d2adc383f
@ -43,9 +43,11 @@ import (
|
|||||||
|
|
||||||
const MaxCallDepth = 4096
|
const MaxCallDepth = 4096
|
||||||
|
|
||||||
var log = logging.Logger("vm")
|
var (
|
||||||
var actorLog = logging.Logger("actors")
|
log = logging.Logger("vm")
|
||||||
var gasOnActorExec = newGasCharge("OnActorExec", 0, 0)
|
actorLog = logging.Logger("actors")
|
||||||
|
gasOnActorExec = newGasCharge("OnActorExec", 0, 0)
|
||||||
|
)
|
||||||
|
|
||||||
// stat counters
|
// stat counters
|
||||||
var (
|
var (
|
||||||
@ -72,8 +74,10 @@ func ResolveToKeyAddr(state types.StateTree, cst cbor.IpldStore, addr address.Ad
|
|||||||
return aast.PubkeyAddress()
|
return aast.PubkeyAddress()
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ cbor.IpldBlockstore = (*gasChargingBlocks)(nil)
|
var (
|
||||||
var _ blockstore.Viewer = (*gasChargingBlocks)(nil)
|
_ cbor.IpldBlockstore = (*gasChargingBlocks)(nil)
|
||||||
|
_ blockstore.Viewer = (*gasChargingBlocks)(nil)
|
||||||
|
)
|
||||||
|
|
||||||
type gasChargingBlocks struct {
|
type gasChargingBlocks struct {
|
||||||
chargeGas func(GasCharge)
|
chargeGas func(GasCharge)
|
||||||
@ -194,9 +198,11 @@ func (vm *UnsafeVM) MakeRuntime(ctx context.Context, msg *types.Message) *Runtim
|
|||||||
return vm.VM.makeRuntime(ctx, msg, nil)
|
return vm.VM.makeRuntime(ctx, msg, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
type CircSupplyCalculator func(context.Context, abi.ChainEpoch, *state.StateTree) (abi.TokenAmount, error)
|
type (
|
||||||
type NtwkVersionGetter func(context.Context, abi.ChainEpoch) network.Version
|
CircSupplyCalculator func(context.Context, abi.ChainEpoch, *state.StateTree) (abi.TokenAmount, error)
|
||||||
type LookbackStateGetter func(context.Context, abi.ChainEpoch) (*state.StateTree, error)
|
NtwkVersionGetter func(context.Context, abi.ChainEpoch) network.Version
|
||||||
|
LookbackStateGetter func(context.Context, abi.ChainEpoch) (*state.StateTree, error)
|
||||||
|
)
|
||||||
|
|
||||||
type VM struct {
|
type VM struct {
|
||||||
cstate *state.StateTree
|
cstate *state.StateTree
|
||||||
@ -265,7 +271,6 @@ type ApplyRet struct {
|
|||||||
|
|
||||||
func (vm *VM) send(ctx context.Context, msg *types.Message, parent *Runtime,
|
func (vm *VM) send(ctx context.Context, msg *types.Message, parent *Runtime,
|
||||||
gasCharge *GasCharge, start time.Time) ([]byte, aerrors.ActorError, *Runtime) {
|
gasCharge *GasCharge, start time.Time) ([]byte, aerrors.ActorError, *Runtime) {
|
||||||
|
|
||||||
defer atomic.AddUint64(&StatSends, 1)
|
defer atomic.AddUint64(&StatSends, 1)
|
||||||
|
|
||||||
st := vm.cstate
|
st := vm.cstate
|
||||||
@ -563,7 +568,7 @@ func (vm *VM) ApplyMessage(ctx context.Context, cmsg types.ChainMsg) (*ApplyRet,
|
|||||||
gasUsed = 0
|
gasUsed = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
burn, err := vm.shouldBurn(st, msg, errcode)
|
burn, err := vm.ShouldBurn(st, msg, errcode)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, xerrors.Errorf("deciding whether should burn failed: %w", err)
|
return nil, xerrors.Errorf("deciding whether should burn failed: %w", err)
|
||||||
}
|
}
|
||||||
@ -606,7 +611,7 @@ func (vm *VM) ApplyMessage(ctx context.Context, cmsg types.ChainMsg) (*ApplyRet,
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (vm *VM) shouldBurn(st *state.StateTree, msg *types.Message, errcode exitcode.ExitCode) (bool, error) {
|
func (vm *VM) ShouldBurn(st *state.StateTree, msg *types.Message, errcode exitcode.ExitCode) (bool, error) {
|
||||||
// Check to see if we should burn funds. We avoid burning on successful
|
// Check to see if we should burn funds. We avoid burning on successful
|
||||||
// window post. This won't catch _indirect_ window post calls, but this
|
// window post. This won't catch _indirect_ window post calls, but this
|
||||||
// is the best we can get for now.
|
// is the best we can get for now.
|
||||||
@ -737,7 +742,7 @@ func Copy(ctx context.Context, from, to blockstore.Blockstore, root cid.Cid) err
|
|||||||
close(freeBufs)
|
close(freeBufs)
|
||||||
}()
|
}()
|
||||||
|
|
||||||
var batch = <-freeBufs
|
batch := <-freeBufs
|
||||||
batchCp := func(blk block.Block) error {
|
batchCp := func(blk block.Block) error {
|
||||||
numBlocks++
|
numBlocks++
|
||||||
totalCopySize += len(blk.RawData())
|
totalCopySize += len(blk.RawData())
|
||||||
|
Loading…
Reference in New Issue
Block a user