diff --git a/CHANGES.md b/CHANGES.md index 73d6c092e6d..076962003b3 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -33,6 +33,9 @@ To be released. ### Behavioral changes + - Added `DetermineNextBlockStateRootHash` property to `BlockChain.BlockChain`. + [[#3977], [#3978]] + ### Bug fixes ### Dependencies @@ -41,6 +44,8 @@ To be released. [#3912]: https://github.com/planetarium/libplanet/pull/3912 [#3974]: https://github.com/planetarium/libplanet/pull/3974 +[#3977]: https://github.com/planetarium/libplanet/issue/3977 +[#3978]: https://github.com/planetarium/libplanet/pull/3978 Version 5.3.1 diff --git a/src/Libplanet/Blockchain/BlockChain.cs b/src/Libplanet/Blockchain/BlockChain.cs index 856403dd71e..5326ccfca17 100644 --- a/src/Libplanet/Blockchain/BlockChain.cs +++ b/src/Libplanet/Blockchain/BlockChain.cs @@ -33,7 +33,7 @@ namespace Libplanet.Blockchain /// /// In order to watch its state changes, implement interface /// and pass it to the - /// + /// /// constructor. /// /// @@ -90,6 +90,9 @@ public partial class BlockChain : IBlockChainStates /// by default or if it is . Note that action renderers receive /// events made by unsuccessful transactions as well. /// to store states. + /// + /// Whether to determine the next block's state root hash when the chain is instantiated. + /// /// Thrown when does not /// have canonical chain id set, i.e. is /// . @@ -106,7 +109,8 @@ public BlockChain( Block genesisBlock, IBlockChainStates blockChainStates, IActionEvaluator actionEvaluator, - IEnumerable renderers = null) + IEnumerable renderers = null, + bool determineNextBlockStateRootHash = true) #pragma warning disable SA1118 // The parameter spans multiple lines : this( policy, @@ -120,7 +124,8 @@ public BlockChain( genesisBlock, blockChainStates, actionEvaluator, - renderers) + renderers, + determineNextBlockStateRootHash) { } @@ -133,7 +138,8 @@ private BlockChain( Block genesisBlock, IBlockChainStates blockChainStates, IActionEvaluator actionEvaluator, - IEnumerable renderers) + IEnumerable renderers, + bool determineNextBlockStateRootHash) { if (store is null) { @@ -190,7 +196,7 @@ private BlockChain( { _nextStateRootHash = Tip.StateRootHash; } - else + else if (determineNextBlockStateRootHash) { _nextStateRootHash = DetermineNextBlockStateRootHash(Tip, out var actionEvaluations); @@ -224,7 +230,7 @@ private BlockChain( /// /// Since this value is immutable, renderers cannot be registered after once a object is instantiated; use renderers option of - /// + /// /// constructor instead. /// #pragma warning restore MEN002 @@ -441,7 +447,8 @@ public static BlockChain Create( genesisBlock, blockChainStates, actionEvaluator, - renderers); + renderers, + true); } ///