Skip to content

Commit

Permalink
backport of uncompressTx / uncompressDeltaChange
Browse files Browse the repository at this point in the history
(cherry picked from commit 7a63a9c)
  • Loading branch information
hans-crypto committed Feb 28, 2024
1 parent 0d82fcb commit 223d771
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 3 deletions.
9 changes: 7 additions & 2 deletions frontend/src/app/services/websocket.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { take } from 'rxjs/operators';
import { TransferState, makeStateKey } from '@angular/platform-browser';
import { CacheService } from './cache.service';
import { environment } from 'src/environments/environment';
import { uncompressDeltaChange, uncompressTx } from '../shared/common.utils';

const OFFLINE_RETRY_AFTER_MS = 2000;
const OFFLINE_PING_CHECK_AFTER_MS = 30000;
Expand Down Expand Up @@ -379,9 +380,13 @@ export class WebsocketService {
if (response['projected-block-transactions']) {
if (response['projected-block-transactions'].index == this.trackingMempoolBlock) {
if (response['projected-block-transactions'].blockTransactions) {
this.stateService.mempoolBlockTransactions$.next(response['projected-block-transactions'].blockTransactions);
// HACK: backport from latest, remove after big merge
// this.stateService.mempoolBlockTransactions$.next(response['projected-block-transactions'].blockTransactions);
this.stateService.mempoolBlockTransactions$.next(response['projected-block-transactions'].blockTransactions.map(uncompressTx));
} else if (response['projected-block-transactions'].delta) {
this.stateService.mempoolBlockDelta$.next(response['projected-block-transactions'].delta);
// HACK: backport from latest, remove after big merge
// this.stateService.mempoolBlockDelta$.next(response['projected-block-transactions'].delta);
this.stateService.mempoolBlockDelta$.next(uncompressDeltaChange(response['projected-block-transactions'].delta));
}
}
}
Expand Down
41 changes: 40 additions & 1 deletion frontend/src/app/shared/common.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,4 +152,43 @@ export function seoDescriptionNetwork(network: string): string {
return ' ' + network.charAt(0).toUpperCase() + network.slice(1);
}
return '';
}
}

// backport from latest, replace this with the real functions after big merge
export function uncompressTx(tx: any): any {

// old backend - nothing to do
if (!Array.isArray(tx)) {
return tx;
}

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: any): any {

// old backend - nothing to do
if (delta.added[0] && !Array.isArray(delta.added[0]) ||
delta.changed[0] && !Array.isArray(delta.changed[0])) {
return delta;
}

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],
}))
};
}

0 comments on commit 223d771

Please sign in to comment.