Skip to content

Commit

Permalink
Bugfixing
Browse files Browse the repository at this point in the history
  • Loading branch information
EvgenKor committed Sep 4, 2024
1 parent de61017 commit bf3307e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion zp-relayer/pool/RelayPool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ export class RelayPool extends BasePool<Network> {
const indexerCommitments = (await this.getIndexerTxs(fromIndex, limit)).map(tx => tx.slice(65, 129));

// find cached commitments in the indexer's response
for (const [commit, memo] of localEntries) {
for (const [commit, {memo, index}] of localEntries) {
if (indexerCommitments.includes(commit)) {
logger.info('Deleting cached entry', { commit })
await this.txStore.remove(commit)
Expand Down
4 changes: 2 additions & 2 deletions zp-relayer/services/relayer/endpoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ async function getTransactionsV2(req: Request, res: Response, { pool }: PoolInje

const indexerCommitments = indexerTxs.map(tx => tx.slice(65, 129));
const optimisticTxs: string[] = []
for (const [commit, memo] of localEntries) {
for (const [commit, {memo, index}] of localEntries) {
if (indexerCommitments.includes(commit)) {
// !!! we shouldn't modify local cache from here. Just filter entries to return correct response
//logger.info('Deleting index from optimistic state', { index })
Expand Down Expand Up @@ -187,7 +187,7 @@ async function relayerInfo(req: Request, res: Response, { pool }: PoolInjection)
const pendingCnt = await txStore.getAll()
.then(keys => {
return Object.entries(keys)
.map(([i]) => parseInt(i) as number)
.map(([commit, {memo, index}]) => index)
.filter(i => indexerMaxIdx <= i)
})
.then(a => a.length);
Expand Down
8 changes: 4 additions & 4 deletions zp-relayer/state/TxStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,17 @@ export class TxStore {
} : null;
}

async getAll() {
return await this.redis.hgetall(this.name).then(keys => {
return Object.entries(keys)
async getAll(): Promise<Record<string, {memo: string, index: number}>> {
return this.redis.hgetall(this.name).then(keys => Object.fromEntries(
Object.entries(keys)
.map(([commit, data]) =>
[commit,
{
memo: data.slice(INDEX_BYTES * 2),
index: hexToNumber(data.slice(0, INDEX_BYTES * 2)),
}] as [string, {memo: string, index: number}]
)
}
));
}

async removeAll() {
Expand Down

0 comments on commit bf3307e

Please sign in to comment.