Skip to content

Commit

Permalink
[FAB-6070] Add orderer capabilities structures
Browse files Browse the repository at this point in the history
Certain capabilities may be required of the orderer which are not
required by the rest of the system.  For instance, changing the way a
channel creation request is validated would have an affect on ordering,
but should not have an effect on processing by the peer.  This CR adds
structures to support this.

Change-Id: I4a94a1b8f657f0b56296801672a02717d2162f9a
Signed-off-by: Jason Yellick <jyellick@us.ibm.com>
  • Loading branch information
Jason Yellick committed Sep 28, 2017
1 parent ed2912c commit 79a0119
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
3 changes: 3 additions & 0 deletions common/capabilities/capabilities_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ func TestSatisfied(t *testing.T) {
var capsMap map[string]*cb.Capability
for _, provider := range []*registry{
NewChannelProvider(capsMap).registry,
NewOrdererProvider(capsMap).registry,
} {
assert.Nil(t, provider.Supported())
}
Expand All @@ -40,6 +41,7 @@ func TestSatisfied(t *testing.T) {
}
for _, provider := range []*registry{
NewChannelProvider(capsMap).registry,
NewOrdererProvider(capsMap).registry,
} {
assert.Nil(t, provider.Supported())
}
Expand All @@ -54,6 +56,7 @@ func TestNotSatisfied(t *testing.T) {
}
for _, provider := range []*registry{
NewChannelProvider(capsMap).registry,
NewOrdererProvider(capsMap).registry,
} {
assert.Error(t, provider.Supported())
}
Expand Down
41 changes: 41 additions & 0 deletions common/capabilities/orderer.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
Copyright IBM Corp. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/

package capabilities

import (
cb "github.com/hyperledger/fabric/protos/common"
)

const (
ordererTypeName = "Orderer"
)

// OrdererProvider provides capabilities information for orderer level config.
type OrdererProvider struct {
*registry
}

// NewOrdererProvider creates an orderer capabilities provider.
func NewOrdererProvider(capabilities map[string]*cb.Capability) *OrdererProvider {
cp := &OrdererProvider{}
cp.registry = newRegistry(cp, capabilities)
return cp
}

// Type returns a descriptive string for logging purposes.
func (cp *OrdererProvider) Type() string {
return ordererTypeName
}

// HasCapability returns true if the capability is supported by this binary.
func (cp *OrdererProvider) HasCapability(capability string) bool {
switch capability {
// Add new capability names here
default:
return false
}
}

0 comments on commit 79a0119

Please sign in to comment.