Skip to content

Commit

Permalink
Prints btc mempool
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremy-then committed Dec 9, 2023
1 parent e7f4643 commit 5aa9281
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion lib/rsk-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ const printFedsLatestBlocks = async (rskTransactionHelpers) => {
const MAX_ATTEMPTS = 20;
const CHECK_EVERY_MILLISECONDS = 2000;

const waitForPegoutWaitingForSignaturesToBeEmpty = async (rskTransactionHelpers) => {
const waitForPegoutWaitingForSignaturesToBeEmpty = async (rskTransactionHelpers, btcClient) => {
const rskTxHelper = rskTransactionHelpers[rskTransactionHelpers.length - 1];
const method = async () => {
const currentBridgeState = await getBridgeState(rskTxHelper.getClient());
Expand All @@ -163,6 +163,11 @@ const waitForPegoutWaitingForSignaturesToBeEmpty = async (rskTransactionHelpers)
return wasPegoutBroadcasted;
};

const getBitcoinMempool = async (btcClient) => {
const mempool = await btcClient.nodeClient.execute('getrawmempool', []);
return mempool;
};

/**
*
* @param {Array<RskTransactionHelper>} rskTransactionHelpers RskTransactionHelper instances each belonging to one federator node to make calls to the rsk network
Expand Down Expand Up @@ -223,9 +228,12 @@ const triggerRelease = async (rskTransactionHelpers, btcClient, callbacks = {})
// return false; // Returning false to make the retryWithCheck loop continue until this check returns true or it reaches the max attempts
// };

console.log('btc mempool before: ', await getBitcoinMempool(btcClient));

const wasPegoutBroadcasted = await waitForPegoutWaitingForSignaturesToBeEmpty(rskTransactionHelpers, btcClient);

console.log('btc mempool after: ', await getBitcoinMempool(btcClient));

await printFedsLatestBlocks(rskTransactionHelpers);

console.debug(`Pegout broadcasted: ${wasPegoutBroadcasted}`);
Expand All @@ -239,6 +247,8 @@ const triggerRelease = async (rskTransactionHelpers, btcClient, callbacks = {})
// and `RSK_TO_BTC_MINIMUM_ACCEPTABLE_CONFIRMATIONS` more to have enough confirmation for the change balance to be reflected back in the bridge (like a pegin)
await btcClient.mine(RSK_TO_BTC_MINIMUM_ACCEPTABLE_CONFIRMATIONS + 1);

console.log('btc mempool after mining: ', await getBitcoinMempool(btcClient));

console.log('triggerRelease currentBridgeStateBeforeUpdateBridge');

await printBridgeStateWithoutUxtos(rskTransactionHelpers);
Expand All @@ -262,6 +272,8 @@ const triggerRelease = async (rskTransactionHelpers, btcClient, callbacks = {})
await rskTxHelper.updateBridge();
await mineAndSync(rskTransactionHelpers); // At this point the bridge should already have the change uxto registered

console.log('btc mempool before: ', await getBitcoinMempool(btcClient));

};

/**
Expand Down

0 comments on commit 5aa9281

Please sign in to comment.