/
capability_checker.go
31 lines (25 loc) · 876 Bytes
/
capability_checker.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
/*
Copyright IBM Corp. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/
package server
import (
"github.com/hyperledger/fabric/core/peer"
"github.com/pkg/errors"
)
//go:generate counterfeiter -o mock/capability_checker.go -fake-name CapabilityChecker . CapabilityChecker
// CapabilityChecker is used to check whether or not a channel supports token functions.
type CapabilityChecker interface {
FabToken(channelId string) (bool, error)
}
// TokenCapabilityChecker implements CapabilityChecker interface
type TokenCapabilityChecker struct {
PeerOps peer.Operations
}
func (c *TokenCapabilityChecker) FabToken(channelId string) (bool, error) {
ac, ok := c.PeerOps.GetChannelConfig(channelId).ApplicationConfig()
if !ok {
return false, errors.Errorf("no application config found for channel %s", channelId)
}
return ac.Capabilities().FabToken(), nil
}