Skip to content

Commit

Permalink
adding debug messages for rpc connnection
Browse files Browse the repository at this point in the history
  • Loading branch information
coinchimp committed Aug 5, 2024
1 parent 507d24c commit eaa97de
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
16 changes: 13 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,20 @@ const startRpcConnection = async () => {
const resolverOptions = config.node ? { urls: config.node } : undefined;
const resolver = new Resolver(resolverOptions);

if (DEBUG) monitoring.debug(`Main: Resolver(${resolverOptions})`);

rpc = new RpcClient({
resolver: resolver,
encoding: Encoding.Borsh,
networkId: config.network,
});

if (DEBUG) monitoring.debug(`Main: Starting RPC connection`);
await rpc.connect();
try {
await rpc.connect();
} catch (rpcError) {
throw Error('RPC connection error');
}
const serverInfo = await rpc.getServerInfo();
if (!serverInfo.isSynced || !serverInfo.hasUtxoIndex) {
throw Error('Provided node is either not synchronized or lacks the UTXO index.');
Expand Down Expand Up @@ -132,8 +138,12 @@ cron.schedule(`*/10 * * * *`, async () => {
setInterval(() => {
const now = new Date();
const minutes = now.getMinutes();
const remainingMinutes = paymentInterval * 60 - (minutes % (paymentInterval * 60));
const remainingTime = remainingMinutes === paymentInterval * 60 ? 0 : remainingMinutes;
const hours = now.getHours();

const nextTransferHours = paymentInterval - (hours % paymentInterval);
const remainingMinutes = nextTransferHours * 60 - minutes;
const remainingTime = remainingMinutes === nextTransferHours * 60 ? 0 : remainingMinutes;

if (DEBUG) monitoring.debug(`Main: ${remainingTime} minutes until the next balance transfer`);
}, 10 * 60 * 1000); // 10 minutes in milliseconds

Expand Down
2 changes: 0 additions & 2 deletions src/trxs/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// @ts-ignore
//globalThis.WebSocket = require('websocket').w3cwebsocket; // W3C WebSocket module shim
import Database from '../database';
import { sompiToKaspaStringWithSuffix, type IPaymentOutput, createTransactions, PrivateKey, UtxoProcessor, UtxoContext, type RpcClient } from "../../wasm/kaspa";
import Monitoring from '../monitoring';
Expand Down

0 comments on commit eaa97de

Please sign in to comment.