@@ -55,6 +55,7 @@ var rootCmd = &cobra.Command{
55
55
GenCertVeryInsecure : viper .GetBool ("gen-cert-very-insecure" ),
56
56
DataDir : viper .GetString ("data-dir" ),
57
57
Redownload : viper .GetBool ("redownload" ),
58
+ NoCache : viper .GetBool ("nocache" ),
58
59
SyncFromHeight : viper .GetInt ("sync-from-height" ),
59
60
PingEnable : viper .GetBool ("ping-very-insecure" ),
60
61
Darkside : viper .GetBool ("darkside-very-insecure" ),
@@ -240,13 +241,22 @@ func startServer(opts *common.Options) error {
240
241
os .Stderr .WriteString (fmt .Sprintf ("\n ** Can't create db directory: %s\n \n " , dbPath ))
241
242
os .Exit (1 )
242
243
}
243
- syncFromHeight := opts .SyncFromHeight
244
- if opts .Redownload {
245
- syncFromHeight = 0
244
+ var cache * common.BlockCache
245
+ if opts .NoCache {
246
+ lengthsName , blocksName := common .DbFileNames (dbPath , chainName )
247
+ os .Remove (lengthsName )
248
+ os .Remove (blocksName )
249
+ } else {
250
+ syncFromHeight := opts .SyncFromHeight
251
+ if opts .Redownload {
252
+ syncFromHeight = 0
253
+ }
254
+ cache = common .NewBlockCache (dbPath , chainName , saplingHeight , syncFromHeight )
246
255
}
247
- cache := common .NewBlockCache (dbPath , chainName , saplingHeight , syncFromHeight )
248
256
if ! opts .Darkside {
249
- go common .BlockIngestor (cache , 0 /*loop forever*/ )
257
+ if ! opts .NoCache {
258
+ go common .BlockIngestor (cache , 0 /*loop forever*/ )
259
+ }
250
260
} else {
251
261
// Darkside wants to control starting the block ingestor.
252
262
common .DarksideInit (cache , int (opts .DarksideTimeout ))
@@ -330,6 +340,7 @@ func init() {
330
340
rootCmd .Flags ().Bool ("no-tls-very-insecure" , false , "run without the required TLS certificate, only for debugging, DO NOT use in production" )
331
341
rootCmd .Flags ().Bool ("gen-cert-very-insecure" , false , "run with self-signed TLS certificate, only for debugging, DO NOT use in production" )
332
342
rootCmd .Flags ().Bool ("redownload" , false , "re-fetch all blocks from zcashd; reinitialize local cache files" )
343
+ rootCmd .Flags ().Bool ("nocache" , false , "don't maintain a compact blocks disk cache (to reduce storage)" )
333
344
rootCmd .Flags ().Int ("sync-from-height" , - 1 , "re-fetch blocks from zcashd start at this height" )
334
345
rootCmd .Flags ().String ("data-dir" , "/var/lib/lightwalletd" , "data directory (such as db)" )
335
346
rootCmd .Flags ().Bool ("ping-very-insecure" , false , "allow Ping GRPC for testing" )
@@ -362,6 +373,8 @@ func init() {
362
373
viper .SetDefault ("gen-cert-very-insecure" , false )
363
374
viper .BindPFlag ("redownload" , rootCmd .Flags ().Lookup ("redownload" ))
364
375
viper .SetDefault ("redownload" , false )
376
+ viper .BindPFlag ("nocache" , rootCmd .Flags ().Lookup ("nocache" ))
377
+ viper .SetDefault ("nocache" , false )
365
378
viper .BindPFlag ("sync-from-height" , rootCmd .Flags ().Lookup ("sync-from-height" ))
366
379
viper .SetDefault ("sync-from-height" , - 1 )
367
380
viper .BindPFlag ("data-dir" , rootCmd .Flags ().Lookup ("data-dir" ))
0 commit comments