Skip to content

Commit

Permalink
Caching FeePerByte on Transaction (neo-project#516)
Browse files Browse the repository at this point in the history
  • Loading branch information
igormcoelho authored and erikzhang committed Dec 12, 2018
1 parent 5b13e34 commit 2de1b01
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions neo/Network/P2P/Payloads/Transaction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,21 @@ public abstract class Transaction : IEquatable<Transaction>, IInventory
public TransactionOutput[] Outputs;
public Witness[] Witnesses { get; set; }

private Fixed8 _feePerByte = -Fixed8.Satoshi;
/// <summary>
/// The <c>NetworkFee</c> for the transaction divided by its <c>Size</c>.
/// <para>Note that this property must be used with care. Getting the value of this property multiple times will return the same result. The value of this property can only be obtained after the transaction has been completely built (no longer modified).</para>
/// </summary>
public Fixed8 FeePerByte
{
get
{
if (_feePerByte == -Fixed8.Satoshi)
_feePerByte = NetworkFee / Size;
return _feePerByte;
}
}

private UInt256 _hash = null;
public UInt256 Hash
{
Expand Down

0 comments on commit 2de1b01

Please sign in to comment.