forked from s7techlab/hlf-sdk-go
/
discovery.go
44 lines (36 loc) · 1.3 KB
/
discovery.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
package api
import (
"github.com/hyperledger/fabric-protos-go/peer"
"github.com/kukgini/hlf-sdk-go-2/api/config"
)
const (
CCTypeGoLang = `golang`
)
type DiscoveryProviderOpts map[string]interface{}
type DiscoveryProvider interface {
Initialize(opts config.DiscoveryConfigOpts, pool PeerPool) (DiscoveryProvider, error)
Channels() ([]DiscoveryChannel, error)
Channel(channelName string) (*DiscoveryChannel, error)
Chaincode(channelName string, ccName string) (*DiscoveryChaincode, error)
Chaincodes(channelName string) ([]DiscoveryChaincode, error)
}
type DiscoveryChannel struct {
Name string `json:"channel_name" yaml:"name"`
Description string `json:"channel_description" yaml:"description"`
Chaincodes []DiscoveryChaincode `json:"chaincodes" yaml:"description"`
Orderers []config.ConnectionConfig `json:"orderers" yaml:"orderers"`
}
type DiscoveryChaincode struct {
Name string `json:"chaincode_name" yaml:"name"`
Type string `json:"type"`
Version string `json:"version"`
Description string `json:"description"`
Policy string `json:"policy"`
}
func (c DiscoveryChaincode) GetFabricType() peer.ChaincodeSpec_Type {
switch c.Type {
case CCTypeGoLang:
return peer.ChaincodeSpec_GOLANG
}
return peer.ChaincodeSpec_UNDEFINED
}