mirror of
https://github.com/mempool/mempool.git
synced 2025-01-18 21:32:55 +01:00
Add multi-address-tracking limit config
This commit is contained in:
parent
8f7895cb2e
commit
aa0948a154
@ -33,7 +33,8 @@
|
|||||||
"DISK_CACHE_BLOCK_INTERVAL": 6,
|
"DISK_CACHE_BLOCK_INTERVAL": 6,
|
||||||
"MAX_PUSH_TX_SIZE_WEIGHT": 4000000,
|
"MAX_PUSH_TX_SIZE_WEIGHT": 4000000,
|
||||||
"ALLOW_UNREACHABLE": true,
|
"ALLOW_UNREACHABLE": true,
|
||||||
"PRICE_UPDATES_PER_HOUR": 1
|
"PRICE_UPDATES_PER_HOUR": 1,
|
||||||
|
"MAX_TRACKED_ADDRESSES": 100
|
||||||
},
|
},
|
||||||
"CORE_RPC": {
|
"CORE_RPC": {
|
||||||
"HOST": "127.0.0.1",
|
"HOST": "127.0.0.1",
|
||||||
|
@ -34,7 +34,8 @@
|
|||||||
"DISK_CACHE_BLOCK_INTERVAL": 999,
|
"DISK_CACHE_BLOCK_INTERVAL": 999,
|
||||||
"MAX_PUSH_TX_SIZE_WEIGHT": 4000000,
|
"MAX_PUSH_TX_SIZE_WEIGHT": 4000000,
|
||||||
"ALLOW_UNREACHABLE": true,
|
"ALLOW_UNREACHABLE": true,
|
||||||
"PRICE_UPDATES_PER_HOUR": 1
|
"PRICE_UPDATES_PER_HOUR": 1,
|
||||||
|
"MAX_TRACKED_ADDRESSES": 1
|
||||||
},
|
},
|
||||||
"CORE_RPC": {
|
"CORE_RPC": {
|
||||||
"HOST": "__CORE_RPC_HOST__",
|
"HOST": "__CORE_RPC_HOST__",
|
||||||
|
@ -48,6 +48,7 @@ describe('Mempool Backend Config', () => {
|
|||||||
MAX_PUSH_TX_SIZE_WEIGHT: 400000,
|
MAX_PUSH_TX_SIZE_WEIGHT: 400000,
|
||||||
ALLOW_UNREACHABLE: true,
|
ALLOW_UNREACHABLE: true,
|
||||||
PRICE_UPDATES_PER_HOUR: 1,
|
PRICE_UPDATES_PER_HOUR: 1,
|
||||||
|
MAX_TRACKED_ADDRESSES: 1,
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(config.ELECTRUM).toStrictEqual({ HOST: '127.0.0.1', PORT: 3306, TLS_ENABLED: true });
|
expect(config.ELECTRUM).toStrictEqual({ HOST: '127.0.0.1', PORT: 3306, TLS_ENABLED: true });
|
||||||
|
@ -217,7 +217,10 @@ class WebsocketHandler {
|
|||||||
addressMap[address] = validAddress;
|
addressMap[address] = validAddress;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (Object.keys(addressMap).length > 0) {
|
if (Object.keys(addressMap).length > config.MEMPOOL.MAX_TRACKED_ADDRESSES) {
|
||||||
|
response['track-addresses-error'] = `too many addresses requested, this connection supports tracking a maximum of ${config.MEMPOOL.MAX_TRACKED_ADDRESSES} addresses`;
|
||||||
|
client['track-addresses'] = null;
|
||||||
|
} else if (Object.keys(addressMap).length > 0) {
|
||||||
client['track-addresses'] = addressMap;
|
client['track-addresses'] = addressMap;
|
||||||
} else {
|
} else {
|
||||||
client['track-addresses'] = null;
|
client['track-addresses'] = null;
|
||||||
@ -231,7 +234,10 @@ class WebsocketHandler {
|
|||||||
spks.push(spk.toLowerCase());
|
spks.push(spk.toLowerCase());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (spks.length) {
|
if (spks.length > config.MEMPOOL.MAX_TRACKED_ADDRESSES) {
|
||||||
|
response['track-scriptpubkeys-error'] = `too many scriptpubkeys requested, this connection supports tracking a maximum of ${config.MEMPOOL.MAX_TRACKED_ADDRESSES} scriptpubkeys`;
|
||||||
|
client['track-scriptpubkeys'] = null;
|
||||||
|
} else if (spks.length) {
|
||||||
client['track-scriptpubkeys'] = spks;
|
client['track-scriptpubkeys'] = spks;
|
||||||
} else {
|
} else {
|
||||||
client['track-scriptpubkeys'] = null;
|
client['track-scriptpubkeys'] = null;
|
||||||
|
@ -39,6 +39,7 @@ interface IConfig {
|
|||||||
MAX_PUSH_TX_SIZE_WEIGHT: number;
|
MAX_PUSH_TX_SIZE_WEIGHT: number;
|
||||||
ALLOW_UNREACHABLE: boolean;
|
ALLOW_UNREACHABLE: boolean;
|
||||||
PRICE_UPDATES_PER_HOUR: number;
|
PRICE_UPDATES_PER_HOUR: number;
|
||||||
|
MAX_TRACKED_ADDRESSES: number;
|
||||||
};
|
};
|
||||||
ESPLORA: {
|
ESPLORA: {
|
||||||
REST_API_URL: string;
|
REST_API_URL: string;
|
||||||
@ -193,6 +194,7 @@ const defaults: IConfig = {
|
|||||||
'MAX_PUSH_TX_SIZE_WEIGHT': 400000,
|
'MAX_PUSH_TX_SIZE_WEIGHT': 400000,
|
||||||
'ALLOW_UNREACHABLE': true,
|
'ALLOW_UNREACHABLE': true,
|
||||||
'PRICE_UPDATES_PER_HOUR': 1,
|
'PRICE_UPDATES_PER_HOUR': 1,
|
||||||
|
'MAX_TRACKED_ADDRESSES': 1,
|
||||||
},
|
},
|
||||||
'ESPLORA': {
|
'ESPLORA': {
|
||||||
'REST_API_URL': 'http://127.0.0.1:3000',
|
'REST_API_URL': 'http://127.0.0.1:3000',
|
||||||
|
@ -35,6 +35,7 @@
|
|||||||
"POOLS_JSON_TREE_URL": "__MEMPOOL_POOLS_JSON_TREE_URL__",
|
"POOLS_JSON_TREE_URL": "__MEMPOOL_POOLS_JSON_TREE_URL__",
|
||||||
"POOLS_JSON_URL": "__MEMPOOL_POOLS_JSON_URL__",
|
"POOLS_JSON_URL": "__MEMPOOL_POOLS_JSON_URL__",
|
||||||
"PRICE_UPDATES_PER_HOUR": __MEMPOOL_PRICE_UPDATES_PER_HOUR__
|
"PRICE_UPDATES_PER_HOUR": __MEMPOOL_PRICE_UPDATES_PER_HOUR__
|
||||||
|
"MAX_TRACKED_ADDRESSES": __MEMPOOL_MAX_TRACKED_ADDRESSES__
|
||||||
},
|
},
|
||||||
"CORE_RPC": {
|
"CORE_RPC": {
|
||||||
"HOST": "__CORE_RPC_HOST__",
|
"HOST": "__CORE_RPC_HOST__",
|
||||||
|
@ -36,6 +36,7 @@ __MEMPOOL_DISK_CACHE_BLOCK_INTERVAL__=${MEMPOOL_DISK_CACHE_BLOCK_INTERVAL:=6}
|
|||||||
__MEMPOOL_MAX_PUSH_TX_SIZE_WEIGHT__=${MEMPOOL_MAX_PUSH_TX_SIZE_WEIGHT:=4000000}
|
__MEMPOOL_MAX_PUSH_TX_SIZE_WEIGHT__=${MEMPOOL_MAX_PUSH_TX_SIZE_WEIGHT:=4000000}
|
||||||
__MEMPOOL_ALLOW_UNREACHABLE__=${MEMPOOL_ALLOW_UNREACHABLE:=true}
|
__MEMPOOL_ALLOW_UNREACHABLE__=${MEMPOOL_ALLOW_UNREACHABLE:=true}
|
||||||
__MEMPOOL_PRICE_UPDATES_PER_HOUR__=${MEMPOOL_PRICE_UPDATES_PER_HOUR:=1}
|
__MEMPOOL_PRICE_UPDATES_PER_HOUR__=${MEMPOOL_PRICE_UPDATES_PER_HOUR:=1}
|
||||||
|
__MEMPOOL_MAX_TRACKED_ADDRESSES__=${MEMPOOL_MAX_TRACKED_ADDRESSES:=1}
|
||||||
|
|
||||||
# CORE_RPC
|
# CORE_RPC
|
||||||
__CORE_RPC_HOST__=${CORE_RPC_HOST:=127.0.0.1}
|
__CORE_RPC_HOST__=${CORE_RPC_HOST:=127.0.0.1}
|
||||||
@ -188,6 +189,7 @@ sed -i "s!__MEMPOOL_DISK_CACHE_BLOCK_INTERVAL__!${__MEMPOOL_DISK_CACHE_BLOCK_INT
|
|||||||
sed -i "s!__MEMPOOL_MAX_PUSH_TX_SIZE_WEIGHT__!${__MEMPOOL_MAX_PUSH_TX_SIZE_WEIGHT__}!g" mempool-config.json
|
sed -i "s!__MEMPOOL_MAX_PUSH_TX_SIZE_WEIGHT__!${__MEMPOOL_MAX_PUSH_TX_SIZE_WEIGHT__}!g" mempool-config.json
|
||||||
sed -i "s!__MEMPOOL_ALLOW_UNREACHABLE__!${__MEMPOOL_ALLOW_UNREACHABLE__}!g" mempool-config.json
|
sed -i "s!__MEMPOOL_ALLOW_UNREACHABLE__!${__MEMPOOL_ALLOW_UNREACHABLE__}!g" mempool-config.json
|
||||||
sed -i "s!__MEMPOOL_PRICE_UPDATES_PER_HOUR__!${__MEMPOOL_PRICE_UPDATES_PER_HOUR__}!g" mempool-config.json
|
sed -i "s!__MEMPOOL_PRICE_UPDATES_PER_HOUR__!${__MEMPOOL_PRICE_UPDATES_PER_HOUR__}!g" mempool-config.json
|
||||||
|
sed -i "s!__MEMPOOL_MAX_TRACKED_ADDRESSES__!${__MEMPOOL_MAX_TRACKED_ADDRESSES__}!g" mempool-config.json
|
||||||
|
|
||||||
sed -i "s!__CORE_RPC_HOST__!${__CORE_RPC_HOST__}!g" mempool-config.json
|
sed -i "s!__CORE_RPC_HOST__!${__CORE_RPC_HOST__}!g" mempool-config.json
|
||||||
sed -i "s!__CORE_RPC_PORT__!${__CORE_RPC_PORT__}!g" mempool-config.json
|
sed -i "s!__CORE_RPC_PORT__!${__CORE_RPC_PORT__}!g" mempool-config.json
|
||||||
|
Loading…
Reference in New Issue
Block a user