Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
zistvan-public
StreamChain Prototype
Commits
299e286c
Commit
299e286c
authored
Jul 08, 2018
by
Gari Singh
Committed by
Gerrit Code Review
Jul 08, 2018
Browse files
Merge "[FAB-11049] add {Read,Write}{Orderer,Peer}Config"
parents
7da0449e
505fb6a0
Changes
2
Hide whitespace changes
Inline
Side-by-side
integration/nwo/network.go
View file @
299e286c
...
...
@@ -22,6 +22,7 @@ import (
docker
"github.com/fsouza/go-dockerclient"
"github.com/hyperledger/fabric/integration/helpers"
"github.com/hyperledger/fabric/integration/nwo/commands"
"github.com/hyperledger/fabric/integration/nwo/fabricconfig"
"github.com/hyperledger/fabric/integration/runner"
"github.com/onsi/ginkgo"
.
"github.com/onsi/gomega"
...
...
@@ -30,6 +31,7 @@ import (
"github.com/tedsuo/ifrit"
"github.com/tedsuo/ifrit/ginkgomon"
"github.com/tedsuo/ifrit/grouper"
yaml
"gopkg.in/yaml.v2"
)
// Organization models information about an Organization. It includes
...
...
@@ -246,6 +248,29 @@ func (n *Network) OrdererConfigPath(o *Orderer) string {
return
filepath
.
Join
(
n
.
OrdererDir
(
o
),
"orderer.yaml"
)
}
// ReadOrdererConfig unmarshals an orderer's orderer.yaml and returns an
// object approximating its contents.
func
(
n
*
Network
)
ReadOrdererConfig
(
o
*
Orderer
)
*
fabricconfig
.
Orderer
{
var
orderer
fabricconfig
.
Orderer
ordererBytes
,
err
:=
ioutil
.
ReadFile
(
n
.
OrdererConfigPath
(
o
))
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
err
=
yaml
.
Unmarshal
(
ordererBytes
,
&
orderer
)
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
return
&
orderer
}
// WriteOrdererConfig serializes the provided configuration as the specified
// orderer's orderer.yaml document.
func
(
n
*
Network
)
WriteOrdererConfig
(
o
*
Orderer
,
config
*
fabricconfig
.
Orderer
)
{
ordererBytes
,
err
:=
yaml
.
Marshal
(
config
)
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
err
=
ioutil
.
WriteFile
(
n
.
OrdererConfigPath
(
o
),
ordererBytes
,
0644
)
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
}
// PeerDir returns the path to the configuration directory for the specified
// Peer.
func
(
n
*
Network
)
PeerDir
(
p
*
Peer
)
string
{
...
...
@@ -258,6 +283,29 @@ func (n *Network) PeerConfigPath(p *Peer) string {
return
filepath
.
Join
(
n
.
PeerDir
(
p
),
"core.yaml"
)
}
// ReadPeerConfig unmarshals a peer's core.yaml and returns an object
// approximating its contents.
func
(
n
*
Network
)
ReadPeerConfig
(
p
*
Peer
)
*
fabricconfig
.
Core
{
var
core
fabricconfig
.
Core
coreBytes
,
err
:=
ioutil
.
ReadFile
(
n
.
PeerConfigPath
(
p
))
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
err
=
yaml
.
Unmarshal
(
coreBytes
,
&
core
)
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
return
&
core
}
// WritePeerConfig serializes the provided configuration as the specified
// peer's core.yaml document.
func
(
n
*
Network
)
WritePeerConfig
(
p
*
Peer
,
config
*
fabricconfig
.
Core
)
{
coreBytes
,
err
:=
yaml
.
Marshal
(
config
)
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
err
=
ioutil
.
WriteFile
(
n
.
PeerConfigPath
(
p
),
coreBytes
,
0644
)
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
}
// PeerUserMSPDir returns the path to the MSP directory containing the
// certificates and keys for the specified user of the peer.
func
(
n
*
Network
)
PeerUserMSPDir
(
p
*
Peer
,
user
string
)
string
{
...
...
integration/pluggable/pluggable_test.go
View file @
299e286c
...
...
@@ -21,7 +21,6 @@ import (
"github.com/onsi/gomega/gbytes"
"github.com/onsi/gomega/gexec"
"github.com/tedsuo/ifrit"
yaml
"gopkg.in/yaml.v2"
"github.com/hyperledger/fabric/integration/nwo"
"github.com/hyperledger/fabric/integration/nwo/commands"
...
...
@@ -139,24 +138,14 @@ func compilePlugin(pluginType string) string {
func
configurePlugins
(
network
*
nwo
.
Network
,
endorsement
,
validation
string
)
{
for
_
,
p
:=
range
network
.
Peers
{
var
core
fabricconfig
.
Core
coreBytes
,
err
:=
ioutil
.
ReadFile
(
network
.
PeerConfigPath
(
p
))
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
err
=
yaml
.
Unmarshal
(
coreBytes
,
&
core
)
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
core
:=
network
.
ReadPeerConfig
(
p
)
core
.
Peer
.
Handlers
.
Endorsers
=
fabricconfig
.
HandlerMap
{
"escc"
:
fabricconfig
.
Handler
{
Name
:
"plugin-escc"
,
Library
:
endorsement
},
}
core
.
Peer
.
Handlers
.
Validators
=
fabricconfig
.
HandlerMap
{
"vscc"
:
fabricconfig
.
Handler
{
Name
:
"plugin-vscc"
,
Library
:
validation
},
}
coreBytes
,
err
=
yaml
.
Marshal
(
core
)
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
err
=
ioutil
.
WriteFile
(
network
.
PeerConfigPath
(
p
),
coreBytes
,
0644
)
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
network
.
WritePeerConfig
(
p
,
core
)
}
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment