@@ -33,7 +33,7 @@ namespace Libplanet.Blockchain
33
33
/// <para>
34
34
/// In order to watch its state changes, implement <see cref="IRenderer"/> interface
35
35
/// and pass it to the
36
- /// <see cref="BlockChain(IBlockPolicy, IStagePolicy, IStore, IStateStore, Block, IBlockChainStates, IActionEvaluator, IEnumerable{IRenderer})"/>
36
+ /// <see cref="BlockChain(IBlockPolicy, IStagePolicy, IStore, IStateStore, Block, IBlockChainStates, IActionEvaluator, IEnumerable{IRenderer}, bool )"/>
37
37
/// constructor.
38
38
/// </para>
39
39
/// </summary>
@@ -90,6 +90,9 @@ public partial class BlockChain : IBlockChainStates
90
90
/// by default or if it is <see langword="null"/>. Note that action renderers receive
91
91
/// events made by unsuccessful transactions as well.</param>
92
92
/// <param name="stateStore"><see cref="IStateStore"/> to store states.</param>
93
+ /// <param name="determineNextBlockStateRootHash">
94
+ /// Whether to determine the next block's state root hash when the chain is instantiated.
95
+ /// </param>
93
96
/// <exception cref="ArgumentException">Thrown when <paramref name="store"/> does not
94
97
/// have canonical chain id set, i.e. <see cref="IStore.GetCanonicalChainId()"/> is
95
98
/// <see langword="null"/>.</exception>
@@ -106,7 +109,8 @@ public BlockChain(
106
109
Block genesisBlock ,
107
110
IBlockChainStates blockChainStates ,
108
111
IActionEvaluator actionEvaluator ,
109
- IEnumerable < IRenderer > renderers = null )
112
+ IEnumerable < IRenderer > renderers = null ,
113
+ bool determineNextBlockStateRootHash = true )
110
114
#pragma warning disable SA1118 // The parameter spans multiple lines
111
115
: this (
112
116
policy ,
@@ -120,7 +124,8 @@ public BlockChain(
120
124
genesisBlock ,
121
125
blockChainStates ,
122
126
actionEvaluator ,
123
- renderers )
127
+ renderers ,
128
+ determineNextBlockStateRootHash )
124
129
{
125
130
}
126
131
@@ -133,7 +138,8 @@ private BlockChain(
133
138
Block genesisBlock ,
134
139
IBlockChainStates blockChainStates ,
135
140
IActionEvaluator actionEvaluator ,
136
- IEnumerable < IRenderer > renderers )
141
+ IEnumerable < IRenderer > renderers ,
142
+ bool determineNextBlockStateRootHash )
137
143
{
138
144
if ( store is null )
139
145
{
@@ -190,7 +196,7 @@ private BlockChain(
190
196
{
191
197
_nextStateRootHash = Tip . StateRootHash ;
192
198
}
193
- else
199
+ else if ( determineNextBlockStateRootHash )
194
200
{
195
201
_nextStateRootHash =
196
202
DetermineNextBlockStateRootHash ( Tip , out var actionEvaluations ) ;
@@ -224,7 +230,7 @@ private BlockChain(
224
230
/// <remarks>
225
231
/// Since this value is immutable, renderers cannot be registered after once a <see
226
232
/// cref="BlockChain"/> object is instantiated; use <c>renderers</c> option of
227
- /// <see cref="BlockChain(IBlockPolicy, IStagePolicy, IStore, IStateStore, Block, IBlockChainStates, IActionEvaluator, IEnumerable{IRenderer})"/>
233
+ /// <see cref="BlockChain(IBlockPolicy, IStagePolicy, IStore, IStateStore, Block, IBlockChainStates, IActionEvaluator, IEnumerable{IRenderer}, bool )"/>
228
234
/// constructor instead.
229
235
/// </remarks>
230
236
#pragma warning restore MEN002
@@ -441,7 +447,8 @@ public static BlockChain Create(
441
447
genesisBlock ,
442
448
blockChainStates ,
443
449
actionEvaluator ,
444
- renderers ) ;
450
+ renderers ,
451
+ true ) ;
445
452
}
446
453
447
454
/// <summary>
0 commit comments