types: remove dep on p2p

This commit is contained in:
Ethan Buchman 2018-02-14 18:31:09 -05:00
parent 200787ede2
commit fd58645dd2

View File

@ -8,10 +8,11 @@ import (
"github.com/pkg/errors" "github.com/pkg/errors"
"github.com/tendermint/tendermint/p2p"
cmn "github.com/tendermint/tmlibs/common" cmn "github.com/tendermint/tmlibs/common"
) )
type p2pID string
/* /*
VoteSet helps collect signatures from validators at each height+round for a VoteSet helps collect signatures from validators at each height+round for a
predefined vote type. predefined vote type.
@ -59,7 +60,7 @@ type VoteSet struct {
sum int64 // Sum of voting power for seen votes, discounting conflicts sum int64 // Sum of voting power for seen votes, discounting conflicts
maj23 *BlockID // First 2/3 majority seen maj23 *BlockID // First 2/3 majority seen
votesByBlock map[string]*blockVotes // string(blockHash|blockParts) -> blockVotes votesByBlock map[string]*blockVotes // string(blockHash|blockParts) -> blockVotes
peerMaj23s map[p2p.ID]BlockID // Maj23 for each peer peerMaj23s map[p2pID]BlockID // Maj23 for each peer
} }
// Constructs a new VoteSet struct used to accumulate votes for given height/round. // Constructs a new VoteSet struct used to accumulate votes for given height/round.
@ -78,7 +79,7 @@ func NewVoteSet(chainID string, height int64, round int, type_ byte, valSet *Val
sum: 0, sum: 0,
maj23: nil, maj23: nil,
votesByBlock: make(map[string]*blockVotes, valSet.Size()), votesByBlock: make(map[string]*blockVotes, valSet.Size()),
peerMaj23s: make(map[p2p.ID]BlockID), peerMaj23s: make(map[p2pID]BlockID),
} }
} }
@ -291,7 +292,7 @@ func (voteSet *VoteSet) addVerifiedVote(vote *Vote, blockKey string, votingPower
// this can cause memory issues. // this can cause memory issues.
// TODO: implement ability to remove peers too // TODO: implement ability to remove peers too
// NOTE: VoteSet must not be nil // NOTE: VoteSet must not be nil
func (voteSet *VoteSet) SetPeerMaj23(peerID p2p.ID, blockID BlockID) error { func (voteSet *VoteSet) SetPeerMaj23(peerID p2pID, blockID BlockID) error {
if voteSet == nil { if voteSet == nil {
cmn.PanicSanity("SetPeerMaj23() on nil VoteSet") cmn.PanicSanity("SetPeerMaj23() on nil VoteSet")
} }