-
Notifications
You must be signed in to change notification settings - Fork 8.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FAB-1617] [FAB-1619] Utilize configtx.Template
https://jira.hyperledger.org/browse/FAB-1617 https://jira.hyperledger.org/browse/FAB-1619 This changeset removes some of the duplicated orderer bootstrap code from the protos/utils package. It does this by introducing a common/configtx/test package which uses a sample config template to produce a genesis block. This can also be used in the future for clients wishing to create a chain creation transaction. This is demonstrated in the broadcast_config client. This removes the vestigal utils methods for creating configuration transactions via the 'oldConfiguration' mechanisms. Change-Id: If064ed3cfcdbd2e59e8fb6c7bf72c8af160dc5f6 Signed-off-by: Jason Yellick <jyellick@us.ibm.com>
- Loading branch information
Jason Yellick
committed
Jan 13, 2017
1 parent
ed33fec
commit ebdfbf3
Showing
16 changed files
with
131 additions
and
192 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* | ||
Copyright IBM Corp. 2016 All Rights Reserved. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package test | ||
|
||
import ( | ||
"io/ioutil" | ||
"os" | ||
|
||
"github.com/hyperledger/fabric/common/configtx" | ||
"github.com/hyperledger/fabric/common/genesis" | ||
cb "github.com/hyperledger/fabric/protos/common" | ||
"github.com/hyperledger/fabric/protos/utils" | ||
|
||
"github.com/golang/protobuf/proto" | ||
) | ||
|
||
var template configtx.Template | ||
|
||
var genesisFactory genesis.Factory | ||
|
||
// XXX This is a hacky singleton, which should go away, but is an artifact of using the existing utils implementation | ||
type MSPTemplate struct{} | ||
|
||
func (msp MSPTemplate) Items(chainID string) ([]*cb.SignedConfigurationItem, error) { | ||
return []*cb.SignedConfigurationItem{utils.EncodeMSP(chainID)}, nil | ||
} | ||
|
||
func init() { | ||
|
||
gopath := os.Getenv("GOPATH") | ||
data, err := ioutil.ReadFile(gopath + "/src/github.com/hyperledger/fabric/common/configtx/test/orderer.template") | ||
if err != nil { | ||
peerConfig := os.Getenv("PEER_CFG_PATH") | ||
data, err = ioutil.ReadFile(peerConfig + "/common/configtx/test/orderer.template") | ||
if err != nil { | ||
panic(err) | ||
} | ||
} | ||
templateProto := &cb.ConfigurationTemplate{} | ||
err = proto.Unmarshal(data, templateProto) | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
template = configtx.NewSimpleTemplate(templateProto.Items...) | ||
genesisFactory = genesis.NewFactoryImpl(configtx.NewCompositeTemplate(MSPTemplate{}, template)) | ||
} | ||
|
||
func MakeGenesisBlock(chainID string) (*cb.Block, error) { | ||
return genesisFactory.Block(chainID) | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.