Skip to content

Commit

Permalink
Minor clean and removing checkings that were not necessary
Browse files Browse the repository at this point in the history
  • Loading branch information
vncoelho committed Dec 17, 2018
1 parent 153f70a commit 73a6da7
Showing 1 changed file with 6 additions and 15 deletions.
21 changes: 6 additions & 15 deletions neo/Consensus/ConsensusService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,12 @@ private void OnPrepareRequestReceived(ConsensusPayload payload, PrepareRequest m
Log($"Invalid request: transaction already exists", LogLevel.Warning);
return;
}
if (!CheckPrimaryPayloadSignature(payload))
{
Log($"Invalid primary signature partial signature for this PrepareRequest payload!", LogLevel.Warning);
return;
}

context.State |= ConsensusState.RequestReceived;
context.Timestamp = payload.Timestamp;
context.Nonce = message.Nonce;
Expand All @@ -240,20 +246,6 @@ private void OnPrepareRequestReceived(ConsensusPayload payload, PrepareRequest m
context.SignedPayloads[payload.ValidatorIndex] = message.PrepReqSignature;
context.FinalSignatures[payload.ValidatorIndex] = message.FinalSignature;

if (!CheckPrimaryPayloadSignature(payload))
{
context.SignedPayloads[payload.ValidatorIndex] = null;
return;
}

for (int i = 0; i < context.SignedPayloads.Length; i++)
if (context.SignedPayloads[i] != null && i != payload.ValidatorIndex)
if (!Crypto.Default.VerifySignature(context.PreparePayload.GetHashData(), context.SignedPayloads[i], context.Validators[i].EncodePoint(false)))
{
Log($"{nameof(OnPrepareRequestReceived)}:Index {i} payload:{payload.ValidatorIndex} length:{context.SignedPayloads.Length} is being set to null");
context.SignedPayloads[i] = null;
}

Dictionary<UInt256, Transaction> mempool = Blockchain.Singleton.GetMemoryPool().ToDictionary(p => p.Hash);
List<Transaction> unverified = new List<Transaction>();
foreach (UInt256 hash in context.TransactionHashes.Skip(1))
Expand Down Expand Up @@ -329,7 +321,6 @@ private void OnPrepareResponseReceived(ConsensusPayload payload, PrepareResponse
{
Log($"{nameof(OnPrepareRequestReceived)}: indirectly from index={payload.ValidatorIndex}, try to speed up p2p route.");
if (message.PreparePayload.ValidatorIndex != context.PrimaryIndex) return;
if (!CheckPrimaryPayloadSignature(message.PreparePayload)) return;
OnConsensusPayload(message.PreparePayload);
}

Expand Down

0 comments on commit 73a6da7

Please sign in to comment.