Transaction

1dbe9f0346a8a8c40887e076f716790584ef2bf8feabf5b9b0ee6fd43f6e61ed
Timestamp (utc)
2024-03-24 02:41:15
Fee Paid
0.00000026 BSV
(
0.01986484 BSV
-
0.01986458 BSV
)
Fee Rate
10.35 sat/KB
Version
1
Confirmations
101,457
Size Stats
2,511 B

2 Outputs

Total Output:
0.01986458 BSV
  • j"1LAnZuoQdcKCkpDBKQMCgziGMoPC4VQUckMÓ<div class="post">That's a difficult approach.<br/><br/>We need to cause a reorg, which will disconnect the invalid chain.<br/><br/>This is code that will rarely ever get tested, and is fairly intricate, so something simple and safe is best.<br/><br/>Here's what I was thinking of. &nbsp;(I haven't tested this yet) &nbsp;It checks all the blocks in the main chain. &nbsp;If it finds a bad one, it sets all that chain's bnChainWork to 0 so it can't win best chain again, and it reduces best chain work to the fork level so any new block after the fork will cause a reorg. &nbsp;(It can't change pindexBest without actually doing a reorg)<br/><br/>This isn't perfect yet. &nbsp;It still needs to receive one valid block to trigger the reorg. &nbsp;<br/><br/>It would probably be possible to initiate an AddToBlockIndex or Reorganize after the check, but it would require a lot more careful attention. &nbsp;I probably should break out part of AddToBlockIndex that sets the new best block. &nbsp;I'll probably end up doing that instead of the code below.<br/><br/><div class="codeheader">Code:</div><div class="code">bool CTxDB::LoadBlockIndex()<br/>{<br/>&nbsp;&nbsp; &nbsp;...<br/><br/>&nbsp;&nbsp; &nbsp;// Verify blocks in the main chain<br/>&nbsp;&nbsp; &nbsp;vector&lt;CBlockIndex*&gt; vChain;<br/>&nbsp;&nbsp; &nbsp;for (CBlockIndex* pindex = pindexBest; pindex &amp;&amp; pindex-&gt;pprev; pindex = pindex-&gt;pprev)<br/>&nbsp;&nbsp; &nbsp;{<br/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;vChain.push_back(pindex);<br/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;CBlock block;<br/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;if (!block.ReadFromDisk(pindex))<br/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;return error("LoadBlockIndex() : block.ReadFromDisk failed");<br/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;if (!block.CheckBlock())<br/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;{<br/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;bnBestChainWork = pindex-&gt;pprev-&gt;bnChainWork;<br/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;foreach(CBlockIndex* pindex2, vChain)<br/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;pindex2-&gt;bnChainWork = 0;<br/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;}<br/>&nbsp;&nbsp; &nbsp;}<br/><br/>&nbsp;&nbsp; &nbsp;return true;<br/>}<br/></div></div> text/html
    https://whatsonchain.com/tx/1dbe9f0346a8a8c40887e076f716790584ef2bf8feabf5b9b0ee6fd43f6e61ed