-
Notifications
You must be signed in to change notification settings - Fork 8.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FAB-11478 Enable etcd/raft configuration in channel
This changeset: 1. Defines consenter metadata for the etcd/raft plugin, creates the associated metadata message factory, and registers it with the metadata factory map in protos/orderer for protolator to work. 2. Adds supports for etcd/raft configuration to the channel configuration encoder. 3. Adds an "etcdraft" section to the configtx sample YAML and the backing config structure. 4. Adds a "SampleDevModeEtcdRaft" profile preset to the configtx sample YAML. This will be consumed by integration tests. Change-Id: I7460c89fdb91e68e4217932aeed5ca41a131d47b Signed-off-by: Kostas Christidis <kostas@christidis.io>
- Loading branch information
1 parent
96492eb
commit 808093b
Showing
17 changed files
with
568 additions
and
39 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
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,53 @@ | ||
/* | ||
Copyright IBM Corp. All Rights Reserved. | ||
SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package etcdraft | ||
|
||
import ( | ||
fmt "fmt" | ||
"io/ioutil" | ||
|
||
"github.com/hyperledger/fabric/protos/orderer" | ||
|
||
"github.com/golang/protobuf/proto" | ||
) | ||
|
||
// TypeKey is the string with which this consensus implementation is identified across Fabric. | ||
const TypeKey = "etcdraft" | ||
|
||
func init() { | ||
orderer.ConsensusTypeMetadataMap[TypeKey] = ConsensusTypeMetadataFactory{} | ||
} | ||
|
||
// ConsensusTypeMetadataFactory allows this implementation's proto messages to register | ||
// their type with the orderer's proto messages. This is needed for protolator to work. | ||
type ConsensusTypeMetadataFactory struct{} | ||
|
||
// NewMessage implements the Orderer.ConsensusTypeMetadataFactory interface. | ||
func (dogf ConsensusTypeMetadataFactory) NewMessage() proto.Message { | ||
return &Metadata{} | ||
} | ||
|
||
// Marshal serializes this implementation's proto messages. It is called by the encoder package | ||
// during the creation of the Orderer ConfigGroup. | ||
func Marshal(md *Metadata) ([]byte, error) { | ||
for _, c := range md.Consenters { | ||
// Expect the user to set the config value for client/server certs to the | ||
// path where they are persisted locally, then load these files to memory. | ||
clientCert, err := ioutil.ReadFile(string(c.GetClientTlsCert())) | ||
if err != nil { | ||
return nil, fmt.Errorf("cannot load client cert for consenter %s:%d: %s", c.GetHost(), c.GetPort(), err) | ||
} | ||
c.ClientTlsCert = clientCert | ||
|
||
serverCert, err := ioutil.ReadFile(string(c.GetServerTlsCert())) | ||
if err != nil { | ||
return nil, fmt.Errorf("cannot load server cert for consenter %s:%d: %s", c.GetHost(), c.GetPort(), err) | ||
} | ||
c.ServerTlsCert = serverCert | ||
} | ||
return proto.Marshal(md) | ||
} |
Oops, something went wrong.