Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions packages/txm/lib/BlockMonitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ export class BlockMonitor {

this.txmgr.viemClient.watchBlocks({
onBlock: this.onNewBlock.bind(this),
...(this.txmgr.transportProtocol === "http"
? {
pollingInterval: this.txmgr.pollingInterval,
}
: {}),
})
}

Expand Down
14 changes: 13 additions & 1 deletion packages/txm/lib/TransactionManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ export type TransactionManagerConfig = {
* Defaults to false.
*/
allowDebug?: boolean

/**
* Specifies the polling interval in milliseconds.
* Defaults to 1/2 of the block time.
Copy link
Contributor

@aodhgan aodhgan Feb 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the PR description says the default 1/8th of the block time, but we will find an ideal default thru testing i think

*/
pollingInterval?: number
}
/** The private key of the account used for signing transactions. */
privateKey: Hex
Expand Down Expand Up @@ -159,6 +165,8 @@ export class TransactionManager {
public readonly rpcAllowDebug: boolean
public readonly blockTime: bigint
public readonly finalizedTransactionPurgeTime: number
public readonly pollingInterval: number
public readonly transportProtocol: "http" | "websocket"

public started: boolean

Expand All @@ -171,12 +179,14 @@ export class TransactionManager {
throw protocol.error
}

this.transportProtocol = protocol.value

const retries = _config.rpc.retries || 2
const retryDelay = _config.rpc.retryDelay || 50
const timeout = _config.rpc.timeout || 500

let transport: ViemTransport
if (protocol.value === "http") {
if (this.transportProtocol === "http") {
transport = viemHttpTransport(_config.rpc.url, {
timeout,
retryCount: retries,
Expand Down Expand Up @@ -250,6 +260,8 @@ export class TransactionManager {
this.blockTime = _config.blockTime || 2n
this.finalizedTransactionPurgeTime = _config.finalizedTransactionPurgeTime || 2 * 60 * 1000

this.pollingInterval = _config.rpc.pollingInterval || (Number(this.blockTime) * 1000) / 2

this.started = false
}

Expand Down