avoid batch mempool resync besides bitcoin as those pools are small + improving tests

This commit is contained in:
pragmaxim
2026-01-25 09:15:04 +01:00
parent cc72eb75c5
commit 734c9223ba
9 changed files with 19 additions and 11 deletions

View File

@@ -52,7 +52,6 @@
"address_format": "cashaddr",
"mempool_workers": 8,
"mempool_sub_workers": 2,
"mempool_resync_batch_size": 100,
"block_addresses_to_keep": 300,
"xpub_magic": 76067358,
"slip44": 145,

View File

@@ -52,7 +52,6 @@
"address_format": "cashaddr",
"mempool_workers": 8,
"mempool_sub_workers": 2,
"mempool_resync_batch_size": 100,
"block_addresses_to_keep": 300,
"xpub_magic": 70617039,
"slip44": 1,

View File

@@ -63,7 +63,6 @@
"parse": true,
"mempool_workers": 8,
"mempool_sub_workers": 2,
"mempool_resync_batch_size": 100,
"block_addresses_to_keep": 300,
"xpub_magic": 49990397,
"slip44": 3,

View File

@@ -65,7 +65,6 @@
"parse": true,
"mempool_workers": 8,
"mempool_sub_workers": 2,
"mempool_resync_batch_size": 100,
"block_addresses_to_keep": 300,
"xpub_magic": 70617039,
"slip44": 1,

View File

@@ -59,7 +59,6 @@
"parse": true,
"mempool_workers": 8,
"mempool_sub_workers": 2,
"mempool_resync_batch_size": 100,
"block_addresses_to_keep": 300,
"xpub_magic": 27108450,
"xpub_magic_segwit_p2sh": 28471030,

View File

@@ -61,7 +61,6 @@
"parse": true,
"mempool_workers": 8,
"mempool_sub_workers": 2,
"mempool_resync_batch_size": 100,
"block_addresses_to_keep": 300,
"xpub_magic": 70617039,
"xpub_magic_segwit_p2sh": 71979618,

View File

@@ -50,7 +50,6 @@
"parse": true,
"mempool_workers": 4,
"mempool_sub_workers": 8,
"mempool_resync_batch_size": 100,
"block_addresses_to_keep": 300,
"xpub_magic": 76067358,
"slip44": 133,

View File

@@ -56,7 +56,6 @@
"parse": true,
"mempool_workers": 4,
"mempool_sub_workers": 8,
"mempool_resync_batch_size": 100,
"block_addresses_to_keep": 300,
"xpub_magic": 70617039,
"slip44": 1,

View File

@@ -271,15 +271,20 @@ func testMempoolSync(t *testing.T, h *TestHandler) {
continue
}
beforeIntersect := len(txs)
txs = intersect(txs, getMempool(t, h))
if len(txs) == 0 {
// no transactions to test
continue
}
const maxMempoolSyncTxs = 200
if len(txs) > maxMempoolSyncTxs {
txs = txs[:maxMempoolSyncTxs]
if beforeIntersect >= 20 {
ratio := float64(len(txs)) / float64(beforeIntersect)
if ratio < 0.2 {
t.Fatalf("mempool intersect too small: after=%d before=%d ratio=%.2f", len(txs), beforeIntersect, ratio)
}
}
const mempoolSyncStride = 5
txs = sampleEveryNth(txs, mempoolSyncStride)
txid2addrs := getTxid2addrs(t, h, txs)
if len(txid2addrs) == 0 {
@@ -578,6 +583,17 @@ func intersect(a, b []string) []string {
return res
}
func sampleEveryNth(txs []string, stride int) []string {
if stride <= 1 || len(txs) <= stride {
return txs
}
sampled := make([]string, 0, (len(txs)+stride-1)/stride)
for idx := 0; idx < len(txs); idx += stride {
sampled = append(sampled, txs[idx])
}
return sampled
}
func containsTx(o []bchain.Outpoint, tx string) bool {
for i := range o {
if o[i].Txid == tx {