Skip to content

Commit 79a0119

Browse files
author
Jason Yellick
committed
[FAB-6070] Add orderer capabilities structures
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>
1 parent ed2912c commit 79a0119

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed

common/capabilities/capabilities_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ func TestSatisfied(t *testing.T) {
2424
var capsMap map[string]*cb.Capability
2525
for _, provider := range []*registry{
2626
NewChannelProvider(capsMap).registry,
27+
NewOrdererProvider(capsMap).registry,
2728
} {
2829
assert.Nil(t, provider.Supported())
2930
}
@@ -40,6 +41,7 @@ func TestSatisfied(t *testing.T) {
4041
}
4142
for _, provider := range []*registry{
4243
NewChannelProvider(capsMap).registry,
44+
NewOrdererProvider(capsMap).registry,
4345
} {
4446
assert.Nil(t, provider.Supported())
4547
}
@@ -54,6 +56,7 @@ func TestNotSatisfied(t *testing.T) {
5456
}
5557
for _, provider := range []*registry{
5658
NewChannelProvider(capsMap).registry,
59+
NewOrdererProvider(capsMap).registry,
5760
} {
5861
assert.Error(t, provider.Supported())
5962
}

common/capabilities/orderer.go

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
Copyright IBM Corp. All Rights Reserved.
3+
4+
SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
package capabilities
8+
9+
import (
10+
cb "github.com/hyperledger/fabric/protos/common"
11+
)
12+
13+
const (
14+
ordererTypeName = "Orderer"
15+
)
16+
17+
// OrdererProvider provides capabilities information for orderer level config.
18+
type OrdererProvider struct {
19+
*registry
20+
}
21+
22+
// NewOrdererProvider creates an orderer capabilities provider.
23+
func NewOrdererProvider(capabilities map[string]*cb.Capability) *OrdererProvider {
24+
cp := &OrdererProvider{}
25+
cp.registry = newRegistry(cp, capabilities)
26+
return cp
27+
}
28+
29+
// Type returns a descriptive string for logging purposes.
30+
func (cp *OrdererProvider) Type() string {
31+
return ordererTypeName
32+
}
33+
34+
// HasCapability returns true if the capability is supported by this binary.
35+
func (cp *OrdererProvider) HasCapability(capability string) bool {
36+
switch capability {
37+
// Add new capability names here
38+
default:
39+
return false
40+
}
41+
}

0 commit comments

Comments
 (0)