From 48d778c4b39f9a65c24b1173ea0258bbed4324d3 Mon Sep 17 00:00:00 2001 From: Ethan Buchman Date: Wed, 1 Nov 2017 13:57:38 -0600 Subject: [PATCH] types/params: introduce EvidenceParams --- types/params.go | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/types/params.go b/types/params.go index 19e86d449..15d8dbe21 100644 --- a/types/params.go +++ b/types/params.go @@ -14,9 +14,10 @@ const ( // ConsensusParams contains consensus critical parameters // that determine the validity of blocks. type ConsensusParams struct { - BlockSize `json:"block_size_params"` - TxSize `json:"tx_size_params"` - BlockGossip `json:"block_gossip_params"` + BlockSize `json:"block_size_params"` + TxSize `json:"tx_size_params"` + BlockGossip `json:"block_gossip_params"` + EvidenceParams `json:"evidence_params"` } // BlockSize contain limits on the block size. @@ -37,12 +38,18 @@ type BlockGossip struct { BlockPartSizeBytes int `json:"block_part_size_bytes"` // NOTE: must not be 0 } +// EvidenceParams determine how we handle evidence of malfeasance +type EvidenceParams struct { + MaxHeightDiff int `json:"max_height_diff"` // only accept new evidence more recent than this +} + // DefaultConsensusParams returns a default ConsensusParams. func DefaultConsensusParams() *ConsensusParams { return &ConsensusParams{ DefaultBlockSize(), DefaultTxSize(), DefaultBlockGossip(), + DefaultEvidenceParams(), } } @@ -70,6 +77,13 @@ func DefaultBlockGossip() BlockGossip { } } +// DefaultEvidence Params returns a default EvidenceParams. +func DefaultEvidenceParams() EvidenceParams { + return EvidenceParams{ + MaxHeightDiff: 100000, // 27.8 hrs at 1block/s + } +} + // Validate validates the ConsensusParams to ensure all values // are within their allowed limits, and returns an error if they are not. func (params *ConsensusParams) Validate() error {