forked from neo-project/neo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Payloads: implement Conflicts attribute
Closes neo-project#1991.
- Loading branch information
1 parent
ec7ac2b
commit 77d823c
Showing
14 changed files
with
541 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
using Neo.IO; | ||
using Neo.Json; | ||
using Neo.Persistence; | ||
using Neo.SmartContract.Native; | ||
using System.IO; | ||
|
||
namespace Neo.Network.P2P.Payloads | ||
{ | ||
public class Conflicts : TransactionAttribute | ||
{ | ||
/// <summary> | ||
/// Indicates the conflict transaction hash. | ||
/// </summary> | ||
public UInt256 Hash; | ||
|
||
public override TransactionAttributeType Type => TransactionAttributeType.Conflicts; | ||
|
||
public override bool AllowMultiple => true; | ||
|
||
public override int Size => base.Size + Hash.Size; | ||
|
||
protected override void DeserializeWithoutType(ref MemoryReader reader) | ||
{ | ||
Hash = reader.ReadSerializable<UInt256>(); | ||
} | ||
|
||
protected override void SerializeWithoutType(BinaryWriter writer) | ||
{ | ||
writer.Write(Hash); | ||
} | ||
|
||
public override JObject ToJson() | ||
{ | ||
JObject json = base.ToJson(); | ||
json["hash"] = Hash.ToString(); | ||
return json; | ||
} | ||
|
||
public override bool Verify(DataCache snapshot, Transaction tx) | ||
{ | ||
return !NativeContract.Ledger.ContainsTransaction(snapshot, Hash); | ||
} | ||
} | ||
} |
Oops, something went wrong.