github.com/sykesm/fabric@v1.1.0-preview.0.20200129034918-2aa12b1a0181/common/ledger/dataformat/dataformats.go (about) 1 /* 2 Copyright IBM Corp. All Rights Reserved. 3 4 SPDX-License-Identifier: Apache-2.0 5 */ 6 7 package dataformat 8 9 import "fmt" 10 11 const ( 12 // Version1x specifies the data format in version 1.x 13 Version1x = "" 14 15 // Version20 specifies the data format in version 2.0 16 Version20 = "2.0" 17 ) 18 19 // ErrVersionMismatch is returned if it is detected that the version of the format recorded in 20 // the internal database is different from what is specified in the `Conf` that is used for opening the db 21 type ErrVersionMismatch struct { 22 DBInfo string 23 ExpectedVersion string 24 Version string 25 } 26 27 func (e *ErrVersionMismatch) Error() string { 28 return fmt.Sprintf("unexpected format. db info = [%s], data format = [%s], expected format = [%s]", 29 e.DBInfo, e.Version, e.ExpectedVersion, 30 ) 31 } 32 33 // IsVersionMismatch returns true if err is an ErrVersionMismatch 34 func IsVersionMismatch(err error) bool { 35 _, ok := err.(*ErrVersionMismatch) 36 return ok 37 }