mirror of
https://github.com/tendermint/tendermint.git
synced 2026-02-10 14:00:33 +00:00
types: Remove NewExtendedCommit constructor
Signed-off-by: Thane Thomson <connect@thanethomson.com>
This commit is contained in:
@@ -43,9 +43,9 @@ func (p testPeer) runInputRoutine() {
|
||||
// Request desired, pretend like we got the block immediately.
|
||||
func (p testPeer) simulateInput(input inputData) {
|
||||
block := &types.Block{Header: types.Header{Height: input.request.Height}}
|
||||
var blockID types.BlockID
|
||||
var extCommitSigs []types.ExtendedCommitSig
|
||||
extCommit := types.NewExtendedCommit(input.request.Height, 0, blockID, extCommitSigs)
|
||||
extCommit := &types.ExtendedCommit{
|
||||
Height: input.request.Height,
|
||||
}
|
||||
_ = input.pool.AddBlock(input.request.PeerID, block, extCommit, 123)
|
||||
// TODO: uncommenting this creates a race which is detected by:
|
||||
// https://github.com/golang/go/blob/2bd767b1022dd3254bcec469f0ee164024726486/src/testing/testing.go#L854-L856
|
||||
|
||||
@@ -150,7 +150,7 @@ func (rts *reactorTestSuite) addNode(
|
||||
var lastExtCommit *types.ExtendedCommit
|
||||
|
||||
// The commit we are building for the current height.
|
||||
seenExtCommit := types.NewExtendedCommit(0, 0, types.BlockID{}, nil)
|
||||
seenExtCommit := &types.ExtendedCommit{}
|
||||
|
||||
for blockHeight := int64(1); blockHeight <= maxBlockHeight; blockHeight++ {
|
||||
lastExtCommit = seenExtCommit.Copy()
|
||||
@@ -173,12 +173,12 @@ func (rts *reactorTestSuite) addNode(
|
||||
time.Now(),
|
||||
)
|
||||
require.NoError(t, err)
|
||||
seenExtCommit = types.NewExtendedCommit(
|
||||
vote.Height,
|
||||
vote.Round,
|
||||
blockID,
|
||||
[]types.ExtendedCommitSig{vote.ExtendedCommitSig()},
|
||||
)
|
||||
seenExtCommit = &types.ExtendedCommit{
|
||||
Height: vote.Height,
|
||||
Round: vote.Round,
|
||||
BlockID: blockID,
|
||||
ExtendedSignatures: []types.ExtendedCommitSig{vote.ExtendedCommitSig()},
|
||||
}
|
||||
|
||||
state, err = blockExec.ApplyBlock(ctx, state, blockID, thisBlock)
|
||||
require.NoError(t, err)
|
||||
|
||||
@@ -183,7 +183,7 @@ func TestByzantinePrevoteEquivocation(t *testing.T) {
|
||||
case lazyNodeState.Height == lazyNodeState.state.InitialHeight:
|
||||
// We're creating a proposal for the first block.
|
||||
// The commit is empty, but not nil.
|
||||
commit = types.NewExtendedCommit(0, 0, types.BlockID{}, nil)
|
||||
commit = &types.ExtendedCommit{}
|
||||
case lazyNodeState.LastCommit.HasTwoThirdsMajority():
|
||||
// Make the commit from LastCommit
|
||||
commit = lazyNodeState.LastCommit.MakeExtendedCommit()
|
||||
|
||||
@@ -1097,8 +1097,12 @@ func makeBlockchainFromWAL(t *testing.T, wal WAL) ([]*types.Block, []*types.Exte
|
||||
require.NoError(t, err)
|
||||
case *types.Vote:
|
||||
if p.Type == tmproto.PrecommitType {
|
||||
thisBlockExtCommit = types.NewExtendedCommit(p.Height, p.Round,
|
||||
p.BlockID, []types.ExtendedCommitSig{p.ExtendedCommitSig()})
|
||||
thisBlockExtCommit = &types.ExtendedCommit{
|
||||
Height: p.Height,
|
||||
Round: p.Round,
|
||||
BlockID: p.BlockID,
|
||||
ExtendedSignatures: []types.ExtendedCommitSig{p.ExtendedCommitSig()},
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1402,7 +1402,7 @@ func (cs *State) createProposalBlock(ctx context.Context) (*types.Block, error)
|
||||
case cs.Height == cs.state.InitialHeight:
|
||||
// We're creating a proposal for the first block.
|
||||
// The commit is empty, but not nil.
|
||||
extCommit = types.NewExtendedCommit(0, 0, types.BlockID{}, nil)
|
||||
extCommit = &types.ExtendedCommit{}
|
||||
|
||||
case cs.LastCommit.HasTwoThirdsMajority():
|
||||
// Make the commit from LastCommit
|
||||
|
||||
@@ -587,12 +587,16 @@ func initializeBlockStore(db dbm.DB, state sm.State, valAddr []byte) (*store.Blo
|
||||
}
|
||||
|
||||
func makeExtCommit(height int64, valAddr []byte) *types.ExtendedCommit {
|
||||
return types.NewExtendedCommit(height, 0, types.BlockID{}, []types.ExtendedCommitSig{{
|
||||
BlockIDFlag: types.BlockIDFlagCommit,
|
||||
ValidatorAddress: valAddr,
|
||||
Timestamp: defaultEvidenceTime,
|
||||
Signature: []byte("Signature"),
|
||||
}})
|
||||
return &types.ExtendedCommit{
|
||||
Height: height,
|
||||
BlockID: types.BlockID{},
|
||||
ExtendedSignatures: []types.ExtendedCommitSig{{
|
||||
BlockIDFlag: types.BlockIDFlagCommit,
|
||||
ValidatorAddress: valAddr,
|
||||
Timestamp: defaultEvidenceTime,
|
||||
Signature: []byte("Signature"),
|
||||
}},
|
||||
}
|
||||
}
|
||||
|
||||
func defaultTestPool(ctx context.Context, t *testing.T, height int64) (*evidence.Pool, types.MockPV, *eventbus.EventBus) {
|
||||
|
||||
@@ -94,7 +94,11 @@ func makeValidCommit(
|
||||
votes[i] = vote
|
||||
}
|
||||
|
||||
return types.NewExtendedCommit(height, 0, blockID, sigs), votes
|
||||
return &types.ExtendedCommit{
|
||||
Height: height,
|
||||
BlockID: blockID,
|
||||
ExtendedSignatures: sigs,
|
||||
}, votes
|
||||
}
|
||||
|
||||
func makeState(t *testing.T, nVals, height int) (sm.State, dbm.DB, map[string]types.PrivValidator) {
|
||||
|
||||
@@ -35,15 +35,14 @@ func makeTestExtCommit(height int64, timestamp time.Time) *types.ExtendedCommit
|
||||
Timestamp: timestamp,
|
||||
Signature: []byte("Signature"),
|
||||
}}
|
||||
return types.NewExtendedCommit(
|
||||
height,
|
||||
0,
|
||||
types.BlockID{
|
||||
return &types.ExtendedCommit{
|
||||
Height: height,
|
||||
BlockID: types.BlockID{
|
||||
Hash: crypto.CRandBytes(32),
|
||||
PartSetHeader: types.PartSetHeader{Hash: crypto.CRandBytes(32), Total: 2},
|
||||
},
|
||||
extCommitSigs,
|
||||
)
|
||||
ExtendedSignatures: extCommitSigs,
|
||||
}
|
||||
}
|
||||
|
||||
func makeStateAndBlockStore(dir string) (sm.State, *BlockStore, cleanupFunc, error) {
|
||||
|
||||
@@ -339,7 +339,7 @@ func TestCreateProposalBlock(t *testing.T) {
|
||||
sm.NopMetrics(),
|
||||
)
|
||||
|
||||
extCommit := types.NewExtendedCommit(height-1, 0, types.BlockID{}, nil)
|
||||
extCommit := &types.ExtendedCommit{Height: height - 1}
|
||||
block, err := blockExec.CreateProposalBlock(
|
||||
ctx,
|
||||
height,
|
||||
@@ -419,7 +419,7 @@ func TestMaxTxsProposalBlockSize(t *testing.T) {
|
||||
sm.NopMetrics(),
|
||||
)
|
||||
|
||||
extCommit := types.NewExtendedCommit(height-1, 0, types.BlockID{}, nil)
|
||||
extCommit := &types.ExtendedCommit{Height: height - 1}
|
||||
block, err := blockExec.CreateProposalBlock(
|
||||
ctx,
|
||||
height,
|
||||
|
||||
@@ -1083,16 +1083,6 @@ type ExtendedCommit struct {
|
||||
bitArray *bits.BitArray
|
||||
}
|
||||
|
||||
// NewExtendedCommit constructs an ExtendedCommit from the given parameters.
|
||||
func NewExtendedCommit(height int64, round int32, blockID BlockID, extCommitSigs []ExtendedCommitSig) *ExtendedCommit {
|
||||
return &ExtendedCommit{
|
||||
Height: height,
|
||||
Round: round,
|
||||
BlockID: blockID,
|
||||
ExtendedSignatures: extCommitSigs,
|
||||
}
|
||||
}
|
||||
|
||||
// Copy creates a copy of this extended commit.
|
||||
func (extCommit *ExtendedCommit) Copy() *ExtendedCommit {
|
||||
ec := *extCommit
|
||||
|
||||
@@ -635,7 +635,12 @@ func (voteSet *VoteSet) MakeExtendedCommit() *ExtendedCommit {
|
||||
extCommitSigs[i] = extCommitSig
|
||||
}
|
||||
|
||||
return NewExtendedCommit(voteSet.GetHeight(), voteSet.GetRound(), *voteSet.maj23, extCommitSigs)
|
||||
return &ExtendedCommit{
|
||||
Height: voteSet.GetHeight(),
|
||||
Round: voteSet.GetRound(),
|
||||
BlockID: *voteSet.maj23,
|
||||
ExtendedSignatures: extCommitSigs,
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user