mirror of
https://github.com/trezor/blockbook.git
synced 2026-02-19 16:31:19 +01:00
avoid batch mempool resync besides bitcoin as those pools are small + improving tests
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user