mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-12-12 01:10:36 +00:00
core: fix system fee calculation
It was completely wrong starting from the genesis block.
This commit is contained in:
parent
a46c93f6bb
commit
70a20ce031
1 changed files with 36 additions and 3 deletions
|
@ -1577,11 +1577,44 @@ func (bc *Blockchain) NetworkFee(t *transaction.Transaction) util.Fixed8 {
|
|||
|
||||
// SystemFee returns system fee.
|
||||
func (bc *Blockchain) SystemFee(t *transaction.Transaction) util.Fixed8 {
|
||||
if t.Type == transaction.InvocationType {
|
||||
switch t.Type {
|
||||
case transaction.InvocationType:
|
||||
inv := t.Data.(*transaction.InvocationTX)
|
||||
if inv.Version >= 1 {
|
||||
return inv.Gas
|
||||
return inv.Gas
|
||||
case transaction.IssueType:
|
||||
if t.Version >= 1 {
|
||||
return util.Fixed8(0)
|
||||
}
|
||||
var iszero = true
|
||||
for i := range t.Outputs {
|
||||
asset := t.Outputs[i].AssetID
|
||||
if asset != UtilityTokenID() && asset != GoverningTokenID() {
|
||||
iszero = false
|
||||
break
|
||||
}
|
||||
}
|
||||
if iszero {
|
||||
return util.Fixed8(0)
|
||||
}
|
||||
case transaction.RegisterType:
|
||||
reg := t.Data.(*transaction.RegisterTX)
|
||||
if reg.AssetType == transaction.GoverningToken || reg.AssetType == transaction.UtilityToken {
|
||||
return util.Fixed8(0)
|
||||
}
|
||||
case transaction.StateType:
|
||||
res := util.Fixed8(0)
|
||||
st := t.Data.(*transaction.StateTX)
|
||||
for _, desc := range st.Descriptors {
|
||||
if desc.Type == transaction.Validator && desc.Field == "Registered" {
|
||||
for i := range desc.Value {
|
||||
if desc.Value[i] != 0 {
|
||||
res += util.Fixed8FromInt64(1000)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return res
|
||||
}
|
||||
return bc.GetConfig().SystemFee.TryGetValue(t.Type)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue