-
Notifications
You must be signed in to change notification settings - Fork 100
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into getnativecontract
- Loading branch information
Showing
22 changed files
with
1,812 additions
and
20 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 System.IO; | ||
|
||
namespace Neo.Consensus | ||
{ | ||
public class ChangeView : ConsensusMessage | ||
{ | ||
/// <summary> | ||
/// NewViewNumber is always set to the current ViewNumber asking changeview + 1 | ||
/// </summary> | ||
public byte NewViewNumber => (byte)(ViewNumber + 1); | ||
|
||
/// <summary> | ||
/// Timestamp of when the ChangeView message was created. This allows receiving nodes to ensure | ||
/// they only respond once to a specific ChangeView request (it thus prevents replay of the ChangeView | ||
/// message from repeatedly broadcasting RecoveryMessages). | ||
/// </summary> | ||
public ulong Timestamp; | ||
|
||
/// <summary> | ||
/// Reason | ||
/// </summary> | ||
public ChangeViewReason Reason; | ||
|
||
public override int Size => base.Size + | ||
sizeof(ulong) + // Timestamp | ||
sizeof(ChangeViewReason); // Reason | ||
|
||
public ChangeView() : base(ConsensusMessageType.ChangeView) { } | ||
|
||
public override void Deserialize(BinaryReader reader) | ||
{ | ||
base.Deserialize(reader); | ||
Timestamp = reader.ReadUInt64(); | ||
Reason = (ChangeViewReason)reader.ReadByte(); | ||
} | ||
|
||
public override void Serialize(BinaryWriter writer) | ||
{ | ||
base.Serialize(writer); | ||
writer.Write(Timestamp); | ||
writer.Write((byte)Reason); | ||
} | ||
} | ||
} |
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,12 @@ | ||
namespace Neo.Consensus | ||
{ | ||
public enum ChangeViewReason : byte | ||
{ | ||
Timeout = 0x0, | ||
ChangeAgreement = 0x1, | ||
TxNotFound = 0x2, | ||
TxRejectedByPolicy = 0x3, | ||
TxInvalid = 0x4, | ||
BlockRejectedByPolicy = 0x5 | ||
} | ||
} |
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,26 @@ | ||
using Neo.IO; | ||
using System.IO; | ||
|
||
namespace Neo.Consensus | ||
{ | ||
public class Commit : ConsensusMessage | ||
{ | ||
public byte[] Signature; | ||
|
||
public override int Size => base.Size + Signature.Length; | ||
|
||
public Commit() : base(ConsensusMessageType.Commit) { } | ||
|
||
public override void Deserialize(BinaryReader reader) | ||
{ | ||
base.Deserialize(reader); | ||
Signature = reader.ReadFixedBytes(64); | ||
} | ||
|
||
public override void Serialize(BinaryWriter writer) | ||
{ | ||
base.Serialize(writer); | ||
writer.Write(Signature); | ||
} | ||
} | ||
} |
Oops, something went wrong.