github.com/hechain20/hechain@v0.0.0-20220316014945-b544036ba106/common/ledger/dataformat/dataformats.go (about) 1 /* 2 Copyright hechain. All Rights Reserved. 3 4 SPDX-License-Identifier: Apache-2.0 5 */ 6 7 package dataformat 8 9 import "fmt" 10 11 // The data format stored in ledger databases may be changed in a new release to 12 // support new features. This file defines the constants to check whether or not 13 // the data format on the ledger matches the CurrentFormat. If not matched, peer start 14 // will fail and the ledger must be upgraded to the CurrentFormat. If a Fabric version 15 // does not introduce a new data format, CurrentFormat will remain the same as the latest 16 // format prior to the Fabric version. 17 const ( 18 // PreviousFormat specifies the data format in previous fabric version 19 PreviousFormat = "" 20 21 // CurrentFormat specifies the data format in current fabric version 22 CurrentFormat = "2.0" 23 ) 24 25 // ErrFormatMismatch is returned if it is detected that the version of the format recorded in 26 // the internal database is different from what is specified in the `Conf` that is used for opening the db 27 type ErrFormatMismatch struct { 28 DBInfo string 29 ExpectedFormat string 30 Format string 31 } 32 33 func (e *ErrFormatMismatch) Error() string { 34 return fmt.Sprintf("unexpected format. db info = [%s], data format = [%s], expected format = [%s]", 35 e.DBInfo, e.Format, e.ExpectedFormat, 36 ) 37 } 38 39 // IsVersionMismatch returns true if err is an ErrFormatMismatch 40 func IsVersionMismatch(err error) bool { 41 _, ok := err.(*ErrFormatMismatch) 42 return ok 43 }