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
4 changes: 2 additions & 2 deletions third_party/pyth/price-service/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion third_party/pyth/price-service/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pythnetwork/pyth-price-service",
"version": "2.2.1",
"version": "2.2.2",
"description": "Pyth Price Service",
"main": "index.js",
"scripts": {
Expand Down
17 changes: 8 additions & 9 deletions third_party/pyth/price-service/src/listen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ import {

import { importCoreWasm } from "@certusone/wormhole-sdk/lib/cjs/solana/wasm";

import { createHash } from "crypto";

import {
getBatchSummary,
parseBatchPriceAttestation,
Expand Down Expand Up @@ -52,7 +50,7 @@ type ListenerConfig = {
readiness: ListenerReadinessConfig;
};

type VaaHash = string;
type VaaKey = string;

export class Listener implements PriceStore {
// Mapping of Price Feed Id to Vaa
Expand All @@ -63,7 +61,7 @@ export class Listener implements PriceStore {
private spyConnectionTime: TimestampInSec | undefined;
private readinessConfig: ListenerReadinessConfig;
private updateCallbacks: ((priceInfo: PriceInfo) => any)[];
private observedVaas: LRUCache<VaaHash, boolean>;
private observedVaas: LRUCache<VaaKey, boolean>;

constructor(config: ListenerConfig, promClient?: PromClient) {
this.promClient = promClient;
Expand Down Expand Up @@ -162,15 +160,16 @@ export class Listener implements PriceStore {

const parsedVaa = parse_vaa(vaa);

const vaaHash: VaaHash = createHash("md5")
.update(Buffer.from(parsedVaa.payload))
.digest("base64");
const vaaEmitterAddressHex = Buffer.from(
parsedVaa.emitter_address
).toString("hex");
const vaaKey: VaaKey = `${parsedVaa.emitter_chain}#${vaaEmitterAddressHex}#${parsedVaa.sequence}`;

if (this.observedVaas.has(vaaHash)) {
if (this.observedVaas.has(vaaKey)) {
return;
}

this.observedVaas.set(vaaHash, true);
this.observedVaas.set(vaaKey, true);
this.promClient?.incReceivedVaa();

let batchAttestation;
Expand Down