@@ -23,12 +23,12 @@ public class StorageDumper : Plugin
2323 {
2424 private readonly Dictionary < uint , NeoSystem > systems = new Dictionary < uint , NeoSystem > ( ) ;
2525
26- private StreamWriter _writer ;
26+ private StreamWriter ? _writer ;
2727 /// <summary>
2828 /// _currentBlock stores the last cached item
2929 /// </summary>
30- private JObject _currentBlock ;
31- private string _lastCreateDirectory ;
30+ private JObject ? _currentBlock ;
31+ private string ? _lastCreateDirectory ;
3232
3333
3434 public override string Description => "Exports Neo-CLI status data" ;
@@ -73,7 +73,7 @@ private void OnDumpStorage(uint network, UInt160? contractHash = null)
7373 prefix = BitConverter . GetBytes ( contract . Id ) ;
7474 }
7575 var states = systems [ network ] . StoreView . Find ( prefix ) ;
76- JArray array = new JArray ( states . Where ( p => ! Settings . Default . Exclude . Contains ( p . Key . Id ) ) . Select ( p => new JObject
76+ JArray array = new JArray ( states . Where ( p => ! Settings . Default ! . Exclude . Contains ( p . Key . Id ) ) . Select ( p => new JObject
7777 {
7878 [ "key" ] = Convert . ToBase64String ( p . Key . ToArray ( ) ) ,
7979 [ "value" ] = Convert . ToBase64String ( p . Value . ToArray ( ) )
@@ -94,7 +94,7 @@ private void OnCommitting(NeoSystem system, Block block, DataCache snapshot, IRe
9494 private void OnPersistStorage ( uint network , DataCache snapshot )
9595 {
9696 uint blockIndex = NativeContract . Ledger . CurrentIndex ( snapshot ) ;
97- if ( blockIndex >= Settings . Default . HeightToBegin )
97+ if ( blockIndex >= Settings . Default ! . HeightToBegin )
9898 {
9999 JArray stateChangeArray = new JArray ( ) ;
100100
@@ -139,7 +139,7 @@ private void OnCommitted(NeoSystem system, Block block)
139139
140140 void OnCommitStorage ( uint network , DataCache snapshot )
141141 {
142- if ( _currentBlock != null )
142+ if ( _currentBlock != null && _writer != null )
143143 {
144144 _writer . WriteLine ( _currentBlock . ToString ( ) ) ;
145145 _writer . Flush ( ) ;
@@ -150,10 +150,10 @@ private void InitFileWriter(uint network, DataCache snapshot)
150150 {
151151 uint blockIndex = NativeContract . Ledger . CurrentIndex ( snapshot ) ;
152152 if ( _writer == null
153- || blockIndex % Settings . Default . BlockCacheSize == 0 )
153+ || blockIndex % Settings . Default ! . BlockCacheSize == 0 )
154154 {
155155 string path = GetOrCreateDirectory ( network , blockIndex ) ;
156- var filepart = ( blockIndex / Settings . Default . BlockCacheSize ) * Settings . Default . BlockCacheSize ;
156+ var filepart = ( blockIndex / Settings . Default ! . BlockCacheSize ) * Settings . Default . BlockCacheSize ;
157157 path = $ "{ path } /dump-block-{ filepart } .dump";
158158 if ( _writer != null )
159159 {
@@ -176,7 +176,7 @@ private string GetOrCreateDirectory(uint network, uint blockIndex)
176176
177177 private string GetDirectoryPath ( uint network , uint blockIndex )
178178 {
179- uint folder = ( blockIndex / Settings . Default . StoragePerFolder ) * Settings . Default . StoragePerFolder ;
179+ uint folder = ( blockIndex / Settings . Default ! . StoragePerFolder ) * Settings . Default . StoragePerFolder ;
180180 return $ "./StorageDumper_{ network } /BlockStorage_{ folder } ";
181181 }
182182
0 commit comments