-
Notifications
You must be signed in to change notification settings - Fork 8.9k
/
channel.go
59 lines (49 loc) · 1.36 KB
/
channel.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/*
Copyright IBM Corp. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/
package capabilities
import (
"github.com/hyperledger/fabric/msp"
cb "github.com/hyperledger/fabric/protos/common"
)
const (
channelTypeName = "Channel"
// ChannelV1_1 is the capabilties string for standard new non-backwards compatible fabric v1.1 channel capabilities.
ChannelV1_1 = "V1_1"
)
// ChannelProvider provides capabilities information for channel level config.
type ChannelProvider struct {
*registry
v11 bool
}
// NewChannelProvider creates a channel capabilities provider.
func NewChannelProvider(capabilities map[string]*cb.Capability) *ChannelProvider {
cp := &ChannelProvider{}
cp.registry = newRegistry(cp, capabilities)
_, cp.v11 = capabilities[ChannelV1_1]
return cp
}
// Type returns a descriptive string for logging purposes.
func (cp *ChannelProvider) Type() string {
return channelTypeName
}
// HasCapability returns true if the capability is supported by this binary.
func (cp *ChannelProvider) HasCapability(capability string) bool {
switch capability {
// Add new capability names here
case ChannelV1_1:
return true
default:
return false
}
}
// MSPVersion returns the level of MSP support required by this channel.
func (cp *ChannelProvider) MSPVersion() msp.MSPVersion {
switch {
case cp.v11:
return msp.MSPv1_1
default:
return msp.MSPv1_0
}
}