Skip to content

Commit

Permalink
Refactor and simplify registerSvpSpendTx method
Browse files Browse the repository at this point in the history
  • Loading branch information
marcos-iov committed Jan 15, 2025
1 parent 7153380 commit a24920f
Showing 1 changed file with 10 additions and 13 deletions.
23 changes: 10 additions & 13 deletions rskj-core/src/main/java/co/rsk/peg/BridgeSupport.java
Original file line number Diff line number Diff line change
Expand Up @@ -451,30 +451,27 @@ private void registerSvpFundTx(BtcTransaction btcTx) throws IOException {
}

private void registerSvpSpendTx(BtcTransaction btcTx) throws IOException {
logger.info("[registerSvpSpendTx] This is an svp spend tx {}", btcTx.getHash());
logger.info(
"[registerSvpSpendTx] This is an svp spend tx {}. SVP was successful, going to commit the proposed federation",
btcTx.getHash()
);

registerNewUtxos(btcTx);

if (isSvpOngoing()) {
processSvpSuccess();
}
provider.setSvpSpendTxHashUnsigned(null);
federationSupport.commitProposedFederation();
}

private void updateSvpFundTransactionValues(BtcTransaction transaction) {
logger.info(
"[updateSvpFundTransactionValues] Transaction {} is the svp fund transaction. Going to update its values", transaction);
"[updateSvpFundTransactionValues] Transaction {} (wtxid:{}) is the svp fund transaction. Going to update its values",
transaction.getHash(),
transaction.getHash(true)
);

provider.setSvpFundTxSigned(transaction);
provider.setSvpFundTxHashUnsigned(null);
}

private void processSvpSuccess() {
logger.info("[processSvpSucess] SVP was successful. Going to commit the proposed federation");

provider.setSvpSpendTxHashUnsigned(null);
federationSupport.commitProposedFederation();
}

@VisibleForTesting
BtcBlockStoreWithCache getBtcBlockStore() {
return btcBlockStore;
Expand Down

0 comments on commit a24920f

Please sign in to comment.