Skip to content

Commit

Permalink
Change to a formula
Browse files Browse the repository at this point in the history
  • Loading branch information
shargon committed Nov 14, 2019
1 parent beb7ab3 commit 26d68b0
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions neo/Consensus/ConsensusContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ internal class ConsensusContext : IDisposable, ISerializable
public Block Block;
public byte ViewNumber;
public ECPoint[] Validators;
public TimeSpan PrepareRequestThreshold;
public int MyIndex;
public UInt256[] TransactionHashes;
public Dictionary<UInt256, Transaction> Transactions;
Expand Down Expand Up @@ -349,6 +350,7 @@ public void Reset(byte viewNumber)
};
var pv = Validators;
Validators = NativeContract.NEO.GetNextBlockValidators(Snapshot);
PrepareRequestThreshold = TimeSpan.FromMilliseconds((Validators.Length + 1) * Blockchain.TimePerBlock.TotalMilliseconds);
if (_witnessSize == 0 || (pv != null && pv.Length != Validators.Length))
{
// Compute the expected size of the witness
Expand Down
2 changes: 1 addition & 1 deletion neo/Consensus/ConsensusService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ private void OnPrepareRequestReceived(ConsensusPayload payload, PrepareRequest m
if (context.RequestSentOrReceived || context.NotAcceptingPayloadsDueToViewChanging) return;
if (payload.ValidatorIndex != context.Block.ConsensusData.PrimaryIndex || message.ViewNumber != context.ViewNumber) return;
Log($"{nameof(OnPrepareRequestReceived)}: height={payload.BlockIndex} view={message.ViewNumber} index={payload.ValidatorIndex} tx={message.TransactionHashes.Length}");
if (message.Timestamp <= context.PrevHeader.Timestamp || message.Timestamp > TimeProvider.Current.UtcNow.AddMinutes(2).ToTimestampMS())
if (message.Timestamp <= context.PrevHeader.Timestamp || message.Timestamp > TimeProvider.Current.UtcNow.Add(context.PrepareRequestThreshold).ToTimestampMS())
{
Log($"Timestamp incorrect: {message.Timestamp}", LogLevel.Warning);
return;
Expand Down

0 comments on commit 26d68b0

Please sign in to comment.