diff --git a/configs/coins/bcash.json b/configs/coins/bcash.json index d02d9739..40772e9b 100644 --- a/configs/coins/bcash.json +++ b/configs/coins/bcash.json @@ -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, diff --git a/configs/coins/bcash_testnet.json b/configs/coins/bcash_testnet.json index 899c589d..ed4a690f 100644 --- a/configs/coins/bcash_testnet.json +++ b/configs/coins/bcash_testnet.json @@ -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, diff --git a/configs/coins/dogecoin.json b/configs/coins/dogecoin.json index 5fa95b23..38f137e2 100644 --- a/configs/coins/dogecoin.json +++ b/configs/coins/dogecoin.json @@ -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, diff --git a/configs/coins/dogecoin_testnet.json b/configs/coins/dogecoin_testnet.json index 02e43076..1d44c74b 100644 --- a/configs/coins/dogecoin_testnet.json +++ b/configs/coins/dogecoin_testnet.json @@ -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, diff --git a/configs/coins/litecoin.json b/configs/coins/litecoin.json index 175038a9..4d1e43a9 100644 --- a/configs/coins/litecoin.json +++ b/configs/coins/litecoin.json @@ -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, diff --git a/configs/coins/litecoin_testnet.json b/configs/coins/litecoin_testnet.json index 673158fc..8a158533 100644 --- a/configs/coins/litecoin_testnet.json +++ b/configs/coins/litecoin_testnet.json @@ -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, diff --git a/configs/coins/zcash.json b/configs/coins/zcash.json index 1d2e58b3..9cab054f 100644 --- a/configs/coins/zcash.json +++ b/configs/coins/zcash.json @@ -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, diff --git a/configs/coins/zcash_testnet.json b/configs/coins/zcash_testnet.json index c96933cd..60ede9ef 100644 --- a/configs/coins/zcash_testnet.json +++ b/configs/coins/zcash_testnet.json @@ -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, diff --git a/tests/rpc/rpc.go b/tests/rpc/rpc.go index 0e5c9f3f..71cb4dd2 100644 --- a/tests/rpc/rpc.go +++ b/tests/rpc/rpc.go @@ -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 {