Skip to content

Commit

Permalink
fix(apps/legacy-api): race condition fix in findPoolSwapDfTx when vou…
Browse files Browse the repository at this point in the history
…ts[0] cannot be found (#1285)
  • Loading branch information
fuxingloh authored Mar 29, 2022
1 parent b4bbce3 commit 18c2389
Showing 1 changed file with 36 additions and 8 deletions.
44 changes: 36 additions & 8 deletions apps/legacy-api/src/controllers/PoolPairController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,14 +206,38 @@ export class PoolPairController {
provider_URL: 'https://defichain.com',
tvl: stats.tvl.total,
links: [
{ title: 'Twitter', link: 'https://twitter.com/defichain' },
{ title: 'YouTube', link: 'https://www.youtube.com/DeFiChain' },
{ title: 'Reddit', link: 'https://reddit.com/r/defiblockchain' },
{ title: 'Telegram', link: 'https://t.me/defiblockchain' },
{ title: 'LinkedIn', link: 'https://www.linkedin.com/company/defichain' },
{ title: 'Facebook', link: 'https://www.facebook.com/defichain.official' },
{ title: 'GitHub', link: 'https://github.com/DeFiCh' },
{ title: 'Discord', link: 'https://discord.com/invite/py55egyaGy' }
{
title: 'Twitter',
link: 'https://twitter.com/defichain'
},
{
title: 'YouTube',
link: 'https://www.youtube.com/DeFiChain'
},
{
title: 'Reddit',
link: 'https://reddit.com/r/defiblockchain'
},
{
title: 'Telegram',
link: 'https://t.me/defiblockchain'
},
{
title: 'LinkedIn',
link: 'https://www.linkedin.com/company/defichain'
},
{
title: 'Facebook',
link: 'https://www.facebook.com/defichain.official'
},
{
title: 'GitHub',
link: 'https://github.com/DeFiCh'
},
{
title: 'Discord',
link: 'https://discord.com/invite/py55egyaGy'
}
]
}
}
Expand Down Expand Up @@ -439,6 +463,10 @@ interface LegacySubgraphSwapFromTo {
}

function findPoolSwapDfTx (vouts: TransactionVout[]): PoolSwap | undefined {
if (vouts.length === 0) {
return undefined // reject because not yet indexed, cannot be found
}

const hex = vouts[0].script.hex
const buffer = SmartBuffer.fromBuffer(Buffer.from(hex, 'hex'))
const stack = toOPCodes(buffer)
Expand Down

0 comments on commit 18c2389

Please sign in to comment.