make ConsensusParams.EvidenceParams.MaxAge time

Refs #2565
This commit is contained in:
Anton Kaliaev
2018-10-16 10:26:59 +04:00
parent 80562669bf
commit 7e7e4c74ca
15 changed files with 520 additions and 269 deletions
+15 -5
View File
@@ -8,8 +8,7 @@ import (
"github.com/pkg/errors"
"github.com/tendermint/go-amino"
amino "github.com/tendermint/go-amino"
cstypes "github.com/tendermint/tendermint/consensus/types"
cmn "github.com/tendermint/tendermint/libs/common"
tmevents "github.com/tendermint/tendermint/libs/events"
@@ -438,6 +437,7 @@ func makeRoundStepMessages(rs *cstypes.RoundState) (nrsMsg *NewRoundStepMessage,
if rs.Step == cstypes.RoundStepCommit {
csMsg = &CommitStepMessage{
Height: rs.Height,
Time: rs.CommitTime,
BlockPartsHeader: rs.ProposalBlockParts.Header(),
BlockParts: rs.ProposalBlockParts.BitArray(),
}
@@ -948,14 +948,22 @@ func (ps *PeerState) ToJSON() ([]byte, error) {
return cdc.MarshalJSON(ps)
}
// GetHeight returns an atomic snapshot of the PeerRoundState's height
// used by the mempool to ensure peers are caught up before broadcasting new txs
// GetHeight returns an atomic snapshot of the PeerRoundState's height used by
// the mempool to ensure peers are caught up before broadcasting new txs.
func (ps *PeerState) GetHeight() int64 {
ps.mtx.Lock()
defer ps.mtx.Unlock()
return ps.PRS.Height
}
// GetLastBlockTime returns an atomic snapshot of the PeerRoundState's last
// block time used by the evidence reactor when sending evidence.
func (ps *PeerState) GetLastBlockTime() time.Time {
ps.mtx.Lock()
defer ps.mtx.Unlock()
return ps.PRS.LastBlockTime
}
// SetHasProposal sets the given proposal as known for the peer.
func (ps *PeerState) SetHasProposal(proposal *types.Proposal) {
ps.mtx.Lock()
@@ -1263,6 +1271,7 @@ func (ps *PeerState) ApplyCommitStepMessage(msg *CommitStepMessage) {
ps.PRS.ProposalBlockPartsHeader = msg.BlockPartsHeader
ps.PRS.ProposalBlockParts = msg.BlockParts
ps.PRS.LastBlockTime = msg.Time
}
// ApplyProposalPOLMessage updates the peer state for the new proposal POL.
@@ -1386,13 +1395,14 @@ func (m *NewRoundStepMessage) String() string {
// CommitStepMessage is sent when a block is committed.
type CommitStepMessage struct {
Height int64
Time time.Time
BlockPartsHeader types.PartSetHeader
BlockParts *cmn.BitArray
}
// String returns a string representation.
func (m *CommitStepMessage) String() string {
return fmt.Sprintf("[CommitStep H:%v BP:%v BA:%v]", m.Height, m.BlockPartsHeader, m.BlockParts)
return fmt.Sprintf("[CommitStep H:%v T:%v BP:%v BA:%v]", m.Height, m.Time, m.BlockPartsHeader, m.BlockParts)
}
//-------------------------------------
+3 -2
View File
@@ -14,6 +14,7 @@ import (
// NOTE: Read-only when returned by PeerState.GetRoundState().
type PeerRoundState struct {
Height int64 `json:"height"` // Height peer is at
LastBlockTime time.Time `json:"last_block_time"` // Time the last block was created at.
Round int `json:"round"` // Round peer is at, -1 if unknown.
Step RoundStepType `json:"step"` // Step peer is at
StartTime time.Time `json:"start_time"` // Estimated start of round 0 at this height
@@ -38,7 +39,7 @@ func (prs PeerRoundState) String() string {
// StringIndented returns a string representation of the PeerRoundState
func (prs PeerRoundState) StringIndented(indent string) string {
return fmt.Sprintf(`PeerRoundState{
%s %v/%v/%v @%v
%s %v/%v/%v @%v (last block time @%v)
%s Proposal %v -> %v
%s POL %v (round %v)
%s Prevotes %v
@@ -46,7 +47,7 @@ func (prs PeerRoundState) StringIndented(indent string) string {
%s LastCommit %v (round %v)
%s Catchup %v (round %v)
%s}`,
indent, prs.Height, prs.Round, prs.Step, prs.StartTime,
indent, prs.Height, prs.Round, prs.Step, prs.StartTime, prs.LastBlockTime,
indent, prs.ProposalBlockPartsHeader, prs.ProposalBlockParts,
indent, prs.ProposalPOL, prs.ProposalPOLRound,
indent, prs.Prevotes,