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
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ export interface PreparedDecodedScript {
}

export interface PreparedInput {
tx_id: string;
value: number;
token_data: number;
script: string;
Expand Down
11 changes: 8 additions & 3 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,12 @@ export const recursivelyDownloadTx = async (blockId: string, txIds: string[] = [
}

const txId: string = txIds.pop() as string;
const network = process.env.NETWORK || 'mainnet';
const network: string = process.env.NETWORK || 'mainnet';

if (network in IGNORE_TXS) {
if (IGNORE_TXS[network].includes(txId)) {
const networkTxs: string[] = IGNORE_TXS[network];

if (networkTxs.includes(txId)) {
// Skip
return recursivelyDownloadTx(blockId, txIds, data);
}
Expand Down Expand Up @@ -120,6 +122,7 @@ export const prepareTx = (tx: FullTx | FullBlock): PreparedTx => {
height: tx.height,
inputs: tx.inputs.map((input) => {
const baseInput: PreparedInput = {
tx_id: input.txId,
value: input.value,
token_data: input.tokenData,
script: input.script,
Expand Down Expand Up @@ -303,7 +306,9 @@ export async function* syncToLatestBlock(): AsyncGenerator<StatusEvent> {
];

// Download block transactions
const txs: FullTx[] = await recursivelyDownloadTx(block.txId, blockTxs);
let txs: FullTx[] = await recursivelyDownloadTx(block.txId, blockTxs);

txs = txs.sort((x, y) => x.timestamp - y.timestamp);

// We will send the block only after all transactions were downloaded
// to be sure that all downloads were succesfull since there is no
Expand Down
1 change: 0 additions & 1 deletion test/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,6 @@ export const BLOCK_BY_HEIGHT: FullBlock = {
timelock: null
},
token: '00',
spentBy: null
}
],
parents: [
Expand Down