-
Notifications
You must be signed in to change notification settings - Fork 100
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create consensus plugin #453
Merged
Changes from 5 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
185e10b
Create consensus plugin
erikzhang dbac755
Merge branch 'master' into dBFT
erikzhang b547c60
Fix
erikzhang 29f96e9
Add RecoveryLogs to config.json
erikzhang 0ba8790
Update DBFTPlugin.cs
erikzhang 27296b3
Fix startup
erikzhang 8f941d5
Optimize the logs
erikzhang 82e1571
Add start command
erikzhang d3c393e
Add AutoStart to config.json
erikzhang 8633a06
Merge branch 'master' into dBFT
erikzhang 24e313f
Add description
erikzhang 3d87003
Merge branch 'master' into dBFT
shargon File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The project name shouldn't include version number.