diff --git a/consensus/moca/proposal.go b/consensus/moca/proposal.go index ea9226647..2c959735b 100644 --- a/consensus/moca/proposal.go +++ b/consensus/moca/proposal.go @@ -85,6 +85,12 @@ func (consensus *Consensus) waitAndHandleProposal() (*election.Election, error) continue } + err = ledger.TimestampCheck(proposal.Header.Timestamp) + if err != nil { + log.Warningf("Ignore proposal that fails to pass timestamp check: %v", err) + continue + } + err := ledger.SignerCheck(proposal.Header) if err != nil { log.Warningf("Ignore proposal that fails to pass signer check: %v", err) @@ -114,12 +120,6 @@ func (consensus *Consensus) waitAndHandleProposal() (*election.Election, error) acceptProposal = false } - err = ledger.TimestampCheck(proposal.Header.Timestamp) - if err != nil { - log.Warningf("Proposal fails to pass timestamp check: %v", err) - acceptProposal = false - } - err = ledger.NextBlockProposerCheck(proposal) if err != nil { log.Warningf("Proposal fails to pass next block proposal check: %v", err) diff --git a/core/ledger/validator.go b/core/ledger/validator.go index 0a3718c0a..75f697b10 100644 --- a/core/ledger/validator.go +++ b/core/ledger/validator.go @@ -247,8 +247,9 @@ func TimestampCheck(timestamp int64) error { latest := now.Add(TimestampTolerance) if t.Before(earliest) || t.After(latest) { - return fmt.Errorf("timestamp %d exceed my tolerance [%d, %d]", timestamp, earliest.Unix(), latest.Unix()) + return fmt.Errorf("timestamp %v exceed my tolerance [%v, %v]", t, earliest, latest) } + return nil }