types: p2pID -> P2PID

This commit is contained in:
Ethan Buchman
2018-02-20 11:14:50 -05:00
parent 6cf5100645
commit ca3655a409
3 changed files with 9 additions and 6 deletions

View File

@ -218,5 +218,5 @@ func (hvs *HeightVoteSet) SetPeerMaj23(round int, type_ byte, peerID p2p.ID, blo
if voteSet == nil { if voteSet == nil {
return nil // something we don't know about yet return nil // something we don't know about yet
} }
return voteSet.SetPeerMaj23(peerID, blockID) return voteSet.SetPeerMaj23(types.P2PID(peerID), blockID)
} }

View File

@ -187,7 +187,6 @@ func argsToJson(args map[string]interface{}) error {
continue continue
} }
// Pass everything else to go-wire
data, err := json.Marshal(v) data, err := json.Marshal(v)
if err != nil { if err != nil {
return err return err

View File

@ -11,7 +11,11 @@ import (
cmn "github.com/tendermint/tmlibs/common" cmn "github.com/tendermint/tmlibs/common"
) )
type p2pID string // UNSTABLE
// XXX: duplicate of p2p.ID to avoid dependence between packages.
// Perhaps we can have a minimal types package containing this (and other things?)
// that both `types` and `p2p` import ?
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
@ -60,7 +64,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[p2pID]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.
@ -79,7 +83,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[p2pID]BlockID), peerMaj23s: make(map[P2PID]BlockID),
} }
} }
@ -292,7 +296,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 p2pID, 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")
} }