fix getBlockTemplate

This commit is contained in:
Benjamin Wilson
2024-09-16 19:16:38 -04:00
parent d6863fad28
commit 6038af8448
+7 -6
View File
@@ -98,16 +98,17 @@ export class BitcoinRpcService implements OnModuleInit {
const block = await this.rpcBlockService.getBlock(blockHeight);
const completeBlock = block?.data != null;
// If the block has already been loaded, and the same instance is fetching the template again, we just need to refresh it.
if (completeBlock && process.env.MASTER == 'true') {
result = await this.loadBlockTemplate(blockHeight);
}
else if (completeBlock) {
if (completeBlock) {
return Promise.resolve(JSON.parse(block.data));
}
if(process.env.MASTER == 'true'){
result = await this.loadBlockTemplate(blockHeight);
}else{
//wait for block
result = await this.waitForBlock(blockHeight);
}
} catch (e) {
console.error('Error getblocktemplate:', e.message);
throw new Error('Error getblocktemplate');