Skip to content

Commit

Permalink
Revert #2009 (#2070)
Browse files Browse the repository at this point in the history
  • Loading branch information
Qiao-Jin committed Nov 20, 2020
1 parent 9b0391d commit 05c02ef
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions neo/Network/P2P/Payloads/Transaction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,26 +82,24 @@ public virtual Fixed8 NetworkFee
}

private IReadOnlyDictionary<CoinReference, TransactionOutput> _references;
private bool hasCalculatedReferences = false;
public IReadOnlyDictionary<CoinReference, TransactionOutput> References
{
get
{
if (!hasCalculatedReferences && _references == null)
if (_references == null)
{
hasCalculatedReferences = true;
Dictionary<CoinReference, TransactionOutput> dictionary = new Dictionary<CoinReference, TransactionOutput>();
foreach (var group in Inputs.GroupBy(p => p.PrevHash))
{
Transaction tx = Blockchain.Singleton.Store.GetTransaction(group.Key);
if (tx == null) return null;
foreach (var reference in group)
foreach (var reference in group.Select(p => new
{
if (reference.PrevIndex >= Outputs.Length)
{
return null;
}
dictionary.Add(reference, tx.Outputs[reference.PrevIndex]);
Input = p,
Output = tx.Outputs[p.PrevIndex]
}))
{
dictionary.Add(reference.Input, reference.Output);
}
}
_references = dictionary;
Expand Down

0 comments on commit 05c02ef

Please sign in to comment.