Skip to content

Commit e02ed09

Browse files
committed
fix count vote
1 parent 40ce84f commit e02ed09

File tree

1 file changed

+21
-24
lines changed

1 file changed

+21
-24
lines changed

src/main/java/org/tron/core/witness/WitnessController.java

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -259,30 +259,27 @@ private Map<ByteString, Long> countVote(VotesStore votesStore) {
259259
// .getVoteRewardRate());
260260
//account.setBalance(account.getBalance() + reward);
261261
//accountStore.put(account.createDbKey(), account);
262-
Optional<Long> sum = votes.getNewVotes().stream().map(vote -> vote.getVoteCount())
263-
.reduce((a, b) -> a + b);
264-
if (sum.isPresent()) { //todo: will be removed in next deployment
265-
votes.getOldVotes().forEach(vote -> {
266-
//TODO validate witness //active_witness
267-
ByteString voteAddress = vote.getVoteAddress();
268-
long voteCount = vote.getVoteCount();
269-
if (countWitness.containsKey(voteAddress)) {
270-
countWitness.put(voteAddress, countWitness.get(voteAddress) - voteCount);
271-
} else {
272-
countWitness.put(voteAddress, -voteCount);
273-
}
274-
});
275-
votes.getNewVotes().forEach(vote -> {
276-
//TODO validate witness //active_witness
277-
ByteString voteAddress = vote.getVoteAddress();
278-
long voteCount = vote.getVoteCount();
279-
if (countWitness.containsKey(voteAddress)) {
280-
countWitness.put(voteAddress, countWitness.get(voteAddress) + voteCount);
281-
} else {
282-
countWitness.put(voteAddress, voteCount);
283-
}
284-
});
285-
}
262+
263+
votes.getOldVotes().forEach(vote -> {
264+
//TODO validate witness //active_witness
265+
ByteString voteAddress = vote.getVoteAddress();
266+
long voteCount = vote.getVoteCount();
267+
if (countWitness.containsKey(voteAddress)) {
268+
countWitness.put(voteAddress, countWitness.get(voteAddress) - voteCount);
269+
} else {
270+
countWitness.put(voteAddress, -voteCount);
271+
}
272+
});
273+
votes.getNewVotes().forEach(vote -> {
274+
//TODO validate witness //active_witness
275+
ByteString voteAddress = vote.getVoteAddress();
276+
long voteCount = vote.getVoteCount();
277+
if (countWitness.containsKey(voteAddress)) {
278+
countWitness.put(voteAddress, countWitness.get(voteAddress) + voteCount);
279+
} else {
280+
countWitness.put(voteAddress, voteCount);
281+
}
282+
});
286283

287284

288285
sizeCount++;

0 commit comments

Comments
 (0)