Skip to content

Commit

Permalink
deny blocks with duplicate transactions
Browse files Browse the repository at this point in the history
  • Loading branch information
erikzhang committed Nov 2, 2018
1 parent a64ca72 commit 6ff2b9a
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions neo/Network/P2P/Payloads/Block.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public override void Deserialize(BinaryReader reader)
base.Deserialize(reader);
Transactions = new Transaction[reader.ReadVarInt(0x10000)];
if (Transactions.Length == 0) throw new FormatException();
HashSet<UInt256> hashes = new HashSet<UInt256>();
for (int i = 0; i < Transactions.Length; i++)
{
Transactions[i] = Transaction.DeserializeFrom(reader);
Expand All @@ -66,6 +67,8 @@ public override void Deserialize(BinaryReader reader)
if (Transactions[i].Type == TransactionType.MinerTransaction)
throw new FormatException();
}
if (!hashes.Add(Transactions[i].Hash))
throw new FormatException();
}
if (MerkleTree.ComputeRoot(Transactions.Select(p => p.Hash).ToArray()) != MerkleRoot)
throw new FormatException();
Expand Down

0 comments on commit 6ff2b9a

Please sign in to comment.