Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow spending of unconfirmed BSQ change outputs #2482

Merged
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ public void onWalletChanged(Wallet wallet) {
///////////////////////////////////////////////////////////////////////////////////////////

@Override
public void onParseTxsCompleteAfterBatchProcessing(Block block) {
public void onParseBlockCompleteAfterBatchProcessing(Block block) {
if (isWalletReady()) {
wallet.getTransactions(false).forEach(unconfirmedBsqChangeOutputListService::onTransactionConfidenceChanged);
updateBsqWalletTransactions();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ private List<Tx> getFeeTxs(StatefulAsset statefulAsset) {
///////////////////////////////////////////////////////////////////////////////////////////

@Override
public void onParseTxsCompleteAfterBatchProcessing(Block block) {
public void onParseBlockCompleteAfterBatchProcessing(Block block) {
int chainHeight = daoStateService.getChainHeight();
bsqFeePerDay = daoStateService.getParamValueAsCoin(Param.ASSET_LISTING_FEE_PER_DAY, chainHeight).value;
minVolumeInBtc = daoStateService.getParamValueAsCoin(Param.ASSET_MIN_VOLUME, chainHeight).value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public void onNewBlockHeight(int blockHeight) {
}

@Override
public void onParseTxsCompleteAfterBatchProcessing(Block block) {
public void onParseBlockCompleteAfterBatchProcessing(Block block) {
onListChanged(ballotListService.getValidatedBallotList());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ public BondRepository(DaoStateService daoStateService, BsqWalletService bsqWalle
public void addListeners() {
daoStateService.addDaoStateListener(new DaoStateListener() {
@Override
public void onParseTxsCompleteAfterBatchProcessing(Block block) {
public void onParseBlockCompleteAfterBatchProcessing(Block block) {
update();
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public MyBondedReputationRepository(DaoStateService daoStateService,
public void addListeners() {
daoStateService.addDaoStateListener(new DaoStateListener() {
@Override
public void onParseTxsCompleteAfterBatchProcessing(Block block) {
public void onParseBlockCompleteAfterBatchProcessing(Block block) {
update();
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public void updateList() {
///////////////////////////////////////////////////////////////////////////////////////////

@Override
public void onParseTxsCompleteAfterBatchProcessing(Block block) {
public void onParseBlockCompleteAfterBatchProcessing(Block block) {
updateList();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public ProposalListPresentation(ProposalService proposalService,
///////////////////////////////////////////////////////////////////////////////////////////

@Override
public void onParseTxsCompleteAfterBatchProcessing(Block block) {
public void onParseBlockCompleteAfterBatchProcessing(Block block) {
updateLists();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ public void onAdded(PersistableNetworkPayload payload) {
///////////////////////////////////////////////////////////////////////////////////////////

@Override
public void onParseTxsCompleteAfterBatchProcessing(Block block) {
public void onParseBlockCompleteAfterBatchProcessing(Block block) {
int heightForRepublishing = periodService.getFirstBlockOfPhase(daoStateService.getChainHeight(), DaoPhase.Phase.BREAK1);
if (block.getHeight() == heightForRepublishing) {
// We only republish if we are completed with parsing old blocks, otherwise we would republish old
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ public void start() {
///////////////////////////////////////////////////////////////////////////////////////////

@Override
public void onParseTxsComplete(Block block) {
public void onParseBlockComplete(Block block) {
maybeCalculateVoteResult(block.getHeight());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ public void addVoteRevealTxPublishedListener(VoteRevealTxPublishedListener voteR
///////////////////////////////////////////////////////////////////////////////////////////

@Override
public void onParseTxsCompleteAfterBatchProcessing(Block block) {
public void onParseBlockCompleteAfterBatchProcessing(Block block) {
maybeRevealVotes(block.getHeight());
}

Expand Down
4 changes: 2 additions & 2 deletions core/src/main/java/bisq/core/dao/state/DaoStateListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ default void onParseBlockChainComplete() {
}

// Called before onParseTxsCompleteAfterBatchProcessing in case batch processing is complete
default void onParseTxsComplete(Block block) {
default void onParseBlockComplete(Block block) {
}

default void onParseTxsCompleteAfterBatchProcessing(Block block) {
default void onParseBlockCompleteAfterBatchProcessing(Block block) {
}
}
6 changes: 3 additions & 3 deletions core/src/main/java/bisq/core/dao/state/DaoStateService.java
Original file line number Diff line number Diff line change
Expand Up @@ -216,13 +216,13 @@ public void onParseBlockComplete(Block block) {
// so we need to make sure that vote result calculation is completed before (e.g. for comp. request to
// update balance).
// TODO the dependency on ordering is nto good here.... Listeners should not depend on order of execution.
daoStateListeners.forEach(l -> l.onParseTxsComplete(block));
daoStateListeners.forEach(l -> l.onParseBlockComplete(block));

// We use 2 different handlers as we don't want to update domain listeners during batch processing of all
// blocks as that cause performance issues. In earlier versions when we updated at each block it took
// 50 sec. for 4000 blocks, after that change it was about 4 sec.
if (parseBlockChainComplete)
daoStateListeners.forEach(l -> l.onParseTxsCompleteAfterBatchProcessing(block));
daoStateListeners.forEach(l -> l.onParseBlockCompleteAfterBatchProcessing(block));
}

// Called after parsing of all pending blocks is completed
Expand All @@ -231,7 +231,7 @@ public void onParseBlockChainComplete() {
parseBlockChainComplete = true;

getLastBlock().ifPresent(block -> {
daoStateListeners.forEach(l -> l.onParseTxsCompleteAfterBatchProcessing(block));
daoStateListeners.forEach(l -> l.onParseBlockCompleteAfterBatchProcessing(block));
});

daoStateListeners.forEach(DaoStateListener::onParseBlockChainComplete);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public DaoStateSnapshotService(DaoStateService daoStateService,
// We listen to each ParseTxsComplete event even if the batch processing of all blocks at startup is not completed
// as we need to write snapshots during that batch processing.
@Override
public void onParseTxsComplete(Block block) {
public void onParseBlockComplete(Block block) {
int chainHeight = block.getHeight();

// Either we don't have a snapshot candidate yet, or if we have one the height at that snapshot candidate must be
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public void deactivate() {
///////////////////////////////////////////////////////////////////////////////////////////

@Override
public void onParseTxsCompleteAfterBatchProcessing(Block block) {
public void onParseBlockCompleteAfterBatchProcessing(Block block) {
applyData(block.getHeight());

phaseBarsItems.forEach(item -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ protected void deactivate() {
///////////////////////////////////////////////////////////////////////////////////////////

@Override
public void onParseTxsCompleteAfterBatchProcessing(Block block) {
public void onParseBlockCompleteAfterBatchProcessing(Block block) {
applyData(block.getHeight());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ protected void activate() {
Optional<Block> blockAtChainHeight = daoFacade.getBlockAtChainHeight();

if (blockAtChainHeight.isPresent())
onParseTxsCompleteAfterBatchProcessing(blockAtChainHeight.get());
onParseBlockCompleteAfterBatchProcessing(blockAtChainHeight.get());
}

@Override
Expand Down Expand Up @@ -244,7 +244,7 @@ private void removeBindings() {
///////////////////////////////////////////////////////////////////////////////////////////

@Override
public void onParseTxsCompleteAfterBatchProcessing(Block block) {
public void onParseBlockCompleteAfterBatchProcessing(Block block) {
isProposalPhase.set(daoFacade.isInPhaseButNotLastBlock(DaoPhase.Phase.PROPOSAL));
if (isProposalPhase.get()) {
proposalGroupTitle.set(Res.get("dao.proposal.create.selectProposalType"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ public void onUpdateBalances(Coin availableConfirmedBalance,
///////////////////////////////////////////////////////////////////////////////////////////

@Override
public void onParseTxsCompleteAfterBatchProcessing(Block block) {
public void onParseBlockCompleteAfterBatchProcessing(Block block) {
updateViews();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ protected void deactivate() {
///////////////////////////////////////////////////////////////////////////////////////////

@Override
public void onParseTxsCompleteAfterBatchProcessing(Block block) {
public void onParseBlockCompleteAfterBatchProcessing(Block block) {
fillCycleList();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public void deactivate() {
///////////////////////////////////////////////////////////////////////////////////////////

@Override
public void onParseTxsCompleteAfterBatchProcessing(Block block) {
public void onParseBlockCompleteAfterBatchProcessing(Block block) {
bsqWalletService.addBsqBalanceListener(this);
triggerUpdate();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ protected void deactivate() {
///////////////////////////////////////////////////////////////////////////////////////////

@Override
public void onParseTxsCompleteAfterBatchProcessing(Block block) {
public void onParseBlockCompleteAfterBatchProcessing(Block block) {
updateWithBsqBlockChainData();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ public void onUpdateBalances(Coin availableConfirmedBalance,
///////////////////////////////////////////////////////////////////////////////////////////

@Override
public void onParseTxsCompleteAfterBatchProcessing(Block block) {
public void onParseBlockCompleteAfterBatchProcessing(Block block) {
onUpdateAnyChainHeight();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ private void onUpdateAnyChainHeight() {
///////////////////////////////////////////////////////////////////////////////////////////

@Override
public void onParseTxsCompleteAfterBatchProcessing(Block block) {
public void onParseBlockCompleteAfterBatchProcessing(Block block) {
onUpdateAnyChainHeight();
}

Expand Down