fix getBlockTemplate

This commit is contained in:
Benjamin Wilson
2024-09-16 19:16:38 -04:00
parent d6863fad28
commit 6038af8448
+8 -7
View File
@@ -98,16 +98,17 @@ export class BitcoinRpcService implements OnModuleInit {
const block = await this.rpcBlockService.getBlock(blockHeight); const block = await this.rpcBlockService.getBlock(blockHeight);
const completeBlock = block?.data != null; 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') { if (completeBlock) {
result = await this.loadBlockTemplate(blockHeight);
}
else if (completeBlock) {
return Promise.resolve(JSON.parse(block.data)); return Promise.resolve(JSON.parse(block.data));
}else { }
//wait for block
if(process.env.MASTER == 'true'){
result = await this.loadBlockTemplate(blockHeight);
}else{
result = await this.waitForBlock(blockHeight); result = await this.waitForBlock(blockHeight);
} }
} catch (e) { } catch (e) {
console.error('Error getblocktemplate:', e.message); console.error('Error getblocktemplate:', e.message);
throw new Error('Error getblocktemplate'); throw new Error('Error getblocktemplate');