Skip to content

Commit

Permalink
prepend vaa since we're receiving them in reverse order
Browse files Browse the repository at this point in the history
  • Loading branch information
barnjamin committed Oct 27, 2023
1 parent a5d8912 commit 1ea7f13
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions watcher/src/watchers/SolanaWatcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,12 @@ export class SolanaWatcher extends Watcher {
.concat(instructions)
.filter((i) => i.programIdIndex === programIdIndex);

const blockKey = makeBlockKey(
res.slot.toString(),
new Date(res.blockTime * 1000).toISOString()
);

const vaaKeys: string[] = [];
for (const instruction of whInstructions) {
// skip if not postMessage instruction
const instructionId = instruction.data;
Expand All @@ -216,20 +222,17 @@ export class SolanaWatcher extends Watcher {
message: { emitterAddress, sequence },
} = await getPostedMessage(this.getConnection(), accountId.toBase58(), COMMITMENT);

const blockKey = makeBlockKey(
res.slot.toString(),
new Date(res.blockTime * 1000).toISOString()
);

const vaaKey = makeVaaKey(
res.transaction.signatures[0],
this.chain,
emitterAddress.toString('hex'),
sequence.toString()
vaaKeys.push(
makeVaaKey(
res.transaction.signatures[0],
this.chain,
emitterAddress.toString('hex'),
sequence.toString()
)
);

vaasByBlock[blockKey] = [...(vaasByBlock[blockKey] || []), vaaKey];
}
if (vaaKeys.length > 0)
vaasByBlock[blockKey] = [...vaaKeys, ...(vaasByBlock[blockKey] || [])];
}

numSignatures = signatures.length;
Expand Down

0 comments on commit 1ea7f13

Please sign in to comment.