forked from TrueCloudLab/neoneo-go
interop: don't allocate for Functions and Notifications in New
Functions are usually immediately replaced (and it's OK for them to be nil, searching through an array with length of zero is fine), Notifications are usually appended to (and are absolutely useless in verification contexts).
This commit is contained in:
parent
2e39f1a1e3
commit
2808f6857d
1 changed files with 8 additions and 12 deletions
|
@ -57,23 +57,19 @@ func NewContext(trigger trigger.Type, bc blockchainer.Blockchainer, d dao.DAO,
|
||||||
block *block.Block, tx *transaction.Transaction, log *zap.Logger) *Context {
|
block *block.Block, tx *transaction.Transaction, log *zap.Logger) *Context {
|
||||||
baseExecFee := int64(DefaultBaseExecFee)
|
baseExecFee := int64(DefaultBaseExecFee)
|
||||||
dao := d.GetWrapped()
|
dao := d.GetWrapped()
|
||||||
nes := make([]state.NotificationEvent, 0)
|
|
||||||
|
|
||||||
if bc != nil && (block == nil || block.Index != 0) {
|
if bc != nil && (block == nil || block.Index != 0) {
|
||||||
baseExecFee = bc.GetPolicer().GetBaseExecFee()
|
baseExecFee = bc.GetPolicer().GetBaseExecFee()
|
||||||
}
|
}
|
||||||
return &Context{
|
return &Context{
|
||||||
Chain: bc,
|
Chain: bc,
|
||||||
Network: uint32(bc.GetConfig().Magic),
|
Network: uint32(bc.GetConfig().Magic),
|
||||||
Natives: natives,
|
Natives: natives,
|
||||||
Trigger: trigger,
|
Trigger: trigger,
|
||||||
Block: block,
|
Block: block,
|
||||||
Tx: tx,
|
Tx: tx,
|
||||||
DAO: dao,
|
DAO: dao,
|
||||||
Notifications: nes,
|
Log: log,
|
||||||
Log: log,
|
|
||||||
// Functions is a slice of interops sorted by ID.
|
|
||||||
Functions: []Function{},
|
|
||||||
getContract: getContract,
|
getContract: getContract,
|
||||||
baseExecFee: baseExecFee,
|
baseExecFee: baseExecFee,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue