github.com/anjalikarhana/fabric@v2.1.1+incompatible/orderer/common/bootstrap/bootstrap.go (about)

     1  // Copyright IBM Corp. All Rights Reserved.
     2  // SPDX-License-Identifier: Apache-2.0
     3  
     4  package bootstrap
     5  
     6  import (
     7  	ab "github.com/hyperledger/fabric-protos-go/common"
     8  )
     9  
    10  // Helper defines the functions a bootstrapping implementation should provide.
    11  type Helper interface {
    12  	// GenesisBlock should return the genesis block required to bootstrap
    13  	// the ledger (be it reading from the filesystem, generating it, etc.)
    14  	GenesisBlock() *ab.Block
    15  }
    16  
    17  // Replacer provides the ability to to replace the current genesis block used
    18  // for bootstrapping with the supplied block. It is used during consensus-type
    19  // migration in order to replace the original genesis block used for
    20  // bootstrapping with the latest config block of the system channel, which
    21  // contains the new consensus-type. This will ensure the instantiation of the
    22  // correct consenter type when the server restarts.
    23  type Replacer interface {
    24  	// ReplaceGenesisBlockFile should first copy the current file to a backup
    25  	// file: <genesis-file-name> => <genesis-file-name>.bak
    26  	// and then overwrite the original file with the content of the given block.
    27  	// If something goes wrong during migration, the original file could be
    28  	// restored from the backup.
    29  	// An error is returned if the operation was not completed successfully.
    30  	ReplaceGenesisBlockFile(block *ab.Block) error
    31  
    32  	// CheckReadWrite checks whether the current file is readable and writable,
    33  	// because if it is not, there is no point in attempting to replace. This
    34  	// check is performed at the beginning of the consensus-type migration
    35  	// process.
    36  	// An error is returned if the file is not readable and writable.
    37  	CheckReadWrite() error
    38  }