mirror of
https://github.com/mempool/mempool.git
synced 2024-11-19 01:41:01 +01:00
clearer uint32 uid overflow check
This commit is contained in:
parent
5d48ae1eec
commit
4a15cd7abe
@ -6,6 +6,8 @@ import config from '../config';
|
|||||||
import { Worker } from 'worker_threads';
|
import { Worker } from 'worker_threads';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
|
|
||||||
|
const MAX_UINT32 = Math.pow(2, 32) - 1;
|
||||||
|
|
||||||
class MempoolBlocks {
|
class MempoolBlocks {
|
||||||
private mempoolBlocks: MempoolBlockWithTransactions[] = [];
|
private mempoolBlocks: MempoolBlockWithTransactions[] = [];
|
||||||
private mempoolBlockDeltas: MempoolBlockDelta[] = [];
|
private mempoolBlockDeltas: MempoolBlockDelta[] = [];
|
||||||
@ -375,7 +377,7 @@ class MempoolBlocks {
|
|||||||
|
|
||||||
public async $rustUpdateBlockTemplates(newMempool: { [txid: string]: MempoolTransactionExtended }, added: MempoolTransactionExtended[], removed: MempoolTransactionExtended[]): Promise<void> {
|
public async $rustUpdateBlockTemplates(newMempool: { [txid: string]: MempoolTransactionExtended }, added: MempoolTransactionExtended[], removed: MempoolTransactionExtended[]): Promise<void> {
|
||||||
// sanity check to avoid approaching uint32 uid overflow
|
// sanity check to avoid approaching uint32 uid overflow
|
||||||
if (this.nextUid > 4_000_000_000) {
|
if (this.nextUid + added.length > MAX_UINT32) {
|
||||||
this.resetRustGbt();
|
this.resetRustGbt();
|
||||||
}
|
}
|
||||||
if (!this.rustInitialized) {
|
if (!this.rustInitialized) {
|
||||||
|
Loading…
Reference in New Issue
Block a user