types: minor cleanup of un or minimally used types (#8154)

This commit is contained in:
Sam Kleinman
2022-03-18 12:27:10 -04:00
committed by GitHub
parent f61e6e4201
commit f1a8f47d4d
4 changed files with 7 additions and 29 deletions

View File

@@ -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)
}
//---------------------------------------------------------

View File

@@ -1,6 +0,0 @@
package types
// UNSTABLE
var (
PeerStateKey = "ConsensusReactor.peerState"
)

View File

@@ -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
}

View File

@@ -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