From 448d0bbd4e7b13e81aaeace79603fa963d5689bf Mon Sep 17 00:00:00 2001 From: Dave Collins Date: Tue, 22 Nov 2016 12:04:42 -0600 Subject: [PATCH] mempool: Remove exported InsertVote function. (#483) Vote insertion is an internal mempool operation and thus should not be exposed to callers outside of the package. It also had an undocumented assumption that the provided tx had already passed stake.IsSSGen checks which is yet another reason the function shouldn't be exposed. --- mempool.go | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/mempool.go b/mempool.go index 8e0f5af3..993011a3 100644 --- a/mempool.go +++ b/mempool.go @@ -220,16 +220,6 @@ func (mp *txMemPool) insertVote(ssgen *dcrutil.Tx) error { return nil } -// InsertVote inserts a vote into the map of block votes. -// -// This function is safe for concurrent access. -func (mp *txMemPool) InsertVote(ssgen *dcrutil.Tx) error { - mp.votesMtx.Lock() - defer mp.votesMtx.Unlock() - - return mp.insertVote(ssgen) -} - // getVoteHashesForBlock gets the transaction hashes of all the known votes for // some block on the blockchain. func (mp *txMemPool) getVoteHashesForBlock(block chainhash.Hash) ([]chainhash.Hash, error) { @@ -1218,7 +1208,9 @@ func (mp *txMemPool) maybeAcceptTransaction(tx *dcrutil.Tx, isNew, // If it's an SSGen (vote), insert it into the list of // votes. if txType == stake.TxTypeSSGen { - err := mp.InsertVote(tx) + mp.votesMtx.Lock() + err := mp.insertVote(tx) + mp.votesMtx.Unlock() if err != nil { return nil, err }