github.com/true-sqn/fabric@v2.1.1+incompatible/core/ledger/kvledger/recovery.go (about)

     1  /*
     2  Copyright IBM Corp. 2016 All Rights Reserved.
     3  
     4  Licensed under the Apache License, Version 2.0 (the "License");
     5  you may not use this file except in compliance with the License.
     6  You may obtain a copy of the License at
     7  
     8  		 http://www.apache.org/licenses/LICENSE-2.0
     9  
    10  Unless required by applicable law or agreed to in writing, software
    11  distributed under the License is distributed on an "AS IS" BASIS,
    12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  See the License for the specific language governing permissions and
    14  limitations under the License.
    15  */
    16  
    17  package kvledger
    18  
    19  import "github.com/hyperledger/fabric/core/ledger"
    20  
    21  type recoverable interface {
    22  	// ShouldRecover return whether recovery is need.
    23  	// If the recovery is needed, this method also returns the block number to start recovery from.
    24  	// lastAvailableBlock is the max block number that has been committed to the block storage
    25  	ShouldRecover(lastAvailableBlock uint64) (bool, uint64, error)
    26  	// CommitLostBlock recommits the block
    27  	CommitLostBlock(block *ledger.BlockAndPvtData) error
    28  	// Name returns the name of the database: either state or history
    29  	Name() string
    30  }
    31  
    32  type recoverer struct {
    33  	firstBlockNum uint64
    34  	recoverable   recoverable
    35  }