Skip to content

Commit

Permalink
Optimize Gas Mint (#2038)
Browse files Browse the repository at this point in the history
  • Loading branch information
shargon committed Oct 30, 2020
1 parent 7a8bb73 commit 6f8e03a
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/neo/SmartContract/Native/Tokens/GasToken.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using Neo.Cryptography.ECC;
using Neo.Ledger;
using Neo.Network.P2P.Payloads;
using System.Linq;

namespace Neo.SmartContract.Native.Tokens
{
Expand All @@ -25,11 +24,15 @@ internal override void Initialize(ApplicationEngine engine)
protected override void OnPersist(ApplicationEngine engine)
{
base.OnPersist(engine);
long totalNetworkFee = 0;
foreach (Transaction tx in engine.Snapshot.PersistingBlock.Transactions)
{
Burn(engine, tx.Sender, tx.SystemFee + tx.NetworkFee);
totalNetworkFee += tx.NetworkFee;
}
ECPoint[] validators = NEO.GetNextBlockValidators(engine.Snapshot);
UInt160 primary = Contract.CreateSignatureRedeemScript(validators[engine.Snapshot.PersistingBlock.ConsensusData.PrimaryIndex]).ToScriptHash();
Mint(engine, primary, engine.Snapshot.PersistingBlock.Transactions.Sum(p => p.NetworkFee));
Mint(engine, primary, totalNetworkFee);
}
}
}

0 comments on commit 6f8e03a

Please sign in to comment.