mirror of
https://github.com/tendermint/tendermint.git
synced 2026-07-29 11:32:56 +00:00
everything but binary, common, and blocks are explicitly imported.
This commit is contained in:
@@ -13,9 +13,9 @@ import (
|
||||
. "github.com/tendermint/tendermint/binary"
|
||||
. "github.com/tendermint/tendermint/blocks"
|
||||
. "github.com/tendermint/tendermint/common"
|
||||
. "github.com/tendermint/tendermint/mempool"
|
||||
"github.com/tendermint/tendermint/mempool"
|
||||
"github.com/tendermint/tendermint/p2p"
|
||||
. "github.com/tendermint/tendermint/state"
|
||||
"github.com/tendermint/tendermint/state"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -102,7 +102,7 @@ type ConsensusReactor struct {
|
||||
doActionCh chan RoundAction
|
||||
}
|
||||
|
||||
func NewConsensusReactor(sw *p2p.Switch, blockStore *BlockStore, mempool *Mempool, state *State) *ConsensusReactor {
|
||||
func NewConsensusReactor(sw *p2p.Switch, blockStore *BlockStore, mempool *mempool.Mempool, state *state.State) *ConsensusReactor {
|
||||
conS := NewConsensusState(state, blockStore, mempool)
|
||||
conR := &ConsensusReactor{
|
||||
sw: sw,
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
package consensus
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestBasicPartSet(t *testing.T) {
|
||||
// XXX this is fun!
|
||||
}
|
||||
+2
-2
@@ -6,7 +6,7 @@ import (
|
||||
. "github.com/tendermint/tendermint/binary"
|
||||
. "github.com/tendermint/tendermint/blocks"
|
||||
. "github.com/tendermint/tendermint/common"
|
||||
. "github.com/tendermint/tendermint/state"
|
||||
"github.com/tendermint/tendermint/state"
|
||||
)
|
||||
|
||||
// Proof of lock.
|
||||
@@ -42,7 +42,7 @@ func (pol *POL) WriteTo(w io.Writer) (n int64, err error) {
|
||||
}
|
||||
|
||||
// Returns whether +2/3 have voted/committed for BlockHash.
|
||||
func (pol *POL) Verify(vset *ValidatorSet) error {
|
||||
func (pol *POL) Verify(vset *state.ValidatorSet) error {
|
||||
|
||||
talliedVotingPower := uint64(0)
|
||||
voteDoc := BinaryBytes(&Vote{Height: pol.Height, Round: pol.Round,
|
||||
|
||||
@@ -3,13 +3,13 @@ package consensus
|
||||
import (
|
||||
. "github.com/tendermint/tendermint/blocks"
|
||||
db_ "github.com/tendermint/tendermint/db"
|
||||
. "github.com/tendermint/tendermint/state"
|
||||
"github.com/tendermint/tendermint/state"
|
||||
)
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
type PrivValidator struct {
|
||||
PrivAccount
|
||||
state.PrivAccount
|
||||
db *db_.LevelDB
|
||||
}
|
||||
|
||||
|
||||
+10
-10
@@ -8,8 +8,8 @@ import (
|
||||
. "github.com/tendermint/tendermint/binary"
|
||||
. "github.com/tendermint/tendermint/blocks"
|
||||
. "github.com/tendermint/tendermint/common"
|
||||
. "github.com/tendermint/tendermint/mempool"
|
||||
. "github.com/tendermint/tendermint/state"
|
||||
"github.com/tendermint/tendermint/mempool"
|
||||
"github.com/tendermint/tendermint/state"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -32,8 +32,8 @@ type RoundState struct {
|
||||
Round uint16
|
||||
Step uint8
|
||||
StartTime time.Time
|
||||
Validators *ValidatorSet
|
||||
Proposer *Validator
|
||||
Validators *state.ValidatorSet
|
||||
Proposer *state.Validator
|
||||
Proposal *Proposal
|
||||
ProposalBlock *Block
|
||||
ProposalBlockPartSet *PartSet
|
||||
@@ -52,16 +52,16 @@ type RoundState struct {
|
||||
// Tracks consensus state across block heights and rounds.
|
||||
type ConsensusState struct {
|
||||
blockStore *BlockStore
|
||||
mempool *Mempool
|
||||
mempool *mempool.Mempool
|
||||
|
||||
mtx sync.Mutex
|
||||
RoundState
|
||||
state *State // State until height-1.
|
||||
stagedBlock *Block // Cache last staged block.
|
||||
stagedState *State // Cache result of staged block.
|
||||
state *state.State // State until height-1.
|
||||
stagedBlock *Block // Cache last staged block.
|
||||
stagedState *state.State // Cache result of staged block.
|
||||
}
|
||||
|
||||
func NewConsensusState(state *State, blockStore *BlockStore, mempool *Mempool) *ConsensusState {
|
||||
func NewConsensusState(state *state.State, blockStore *BlockStore, mempool *mempool.Mempool) *ConsensusState {
|
||||
cs := &ConsensusState{
|
||||
blockStore: blockStore,
|
||||
mempool: mempool,
|
||||
@@ -77,7 +77,7 @@ func (cs *ConsensusState) GetRoundState() *RoundState {
|
||||
return &rs
|
||||
}
|
||||
|
||||
func (cs *ConsensusState) updateToState(state *State) {
|
||||
func (cs *ConsensusState) updateToState(state *state.State) {
|
||||
// Sanity check state.
|
||||
stateHeight := state.Height
|
||||
if stateHeight > 0 && stateHeight != cs.Height+1 {
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
|
||||
. "github.com/tendermint/tendermint/blocks"
|
||||
. "github.com/tendermint/tendermint/common"
|
||||
. "github.com/tendermint/tendermint/state"
|
||||
"github.com/tendermint/tendermint/state"
|
||||
)
|
||||
|
||||
// VoteSet helps collect signatures from validators at each height+round
|
||||
@@ -23,7 +23,7 @@ type VoteSet struct {
|
||||
type_ byte
|
||||
|
||||
mtx sync.Mutex
|
||||
vset *ValidatorSet
|
||||
vset *state.ValidatorSet
|
||||
votes map[uint64]*Vote
|
||||
votesBitArray BitArray
|
||||
votesByBlockHash map[string]uint64
|
||||
@@ -33,7 +33,7 @@ type VoteSet struct {
|
||||
}
|
||||
|
||||
// Constructs a new VoteSet struct used to accumulate votes for each round.
|
||||
func NewVoteSet(height uint32, round uint16, type_ byte, vset *ValidatorSet) *VoteSet {
|
||||
func NewVoteSet(height uint32, round uint16, type_ byte, vset *state.ValidatorSet) *VoteSet {
|
||||
if type_ == VoteTypeCommit && round != 0 {
|
||||
panic("Expected round 0 for commit vote set")
|
||||
}
|
||||
|
||||
@@ -3,29 +3,29 @@ package consensus
|
||||
import (
|
||||
. "github.com/tendermint/tendermint/blocks"
|
||||
. "github.com/tendermint/tendermint/common"
|
||||
. "github.com/tendermint/tendermint/state"
|
||||
"github.com/tendermint/tendermint/state"
|
||||
|
||||
"testing"
|
||||
)
|
||||
|
||||
func makeValidator(id uint64, votingPower uint64) (*Validator, *PrivAccount) {
|
||||
privAccount := GenPrivAccount()
|
||||
func makeValidator(id uint64, votingPower uint64) (*state.Validator, *state.PrivAccount) {
|
||||
privAccount := state.GenPrivAccount()
|
||||
privAccount.Id = id
|
||||
return &Validator{
|
||||
return &state.Validator{
|
||||
Account: privAccount.Account,
|
||||
VotingPower: votingPower,
|
||||
}, privAccount
|
||||
}
|
||||
|
||||
func makeVoteSet(height uint32, round uint16, numValidators int, votingPower uint64) (*VoteSet, *ValidatorSet, []*PrivAccount) {
|
||||
vals := make([]*Validator, numValidators)
|
||||
privAccounts := make([]*PrivAccount, numValidators)
|
||||
func makeVoteSet(height uint32, round uint16, numValidators int, votingPower uint64) (*VoteSet, *state.ValidatorSet, []*state.PrivAccount) {
|
||||
vals := make([]*state.Validator, numValidators)
|
||||
privAccounts := make([]*state.PrivAccount, numValidators)
|
||||
for i := 0; i < numValidators; i++ {
|
||||
val, privAccount := makeValidator(uint64(i), votingPower)
|
||||
vals[i] = val
|
||||
privAccounts[i] = privAccount
|
||||
}
|
||||
valSet := NewValidatorSet(vals)
|
||||
valSet := state.NewValidatorSet(vals)
|
||||
return NewVoteSet(height, round, VoteTypeBare, valSet), valSet, privAccounts
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user