Skip to content

Commit

Permalink
feat(watcher): add BitcoinWrapper to onProposedFederationChange so it…
Browse files Browse the repository at this point in the history
… can register the svp spend tx
  • Loading branch information
apancorb authored and marcos-iov committed Jan 15, 2025
1 parent 22c781a commit 7c64b8d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/main/java/co/rsk/federate/FedNodeRunner.java
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,8 @@ private void startFederate() throws Exception {
FederationWatcherListener federationWatcherListener = new FederationWatcherListenerImpl(
btcToRskClientActive,
btcToRskClientRetiring,
btcReleaseClient);
btcReleaseClient,
bitcoinWrapper);

federationWatcher.start(federationProvider, federationWatcherListener);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package co.rsk.federate.watcher;

import co.rsk.federate.BtcToRskClient;
import co.rsk.federate.bitcoin.BitcoinWrapper;
import co.rsk.federate.btcreleaseclient.BtcReleaseClient;
import co.rsk.peg.federation.Federation;
import org.slf4j.Logger;
Expand All @@ -14,14 +15,17 @@ public class FederationWatcherListenerImpl implements FederationWatcherListener
private final BtcToRskClient btcToRskClientActive;
private final BtcToRskClient btcToRskClientRetiring;
private final BtcReleaseClient btcReleaseClient;
private final BitcoinWrapper bitcoinWrapper;

public FederationWatcherListenerImpl(
BtcToRskClient btcToRskClientActive,
BtcToRskClient btcToRskClientRetiring,
BtcReleaseClient btcReleaseClient) {
BtcReleaseClient btcReleaseClient,
BitcoinWrapper bitcoinWrapper) {
this.btcToRskClientActive = btcToRskClientActive;
this.btcToRskClientRetiring = btcToRskClientRetiring;
this.btcReleaseClient = btcReleaseClient;
this.bitcoinWrapper = bitcoinWrapper;
}

@Override
Expand Down Expand Up @@ -51,13 +55,17 @@ public void onProposedFederationChange(Federation newProposedFederation) {
// start {@code BtcReleaseClient} with proposed federation
// so it can sign svp spend tx
btcReleaseClient.start(newProposedFederation);

// add proposed federation to active btc to rsk client so
// it can register svp spend tx in the bridge
bitcoinWrapper.addFederationListener(newProposedFederation, btcToRskClientActive);

logger.info(
"[onProposedFederationChange] Client for proposed federation [{}] started with success",
"[onProposedFederationChange] Clients for proposed federation [{}] started with success",
newProposedFederation.getAddress());
} catch (Exception e) {
logger.error(
"[onProposedFederationChange] Client for proposed federation [{}] failed to start",
"[onProposedFederationChange] Clients for proposed federation [{}] failed to start",
newProposedFederation.getAddress(),
e);
}
Expand Down

0 comments on commit 7c64b8d

Please sign in to comment.