Browse Source

types: move `MakeBlock` to block.go (#5573)

pull/5579/head
Marko 4 years ago
committed by GitHub
parent
commit
38587d83c4
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 21 deletions
  1. +19
    -0
      types/block.go
  2. +0
    -21
      types/test_util.go

+ 19
- 0
types/block.go View File

@ -305,6 +305,25 @@ func MaxDataBytesNoEvidence(maxBytes int64, valsCount int) int64 {
return maxDataBytes
}
// MakeBlock returns a new block with an empty header, except what can be
// computed from itself.
// It populates the same set of fields validated by ValidateBasic.
func MakeBlock(height int64, txs []Tx, lastCommit *Commit, evidence []Evidence) *Block {
block := &Block{
Header: Header{
Version: tmversion.Consensus{Block: version.BlockProtocol, App: 0},
Height: height,
},
Data: Data{
Txs: txs,
},
Evidence: EvidenceData{Evidence: evidence},
LastCommit: lastCommit,
}
block.fillHeader()
return block
}
//-----------------------------------------------------------------------------
// Header defines the structure of a Tendermint block header.


+ 0
- 21
types/test_util.go View File

@ -5,8 +5,6 @@ import (
"time"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
tmversion "github.com/tendermint/tendermint/proto/tendermint/version"
"github.com/tendermint/tendermint/version"
)
func MakeCommit(blockID BlockID, height int64, round int32,
@ -80,22 +78,3 @@ func MakeVote(
return vote, nil
}
// MakeBlock returns a new block with an empty header, except what can be
// computed from itself.
// It populates the same set of fields validated by ValidateBasic.
func MakeBlock(height int64, txs []Tx, lastCommit *Commit, evidence []Evidence) *Block {
block := &Block{
Header: Header{
Version: tmversion.Consensus{Block: version.BlockProtocol, App: 0},
Height: height,
},
Data: Data{
Txs: txs,
},
Evidence: EvidenceData{Evidence: evidence},
LastCommit: lastCommit,
}
block.fillHeader()
return block
}

Loading…
Cancel
Save