Skip to content

Commit

Permalink
Reduce polling
Browse files Browse the repository at this point in the history
  • Loading branch information
paullinator committed Jul 3, 2024
1 parent 25e74e8 commit 0d8ec53
Show file tree
Hide file tree
Showing 14 changed files with 46 additions and 37 deletions.
4 changes: 2 additions & 2 deletions src/algorand/AlgorandEngine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ import {

const { Algodv2, Indexer } = algosdk

const ACCOUNT_POLL_MILLISECONDS = 5000
const TRANSACTION_POLL_MILLISECONDS = 3000
const ACCOUNT_POLL_MILLISECONDS = 20000
const TRANSACTION_POLL_MILLISECONDS = 20000

export class AlgorandEngine extends CurrencyEngine<
AlgorandTools,
Expand Down
2 changes: 1 addition & 1 deletion src/binance/BinanceEngine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import {

const ACCOUNT_POLL_MILLISECONDS = 20000
const BLOCKCHAIN_POLL_MILLISECONDS = 20000
const TRANSACTION_POLL_MILLISECONDS = 3000
const TRANSACTION_POLL_MILLISECONDS = 20000
const ADDRESS_QUERY_LOOKBACK_TIME = 1000 * 60 * 60 * 24 // ~ one day
const TIMESTAMP_BEFORE_BNB_LAUNCH = 1555500000000 // 2019-04-17, BNB launched on 2019-04-18
const TRANSACTION_QUERY_TIME_WINDOW = 1000 * 60 * 60 * 24 * 5 // 5 days
Expand Down
2 changes: 1 addition & 1 deletion src/cardano/CardanoEngine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ import {

const ACCOUNT_POLL_MILLISECONDS = 20000
const BLOCKCHAIN_POLL_MILLISECONDS = 20000
const TRANSACTION_POLL_MILLISECONDS = 3000
const TRANSACTION_POLL_MILLISECONDS = 20000

export class CardanoEngine extends CurrencyEngine<
CardanoTools,
Expand Down
4 changes: 2 additions & 2 deletions src/cosmos/CosmosEngine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ import {
safeParse
} from './cosmosUtils'

const ACCOUNT_POLL_MILLISECONDS = 5000
const TRANSACTION_POLL_MILLISECONDS = 3000
const ACCOUNT_POLL_MILLISECONDS = 20000
const TRANSACTION_POLL_MILLISECONDS = 20000
const TWO_WEEKS = 1000 * 60 * 60 * 24 * 14
const TWO_MINUTES = 1000 * 60 * 2
const TXS_PER_PAGE = 50
Expand Down
6 changes: 3 additions & 3 deletions src/eos/EosEngine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ import {
SafeEosWalletInfo
} from './eosTypes'

const ADDRESS_POLL_MILLISECONDS = 10000
const BLOCKCHAIN_POLL_MILLISECONDS = 15000
const TRANSACTION_POLL_MILLISECONDS = 10000
const ADDRESS_POLL_MILLISECONDS = 20000
const BLOCKCHAIN_POLL_MILLISECONDS = 20000
const TRANSACTION_POLL_MILLISECONDS = 20000
const CHECK_TXS_HYPERION = true
const CHECK_TXS_FULL_NODES = true

Expand Down
12 changes: 6 additions & 6 deletions src/filecoin/FilecoinEngine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ import { Filfox, FilfoxMessageDetails } from './Filfox'
import { Filscan, FilscanMessage } from './Filscan'
import { RpcExtra } from './RpcExtra'

const CHECK_BALANCE_INTERVAL = 15000
const CHECK_BLOCKHEIGHT_INTERVAL = 30000
const CHECK_TRANSACTION_INTERVAL = 15000
const ACCOUNT_POLL_MILLISECONDS = 20000
const BLOCKCHAIN_POLL_MILLISECONDS = 30000
const TRANSACTION_POLL_MILLISECONDS = 20000

export class FilecoinEngine extends CurrencyEngine<
FilecoinTools,
Expand Down Expand Up @@ -107,13 +107,13 @@ export class FilecoinEngine extends CurrencyEngine<
}

initSubscriptions(): void {
this.addToLoop('checkBalance', CHECK_BALANCE_INTERVAL).catch(error =>
this.addToLoop('checkBalance', ACCOUNT_POLL_MILLISECONDS).catch(error =>
this.log(error)
)
this.addToLoop('checkBlockHeight', CHECK_BLOCKHEIGHT_INTERVAL).catch(
this.addToLoop('checkBlockHeight', BLOCKCHAIN_POLL_MILLISECONDS).catch(
error => this.log(error)
)
this.addToLoop('checkTransactions', CHECK_TRANSACTION_INTERVAL).catch(
this.addToLoop('checkTransactions', TRANSACTION_POLL_MILLISECONDS).catch(
error => this.log(error)
)
}
Expand Down
8 changes: 4 additions & 4 deletions src/fio/FioEngine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,10 @@ import {
SafeFioWalletInfo
} from './fioTypes'

const ADDRESS_POLL_MILLISECONDS = 10000
const BLOCKCHAIN_POLL_MILLISECONDS = 15000
const TRANSACTION_POLL_MILLISECONDS = 10000
const SYNC_NETWORK_INTERVAL = 10000
const ADDRESS_POLL_MILLISECONDS = 20000
const BLOCKCHAIN_POLL_MILLISECONDS = 20000
const TRANSACTION_POLL_MILLISECONDS = 20000
const SYNC_NETWORK_INTERVAL = 20000

interface PreparedTrx {
signatures: string[]
Expand Down
15 changes: 12 additions & 3 deletions src/hedera/HederaEngine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ import {
SafeHederaWalletInfo
} from './hederaTypes'

const ACCOUNT_POLL_MILLISECONDS = 20000
const BALANCE_POLL_MILLISECONDS = 20000
const TRANSACTION_POLL_MILLISECONDS = 20000

export class HederaEngine extends CurrencyEngine<
HederaTools,
SafeHederaWalletInfo
Expand Down Expand Up @@ -239,9 +243,14 @@ export class HederaEngine extends CurrencyEngine<
this.engineOn = true
this.accountNameChecked = this.otherData.hederaAccount != null

this.addToLoop('getNewTransactions', 1000).catch(() => {})
this.addToLoop('queryBalance', 5000).catch(() => {})
this.addToLoop('checkAccountCreationStatus', 5000).catch(() => {})
this.addToLoop('getNewTransactions', TRANSACTION_POLL_MILLISECONDS).catch(
() => {}
)
this.addToLoop('queryBalance', BALANCE_POLL_MILLISECONDS).catch(() => {})
this.addToLoop(
'checkAccountCreationStatus',
ACCOUNT_POLL_MILLISECONDS
).catch(() => {})

await super.startEngine()
}
Expand Down
4 changes: 2 additions & 2 deletions src/polkadot/PolkadotEngine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ import {
SubscanTx
} from './polkadotTypes'

const ACCOUNT_POLL_MILLISECONDS = 5000
const ACCOUNT_POLL_MILLISECONDS = 20000
const BLOCKCHAIN_POLL_MILLISECONDS = 20000
const TRANSACTION_POLL_MILLISECONDS = 3000
const TRANSACTION_POLL_MILLISECONDS = 20000

const queryTxMutex = makeMutex()

Expand Down
6 changes: 3 additions & 3 deletions src/ripple/RippleEngine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ import { convertCurrencyCodeToHex, makeTokenId } from './rippleUtils'

type AccountTransaction = AccountTxResponse['result']['transactions'][number]

const ADDRESS_POLL_MILLISECONDS = 10000
const BLOCKHEIGHT_POLL_MILLISECONDS = 15000
const TRANSACTION_POLL_MILLISECONDS = 3000
const ADDRESS_POLL_MILLISECONDS = 20000
const BLOCKHEIGHT_POLL_MILLISECONDS = 20000
const TRANSACTION_POLL_MILLISECONDS = 20000
const ADDRESS_QUERY_LOOKBACK_BLOCKS = 30 * 60 // ~ one minute

// How long to wait before a transaction is accepted into a ledge close (block)
Expand Down
4 changes: 2 additions & 2 deletions src/solana/SolanaEngine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ import {
wasSolanaTxOtherParams
} from './solanaTypes'

const ACCOUNT_POLL_MILLISECONDS = 5000
const ACCOUNT_POLL_MILLISECONDS = 20000
const BLOCKCHAIN_POLL_MILLISECONDS = 20000
const TRANSACTION_POLL_MILLISECONDS = 3000
const TRANSACTION_POLL_MILLISECONDS = 20000

export class SolanaEngine extends CurrencyEngine<
SolanaTools,
Expand Down
6 changes: 3 additions & 3 deletions src/stellar/StellarEngine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ import {
} from './stellarTypes'

const TX_QUERY_PAGING_LIMIT = 2
const ADDRESS_POLL_MILLISECONDS = 15000
const BLOCKCHAIN_POLL_MILLISECONDS = 30000
const TRANSACTION_POLL_MILLISECONDS = 5000
const ADDRESS_POLL_MILLISECONDS = 20000
const BLOCKCHAIN_POLL_MILLISECONDS = 20000
const TRANSACTION_POLL_MILLISECONDS = 20000

const BASE_FEE = 100 // Stroops

Expand Down
6 changes: 3 additions & 3 deletions src/tezos/TezosEngine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ import {
XtzGetTransaction
} from './tezosTypes'

const ADDRESS_POLL_MILLISECONDS = 15000
const BLOCKCHAIN_POLL_MILLISECONDS = 30000
const TRANSACTION_POLL_MILLISECONDS = 5000
const ADDRESS_POLL_MILLISECONDS = 20000
const BLOCKCHAIN_POLL_MILLISECONDS = 20000
const TRANSACTION_POLL_MILLISECONDS = 20000

const makeSpendMutex = makeMutex()

Expand Down
4 changes: 2 additions & 2 deletions src/tron/TronEngine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ const queryTxMutex = makeMutex()

const ACCOUNT_POLL_MILLISECONDS = 20000
const BLOCKCHAIN_POLL_MILLISECONDS = 20000
const TRANSACTION_POLL_MILLISECONDS = 3000
const NETWORKFEES_POLL_MILLISECONDS = 60 * 10 * 1000
const TRANSACTION_POLL_MILLISECONDS = 20000
const NETWORKFEES_POLL_MILLISECONDS = 60 * 60 * 1000 // 1 hour

type TronFunction =
| 'trx_blockNumber'
Expand Down

0 comments on commit 0d8ec53

Please sign in to comment.