From f1a8f47d4dc7e258775eb90a209de72d2cb39d81 Mon Sep 17 00:00:00 2001 From: Sam Kleinman Date: Fri, 18 Mar 2022 12:27:10 -0400 Subject: [PATCH] types: minor cleanup of un or minimally used types (#8154) --- internal/consensus/types/height_vote_set.go | 2 +- types/keys.go | 6 ------ types/signable.go | 10 ---------- types/vote_set.go | 18 ++++++------------ 4 files changed, 7 insertions(+), 29 deletions(-) delete mode 100644 types/keys.go diff --git a/internal/consensus/types/height_vote_set.go b/internal/consensus/types/height_vote_set.go index dd8630725..661c5120e 100644 --- a/internal/consensus/types/height_vote_set.go +++ b/internal/consensus/types/height_vote_set.go @@ -199,7 +199,7 @@ func (hvs *HeightVoteSet) SetPeerMaj23( if voteSet == nil { return nil // something we don't know about yet } - return voteSet.SetPeerMaj23(types.P2PID(peerID), blockID) + return voteSet.SetPeerMaj23(string(peerID), blockID) } //--------------------------------------------------------- diff --git a/types/keys.go b/types/keys.go deleted file mode 100644 index 941e82b65..000000000 --- a/types/keys.go +++ /dev/null @@ -1,6 +0,0 @@ -package types - -// UNSTABLE -var ( - PeerStateKey = "ConsensusReactor.peerState" -) diff --git a/types/signable.go b/types/signable.go index 25e307316..85b9bb911 100644 --- a/types/signable.go +++ b/types/signable.go @@ -11,13 +11,3 @@ var ( // XXX: secp256k1 does not have Size nor MaxSize defined. MaxSignatureSize = tmmath.MaxInt(ed25519.SignatureSize, 64) ) - -// Signable is an interface for all signable things. -// It typically removes signatures before serializing. -// SignBytes returns the bytes to be signed -// NOTE: chainIDs are part of the SignBytes but not -// necessarily the object themselves. -// NOTE: Expected to panic if there is an error marshaling. -type Signable interface { - SignBytes(chainID string) []byte -} diff --git a/types/vote_set.go b/types/vote_set.go index 438d089b3..142a4130c 100644 --- a/types/vote_set.go +++ b/types/vote_set.go @@ -18,12 +18,6 @@ const ( MaxVotesCount = 10000 ) -// 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 predefined vote type. @@ -71,7 +65,7 @@ type VoteSet struct { sum int64 // Sum of voting power for seen votes, discounting conflicts maj23 *BlockID // First 2/3 majority seen votesByBlock map[string]*blockVotes // string(blockHash|blockParts) -> blockVotes - peerMaj23s map[P2PID]BlockID // Maj23 for each peer + peerMaj23s map[string]BlockID // Maj23 for each peer } // Constructs a new VoteSet struct used to accumulate votes for given height/round. @@ -91,7 +85,7 @@ func NewVoteSet(chainID string, height int64, round int32, sum: 0, maj23: nil, votesByBlock: make(map[string]*blockVotes, valSet.Size()), - peerMaj23s: make(map[P2PID]BlockID), + peerMaj23s: make(map[string]BlockID), } } @@ -313,7 +307,7 @@ func (voteSet *VoteSet) addVerifiedVote( // this can cause memory issues. // TODO: implement ability to remove peers too // NOTE: VoteSet must not be nil -func (voteSet *VoteSet) SetPeerMaj23(peerID P2PID, blockID BlockID) error { +func (voteSet *VoteSet) SetPeerMaj23(peerID string, blockID BlockID) error { if voteSet == nil { panic("SetPeerMaj23() on nil VoteSet") } @@ -530,9 +524,9 @@ func (voteSet *VoteSet) MarshalJSON() ([]byte, error) { // NOTE: insufficient for unmarshaling from (compressed votes) // TODO: make the peerMaj23s nicer to read (eg just the block hash) type VoteSetJSON struct { - Votes []string `json:"votes"` - VotesBitArray string `json:"votes_bit_array"` - PeerMaj23s map[P2PID]BlockID `json:"peer_maj_23s"` + Votes []string `json:"votes"` + VotesBitArray string `json:"votes_bit_array"` + PeerMaj23s map[string]BlockID `json:"peer_maj_23s"` } // Return the bit-array of votes including