mirror of
https://github.com/benjamin-wilson/public-pool.git
synced 2026-09-29 09:05:06 -07:00
Switch block ZMQ notifications to hashblock
This commit is contained in:
+2
-1
@@ -22,7 +22,8 @@ BLOCK_TEMPLATE_RETRY_MAX_MS=1000
|
|||||||
#BITCOIN_RPC_AUX_URLS=http://bitcoin-core-2,http://bitcoin-core-3
|
#BITCOIN_RPC_AUX_URLS=http://bitcoin-core-2,http://bitcoin-core-3
|
||||||
|
|
||||||
# Enable in bitcoin.conf with:
|
# Enable in bitcoin.conf with:
|
||||||
# zmqpubrawblock=tcp://0.0.0.0:3000
|
# zmqpubhashblock=tcp://0.0.0.0:3000
|
||||||
|
BITCOIN_ZMQ_TOPIC=hashblock
|
||||||
BITCOIN_ZMQ_HOST=tcp://192.168.1.100:3000
|
BITCOIN_ZMQ_HOST=tcp://192.168.1.100:3000
|
||||||
|
|
||||||
API_PORT=3334
|
API_PORT=3334
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ reserve two namespace values per configured Stratum worker.
|
|||||||
### New-block notification path
|
### New-block notification path
|
||||||
|
|
||||||
The master keeps an authoritative Bitcoin Core `getblocktemplate` longpoll open;
|
The master keeps an authoritative Bitcoin Core `getblocktemplate` longpoll open;
|
||||||
rawblock ZMQ remains a watchdog and duplicate results are discarded. Optional
|
hashblock ZMQ remains a watchdog and duplicate results are discarded. Optional
|
||||||
endpoints in `BITCOIN_RPC_AUX_URLS` keep independent longpolls open and race the
|
endpoints in `BITCOIN_RPC_AUX_URLS` keep independent longpolls open and race the
|
||||||
primary source, reducing dependence on one node's block-relay peers. An auxiliary
|
primary source, reducing dependence on one node's block-relay peers. An auxiliary
|
||||||
template is only eligible after the primary Core's `getbestblockhash` exactly
|
template is only eligible after the primary Core's `getbestblockhash` exactly
|
||||||
@@ -234,7 +234,7 @@ RPC block template table.
|
|||||||
|
|
||||||
```
|
```
|
||||||
rpcallowip=172.16.0.0/12
|
rpcallowip=172.16.0.0/12
|
||||||
zmqpubrawblock=tcp://0.0.0.0:3000
|
zmqpubhashblock=tcp://0.0.0.0:3000
|
||||||
```
|
```
|
||||||
|
|
||||||
to your bitcoin.conf.
|
to your bitcoin.conf.
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ rpcuser=bitcoin
|
|||||||
server=1
|
server=1
|
||||||
|
|
||||||
# notify pool master about new blocks
|
# notify pool master about new blocks
|
||||||
zmqpubrawblock=tcp://0.0.0.0:3000
|
zmqpubhashblock=tcp://0.0.0.0:3000
|
||||||
|
|
||||||
[main]
|
[main]
|
||||||
[test]
|
[test]
|
||||||
|
|||||||
@@ -22,4 +22,4 @@ rpcuser=bitcoin
|
|||||||
prune=550
|
prune=550
|
||||||
|
|
||||||
# notify pool master about new blocks
|
# notify pool master about new blocks
|
||||||
zmqpubrawblock=tcp://0.0.0.0:3000
|
zmqpubhashblock=tcp://0.0.0.0:3000
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ rpcuser=bitcoin
|
|||||||
server=1
|
server=1
|
||||||
|
|
||||||
# notify pool master about new blocks
|
# notify pool master about new blocks
|
||||||
zmqpubrawblock=tcp://0.0.0.0:3000
|
zmqpubhashblock=tcp://0.0.0.0:3000
|
||||||
|
|
||||||
[main]
|
[main]
|
||||||
[test]
|
[test]
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ BITCOIN_RPC_PASSWORD=bitcoin
|
|||||||
BITCOIN_RPC_PORT=8332
|
BITCOIN_RPC_PORT=8332
|
||||||
BITCOIN_RPC_TIMEOUT=10000
|
BITCOIN_RPC_TIMEOUT=10000
|
||||||
|
|
||||||
|
BITCOIN_ZMQ_TOPIC=hashblock
|
||||||
BITCOIN_ZMQ_HOST=tcp://bitcoin:3000
|
BITCOIN_ZMQ_HOST=tcp://bitcoin:3000
|
||||||
|
|
||||||
API_PORT=3334
|
API_PORT=3334
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ BITCOIN_RPC_PASSWORD=bitcoin
|
|||||||
BITCOIN_RPC_PORT=28332
|
BITCOIN_RPC_PORT=28332
|
||||||
BITCOIN_RPC_TIMEOUT=10000
|
BITCOIN_RPC_TIMEOUT=10000
|
||||||
|
|
||||||
|
BITCOIN_ZMQ_TOPIC=hashblock
|
||||||
BITCOIN_ZMQ_HOST=tcp://bitcoin-regtest:3000
|
BITCOIN_ZMQ_HOST=tcp://bitcoin-regtest:3000
|
||||||
|
|
||||||
API_PORT=23334
|
API_PORT=23334
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ BITCOIN_RPC_PASSWORD=bitcoin
|
|||||||
BITCOIN_RPC_PORT=18332
|
BITCOIN_RPC_PORT=18332
|
||||||
BITCOIN_RPC_TIMEOUT=10000
|
BITCOIN_RPC_TIMEOUT=10000
|
||||||
|
|
||||||
|
BITCOIN_ZMQ_TOPIC=hashblock
|
||||||
BITCOIN_ZMQ_HOST=tcp://bitcoin-testnet:3000
|
BITCOIN_ZMQ_HOST=tcp://bitcoin-testnet:3000
|
||||||
|
|
||||||
API_PORT=13334
|
API_PORT=13334
|
||||||
|
|||||||
@@ -249,8 +249,18 @@ export class BitcoinRpcService implements OnModuleInit {
|
|||||||
console.error('ZMQ Unable to connect, Retrying');
|
console.error('ZMQ Unable to connect, Retrying');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const zmqTopics = (this.configService.get<string>('BITCOIN_ZMQ_TOPIC')
|
||||||
|
?? process.env.BITCOIN_ZMQ_TOPIC
|
||||||
|
?? 'hashblock')
|
||||||
|
.split(',')
|
||||||
|
.map(topic => topic.trim())
|
||||||
|
.filter(topic => topic.length > 0);
|
||||||
|
if (zmqTopics.length === 0) {
|
||||||
|
zmqTopics.push('hashblock');
|
||||||
|
}
|
||||||
sock.connect(this.configService.get('BITCOIN_ZMQ_HOST'));
|
sock.connect(this.configService.get('BITCOIN_ZMQ_HOST'));
|
||||||
sock.subscribe('rawblock');
|
zmqTopics.forEach(topic => sock.subscribe(topic));
|
||||||
|
console.log(`ZMQ subscribed to ${zmqTopics.join(',')}`);
|
||||||
// Don't await this, otherwise it will block the rest of the program
|
// Don't await this, otherwise it will block the rest of the program
|
||||||
this.listenForNewBlocks(sock);
|
this.listenForNewBlocks(sock);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user