Reduce the network size of mempool block websocket updates

This commit is contained in:
Mononaut
2024-02-08 22:40:22 +00:00
parent efdc83d4bb
commit 1121136a5e
8 changed files with 93 additions and 16 deletions

View File

@@ -1,3 +1,5 @@
import { MempoolBlockDelta, MempoolBlockDeltaCompressed, MempoolDeltaChange, TransactionCompressed, TransactionStripped } from "../interfaces/websocket.interface";
export function isMobile(): boolean {
return (window.innerWidth <= 767.98);
}
@@ -152,4 +154,29 @@ export function seoDescriptionNetwork(network: string): string {
return ' ' + network.charAt(0).toUpperCase() + network.slice(1);
}
return '';
}
export function uncompressTx(tx: TransactionCompressed): TransactionStripped {
return {
txid: tx[0],
fee: tx[1],
vsize: tx[2],
value: tx[3],
rate: tx[4],
flags: tx[5],
acc: !!tx[6],
};
}
export function uncompressDeltaChange(delta: MempoolBlockDeltaCompressed): MempoolBlockDelta {
return {
added: delta.added.map(uncompressTx),
removed: delta.removed,
changed: delta.changed.map(tx => ({
txid: tx[0],
rate: tx[1],
flags: tx[2],
acc: !!tx[3],
}))
};
}