Skip to content

Commit

Permalink
[FAB-6071] Add application capabilities structures
Browse files Browse the repository at this point in the history
Certain capabilities may be required of the peer which are completely
irrelevant to the other pieces of the system (such as the orderer).  For
instance, whether a peer may process side-DB transactions had no impact
on the orderer, because the orderer is left out of these transactions by
design.

This CR adds basic support for application/peer capabilities though none
are currently implemented.

Change-Id: I27fe1266b370b6d71791c5782bbe641c081e8f62
Signed-off-by: Jason Yellick <jyellick@us.ibm.com>
  • Loading branch information
Jason Yellick committed Sep 28, 2017
1 parent 79a0119 commit 64d1b8e
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
41 changes: 41 additions & 0 deletions common/capabilities/application.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 (
applicationTypeName = "Application"
)

// ApplicationProvider provides capabilities information for application level config.
type ApplicationProvider struct {
*registry
}

// NewApplicationProvider creates a application capabilities provider.
func NewApplicationProvider(capabilities map[string]*cb.Capability) *ApplicationProvider {
cp := &ApplicationProvider{}
cp.registry = newRegistry(cp, capabilities)
return cp
}

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

// HasCapability returns true if the capability is supported by this binary.
func (cp *ApplicationProvider) HasCapability(capability string) bool {
switch capability {
// Add new capability names here
default:
return false
}
}
3 changes: 3 additions & 0 deletions common/capabilities/capabilities_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ func TestSatisfied(t *testing.T) {
for _, provider := range []*registry{
NewChannelProvider(capsMap).registry,
NewOrdererProvider(capsMap).registry,
NewApplicationProvider(capsMap).registry,
} {
assert.Nil(t, provider.Supported())
}
Expand All @@ -42,6 +43,7 @@ func TestSatisfied(t *testing.T) {
for _, provider := range []*registry{
NewChannelProvider(capsMap).registry,
NewOrdererProvider(capsMap).registry,
NewApplicationProvider(capsMap).registry,
} {
assert.Nil(t, provider.Supported())
}
Expand All @@ -57,6 +59,7 @@ func TestNotSatisfied(t *testing.T) {
for _, provider := range []*registry{
NewChannelProvider(capsMap).registry,
NewOrdererProvider(capsMap).registry,
NewApplicationProvider(capsMap).registry,
} {
assert.Error(t, provider.Supported())
}
Expand Down

0 comments on commit 64d1b8e

Please sign in to comment.