Use msgpackr

This commit is contained in:
Jim Hamill
2025-02-02 07:08:30 +00:00
parent a604363bec
commit e64d964e6e
5 changed files with 152 additions and 30 deletions
@@ -224,23 +224,13 @@ export class BlockchainElectrum extends BaseBlockchain {
const cacheKey = `transactions.${txHash}`;
// Attempt to get the transaction hex from the cache or fetch it if not available.
const transactionHex = await this.store.getOrSet(cacheKey, async () => {
return await fetchTransaction(this.electrumClient, txHash);
const transactionRaw = await this.store.getOrSet(cacheKey, async () => {
const txHex = await fetchTransaction(this.electrumClient, txHash);
return Transaction.fromHex(txHex).toRaw();
});
// Decode the hex into our transaction primitive.
const transaction = Transaction.fromHex(transactionHex);
// Attempt to get the transaction hex from the cache or fetch it if not available.
// NOTE: We store JSON as opposed to hex because it is MUCH faster to decode.
/*
const transaction = new Transaction(
await this.store.getOrSet(cacheKey, async () => {
const tx = await fetchTransaction(this.electrumClient, txHash);
return Transaction.fromHex(tx).transaction;
}),
);
*/
const transaction = Transaction.fromRaw(transactionRaw);
// Return the transaction hex.
return transaction;