github.com/hechain20/hechain@v0.0.0-20220316014945-b544036ba106/internal/peer/node/reset.go (about)

     1  /*
     2  Copyright hechain. All Rights Reserved.
     3  
     4  SPDX-License-Identifier: Apache-2.0
     5  */
     6  
     7  package node
     8  
     9  import (
    10  	"github.com/hechain20/hechain/core/ledger/kvledger"
    11  	"github.com/spf13/cobra"
    12  )
    13  
    14  func resetCmd() *cobra.Command {
    15  	return nodeResetCmd
    16  }
    17  
    18  var nodeResetCmd = &cobra.Command{
    19  	Use:   "reset",
    20  	Short: "Resets the node.",
    21  	Long: "Resets all channels to the genesis block. When the command is executed, the peer must be offline." +
    22  		" When the peer starts after the reset, it will receive blocks starting with block number one from an orderer or another peer to rebuild the block store and state database." +
    23  		" The command is not supported if the peer contains any channel that was bootstrapped from a snapshot.",
    24  	RunE: func(cmd *cobra.Command, args []string) error {
    25  		config := ledgerConfig()
    26  		return kvledger.ResetAllKVLedgers(config.RootFSPath)
    27  	},
    28  }