mirror of
https://github.com/benjamin-wilson/public-pool.git
synced 2026-09-29 09:05:06 -07:00
bug
This commit is contained in:
@@ -77,11 +77,12 @@ export class BitcoinRpcService {
|
|||||||
if (block != null && block.data != null) {
|
if (block != null && block.data != null) {
|
||||||
return Promise.resolve(JSON.parse(block.data));
|
return Promise.resolve(JSON.parse(block.data));
|
||||||
} else if (block == null) {
|
} else if (block == null) {
|
||||||
const { lockedBy } = await this.rpcBlockService.lockBlock(blockHeight, process.env.NODE_APP_INSTANCE);
|
// There is a unique constraint on the block height so if another process tries to lock, it'll throw
|
||||||
|
try {
|
||||||
if (lockedBy != process.env.NODE_APP_INSTANCE) {
|
await this.rpcBlockService.lockBlock(blockHeight, process.env.NODE_APP_INSTANCE);
|
||||||
|
} catch (e) {
|
||||||
result = await this.waitForBlock(blockHeight);
|
result = await this.waitForBlock(blockHeight);
|
||||||
} else {
|
}
|
||||||
|
|
||||||
result = await this.client.getblocktemplate({
|
result = await this.client.getblocktemplate({
|
||||||
template_request: {
|
template_request: {
|
||||||
@@ -91,7 +92,7 @@ export class BitcoinRpcService {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
await this.rpcBlockService.saveBlock(blockHeight, JSON.stringify(result));
|
await this.rpcBlockService.saveBlock(blockHeight, JSON.stringify(result));
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
//wait for block
|
//wait for block
|
||||||
result = await this.waitForBlock(blockHeight);
|
result = await this.waitForBlock(blockHeight);
|
||||||
|
|||||||
Reference in New Issue
Block a user