Skip to content

Commit

Permalink
back to kaspa and testing new changes rpc connection
Browse files Browse the repository at this point in the history
  • Loading branch information
coinchimp committed Aug 9, 2024
1 parent 679c0fd commit 1af6b76
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,12 @@ const rpc = new RpcClient({
let transactionManager: trxManager | null = null;
let rpcConnected = false;

// Transaction Manager setup
const setupTransactionManager = () => {
if (DEBUG) monitoring.debug(`Main: Starting transaction manager`);
transactionManager = new trxManager(config.network, treasuryPrivateKey, databaseUrl, rpc!);
};

const startRpcConnection = async () => {
if (DEBUG) monitoring.debug(`Main: Starting RPC connection`);
try {
Expand All @@ -87,16 +93,18 @@ const startRpcConnection = async () => {
throw Error('Provided node is either not synchronized or lacks the UTXO index.');
}
rpcConnected = true;
if (DEBUG) monitoring.debug(`Main: RPC connection established`);
setupTransactionManager();

};

if (!rpcConnected) {
await startRpcConnection();
if (DEBUG) monitoring.debug('Main: RPC connection started');
if (DEBUG) monitoring.debug(`Main: RPC connection established`);
setupTransactionManager();
}



// const stopRpcConnection = async () => {
// if (rpc) {
// await transactionManager!.stopProcessor();
Expand All @@ -106,11 +114,7 @@ if (!rpcConnected) {
// }
// };

// Transaction Manager setup
const setupTransactionManager = () => {
if (DEBUG) monitoring.debug(`Main: Starting transaction manager`);
transactionManager = new trxManager(config.network, treasuryPrivateKey, databaseUrl, rpc!);
};


// Unified cron schedule
cron.schedule(`*/10 * * * *`, async () => {
Expand Down

0 comments on commit 1af6b76

Please sign in to comment.