ton-watcher
Advanced tools
Comparing version 1.1.12 to 1.1.14
@@ -75,4 +75,4 @@ "use strict"; | ||
async fetchTxs(lastTransaction) { | ||
const txsHashes = {}; | ||
const params = Object.create(null); | ||
params.limit = 100; | ||
if (lastTransaction) { | ||
@@ -85,12 +85,19 @@ params.lt = lastTransaction.lt; | ||
} | ||
let all_txs = []; | ||
const all_txs = []; | ||
while (true) { | ||
const batchTxs = []; | ||
const txs = await (0, common_helpers_1.retry)(() => this.client.getAccountTransactions(this.address, params.lt, params.hash), { retries: 5, delay: 5000 }); | ||
for (let i = 0; i < txs.length; i++) { | ||
if (txs[i].tx.hash().toString('hex') === this.last_hash) { | ||
const txHash = txs[i].tx.hash().toString('base64'); | ||
if (txsHashes[txHash]) { | ||
continue; | ||
} | ||
if (txHash === this.last_hash) { | ||
break; | ||
} | ||
txsHashes[txHash] = true; | ||
batchTxs.push(txs[i]); | ||
all_txs.push(txs[i]); | ||
} | ||
if (txs.length < params.limit || (this.last_lt && txs[txs.length - 1].tx.lt <= BigInt(this.last_lt))) { | ||
if (batchTxs.length === 0) { | ||
break; | ||
@@ -97,0 +104,0 @@ } |
{ | ||
"name": "ton-watcher", | ||
"version": "1.1.12", | ||
"version": "1.1.14", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "build/index.js", |
@@ -104,4 +104,4 @@ import { Address, TonClient4, Transaction, WalletContractV5R1 } from "@ton/ton"; | ||
private async fetchTxs(lastTransaction: { lt: string, hash: string } | null): Promise<void> { | ||
const txsHashes = {} as Record<string, boolean>; | ||
const params = Object.create(null); | ||
params.limit = 100; | ||
if (lastTransaction) { | ||
@@ -113,14 +113,24 @@ params.lt = lastTransaction.lt; | ||
} | ||
let all_txs = []; | ||
const all_txs = []; | ||
while(true) { | ||
const batchTxs = []; | ||
const txs = await retry(() => this.client.getAccountTransactions(this.address, params.lt, params.hash), { retries: 5, delay: 5000 }); | ||
for (let i = 0; i < txs.length; i++) { | ||
if (txs[i].tx.hash().toString('hex') === this.last_hash) { | ||
const txHash = txs[i].tx.hash().toString('base64'); | ||
if (txsHashes[txHash]) { | ||
continue; | ||
} | ||
if (txHash === this.last_hash) { | ||
break; | ||
} | ||
txsHashes[txHash] = true; | ||
batchTxs.push(txs[i]); | ||
all_txs.push(txs[i]); | ||
} | ||
if (txs.length < params.limit || (this.last_lt && txs[txs.length -1].tx.lt <= BigInt(this.last_lt))) { | ||
if (batchTxs.length === 0) { | ||
break; | ||
@@ -127,0 +137,0 @@ } |
Sorry, the diff of this file is not supported yet
298547
4968