everything but binary, common, and blocks are explicitly imported.

This commit is contained in:
Jae Kwon
2014-10-16 16:00:48 -07:00
parent 300f12dd63
commit ac147e2353
13 changed files with 84 additions and 75 deletions
+3 -3
View File
@@ -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,
+9
View File
@@ -0,0 +1,9 @@
package consensus
import (
"testing"
)
func TestBasicPartSet(t *testing.T) {
// XXX this is fun!
}
+2 -2
View File
@@ -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,
+2 -2
View File
@@ -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
View File
@@ -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 {
+3 -3
View File
@@ -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")
}
+8 -8
View File
@@ -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
}