mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-11-23 13:38:35 +00:00
transaction: cache feePerByte
This commit is contained in:
parent
2f09ec38fc
commit
3097dc60e5
1 changed files with 8 additions and 1 deletions
|
@ -64,6 +64,9 @@ type Transaction struct {
|
||||||
// for correct signing/verification.
|
// for correct signing/verification.
|
||||||
Network netmode.Magic
|
Network netmode.Magic
|
||||||
|
|
||||||
|
// feePerByte is the ratio of NetworkFee and tx size, used for calculating tx priority.
|
||||||
|
feePerByte int64
|
||||||
|
|
||||||
// Hash of the transaction (double SHA256).
|
// Hash of the transaction (double SHA256).
|
||||||
hash util.Uint256
|
hash util.Uint256
|
||||||
|
|
||||||
|
@ -278,7 +281,11 @@ func NewTransactionFromBytes(network netmode.Magic, b []byte) (*Transaction, err
|
||||||
// FeePerByte returns NetworkFee of the transaction divided by
|
// FeePerByte returns NetworkFee of the transaction divided by
|
||||||
// its size
|
// its size
|
||||||
func (t *Transaction) FeePerByte() int64 {
|
func (t *Transaction) FeePerByte() int64 {
|
||||||
return t.NetworkFee / int64(io.GetVarSize(t))
|
if t.feePerByte != 0 {
|
||||||
|
return t.feePerByte
|
||||||
|
}
|
||||||
|
t.feePerByte = t.NetworkFee / int64(io.GetVarSize(t))
|
||||||
|
return t.feePerByte
|
||||||
}
|
}
|
||||||
|
|
||||||
// transactionJSON is a wrapper for Transaction and
|
// transactionJSON is a wrapper for Transaction and
|
||||||
|
|
Loading…
Reference in a new issue