Don't ignore BSQ burned by invalid txs in chart data models

Use 'Tx::getBurntBsq' instead of 'Tx::getBurntFee', so as not to exclude
BSQ burned by invalid txs from the supply calculations. There are no
invalid BSQ txs at present on mainchain, but accidentally burned BSQ
should definitely count as a reduction in supply, so this fixes a bug.
This commit is contained in:
Steven Barclay 2024-02-20 16:21:07 +08:00
parent 712c97826b
commit d97636eaad
No known key found for this signature in database
GPG Key ID: 9FED6BF1176D500B
2 changed files with 6 additions and 6 deletions

View File

@ -307,7 +307,7 @@ public class PriceChartDataModel extends ChartDataModel {
private NavigableMap<Long, Double> getOutstandingBsqByInterval() {
Stream<Tx> txStream = daoStateService.getBlocks().stream()
.flatMap(b -> b.getTxs().stream())
.filter(tx -> tx.getBurntFee() > 0);
.filter(tx -> tx.getBurntBsq() > 0);
Map<Long, Double> simpleBurns = txStream
.collect(Collectors.groupingBy(
tx -> toTimeInterval(Instant.ofEpochMilli(tx.getTime())),

View File

@ -210,7 +210,7 @@ public class DaoChartDataModel extends ChartDataModel {
return totalBurnedByInterval;
}
totalBurnedByInterval = getBurntBsqByInterval(getBurntFeeTxStream(), getDateFilter());
totalBurnedByInterval = getBurntBsqByInterval(getBurntBsqTxStream(), getDateFilter());
return totalBurnedByInterval;
}
@ -246,7 +246,7 @@ public class DaoChartDataModel extends ChartDataModel {
return miscBurnByInterval;
}
Map<Long, Long> allMiscBurnByInterval = getBurntFeeTxStream()
Map<Long, Long> allMiscBurnByInterval = getBurntBsqTxStream()
.filter(e -> e.getTxType() != TxType.PAY_TRADE_FEE)
.filter(e -> e.getTxType() != TxType.PROOF_OF_BURN)
.collect(Collectors.groupingBy(
@ -295,7 +295,7 @@ public class DaoChartDataModel extends ChartDataModel {
Collection<Issuance> issuanceSetForType = daoStateService.getIssuanceItems();
// get all issued and burnt BSQ, not just the filtered date range
Map<Long, Long> tmpIssuedByInterval = getIssuedBsqByInterval(issuanceSetForType, e -> true);
Map<Long, Long> tmpBurnedByInterval = getBurntBsqByInterval(getBurntFeeTxStream(), e -> true);
Map<Long, Long> tmpBurnedByInterval = getBurntBsqByInterval(getBurntBsqTxStream(), e -> true);
tmpBurnedByInterval.replaceAll((k, v) -> -v);
Map<Long, Long> tmpSupplyByInterval = new TreeMap<>(getMergedMap(tmpIssuedByInterval, tmpBurnedByInterval, Long::sum));
@ -354,10 +354,10 @@ public class DaoChartDataModel extends ChartDataModel {
// TODO: Consider moving these two methods to DaoStateService:
private Stream<Tx> getBurntFeeTxStream() {
private Stream<Tx> getBurntBsqTxStream() {
return daoStateService.getBlocks().stream()
.flatMap(b -> b.getTxs().stream())
.filter(tx -> tx.getBurntFee() > 0);
.filter(tx -> tx.getBurntBsq() > 0);
}
private Stream<Tx> getTradeFeeTxStream() {