Skip to content

Commit

Permalink
Fix bug displaying the wrong number of votes in getstakeinfo
Browse files Browse the repository at this point in the history
If a ticket was used to generate multiple votes, DumpSSGenHashes would
only load the first vote generated. The wstakemgr/stake.go code now
loads all vote hashes, so that the number of votes are counted
correctly in getstakeinfo.
  • Loading branch information
cjepson committed Feb 26, 2016
1 parent ee2a72a commit a6a8ce9
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions wstakemgr/stake.go
Original file line number Diff line number Diff line change
Expand Up @@ -361,12 +361,14 @@ func (s *StakeStore) dumpSSGenHashes() ([]chainhash.Hash, error) {

// Store each hash sequentially.
errForEach = bucket.ForEach(func(k []byte, v []byte) error {
rec, errDeser := deserializeSSGenRecord(v)
recs, errDeser := deserializeSSGenRecords(v)
if errDeser != nil {
return errDeser
}

voteList = append(voteList, rec.txHash)
for _, rec := range recs {
voteList = append(voteList, rec.txHash)
}
return nil
})

Expand Down Expand Up @@ -548,12 +550,9 @@ func (s *StakeStore) InsertSSGen(blockHash *chainhash.Hash, blockHeight int64,
return s.insertSSGen(blockHash, blockHeight, ssgenHash, voteBits, sstxHash)
}

// GetSSGens gets a list of SSGens that have been generated for some stake
// getSSGens gets a list of SSGens that have been generated for some stake
// ticket.
func (s *StakeStore) getSSGens(sstxHash *chainhash.Hash) ([]*ssgenRecord, error) {
s.mtx.Lock()
defer s.mtx.Unlock()

var records []*ssgenRecord

// Access the database and store the result locally.
Expand Down

0 comments on commit a6a8ce9

Please sign in to comment.