/
api.go
161 lines (133 loc) · 4.82 KB
/
api.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
/*
Copyright SecureKey Technologies Inc. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/
package fab
import (
"time"
"app/service/fabric-sdk-go-gm/pkg/common/errors/retry"
"app/service/fabric-sdk-go-gm/pkg/core/config/endpoint"
)
// ClientConfig provides the definition of the client configuration
type ClientConfig struct {
Organization string
TLSCerts ClientTLSConfig
}
// ClientTLSConfig contains the client TLS configuration
type ClientTLSConfig struct {
//Client TLS information
Client endpoint.TLSKeyPair
}
// OrdererConfig defines an orderer configuration
type OrdererConfig struct {
URL string
GRPCOptions map[string]interface{}
TLSCACerts endpoint.TLSConfig
}
// PeerConfig defines a peer configuration
type PeerConfig struct {
URL string
GRPCOptions map[string]interface{}
TLSCACerts endpoint.TLSConfig
}
// OrganizationConfig provides the definition of an organization in the network
type OrganizationConfig struct {
MSPID string
CryptoPath string
Users map[string]endpoint.TLSKeyPair
Peers []string
CertificateAuthorities []string
}
// ChannelEndpointConfig provides the definition of channels for the network
type ChannelEndpointConfig struct {
// Orderers list of ordering service nodes
Orderers []string
// Peers a list of peer-channels that are part of this organization
// to get the real Peer config object, use the Name field and fetch NetworkConfig.Peers[Name]
Peers map[string]PeerChannelConfig
//Policies list of policies for channel
Policies ChannelPolicies
}
//ChannelPolicies defines list of policies defined for a channel
type ChannelPolicies struct {
//Policy for querying channel block
QueryChannelConfig QueryChannelConfigPolicy
//Policy for querying discovery
Discovery DiscoveryPolicy
//Policy for endorser selection
Selection SelectionPolicy
//Policy for event service
EventService EventServicePolicy
}
//QueryChannelConfigPolicy defines opts for channelConfigBlock
type QueryChannelConfigPolicy struct {
MinResponses int
MaxTargets int
RetryOpts retry.Opts
}
//DiscoveryPolicy defines policy for discovery
type DiscoveryPolicy struct {
MinResponses int
MaxTargets int
RetryOpts retry.Opts
}
// SelectionSortingStrategy is the endorser selection sorting strategy
type SelectionSortingStrategy string
const (
// BlockHeightPriority (default) is a load-balancing selection sorting strategy
// which also prioritizes peers at a block height that is above a certain "lag" threshold.
BlockHeightPriority SelectionSortingStrategy = "BlockHeightPriority"
// Balanced is a load-balancing selection sorting strategy
Balanced SelectionSortingStrategy = "Balanced"
)
// BalancerType is the load-balancer type
type BalancerType string
const (
// RoundRobin (default) chooses endorsers in a round-robin fashion
RoundRobin BalancerType = "RoundRobin"
// Random chooses endorsers randomly
Random BalancerType = "Random"
)
//SelectionPolicy defines policy for selection
type SelectionPolicy struct {
// SortingStrategy is the endorser sorting strategy to use
SortingStrategy SelectionSortingStrategy
// BalancerType is the balancer to use in order to load-balance calls to endorsers
Balancer BalancerType
// BlockHeightLagThreshold is the number of blocks from the highest block number of a group of peers
// that a peer can lag behind and still be considered to be up-to-date. These peers will be sorted
// using the given Balancer. If a peer's block height falls behind this threshold then it will be
// demoted to a lower priority list of peers which will be sorted according to block height.
// Note: This property only applies to BlockHeightPriority sorter
BlockHeightLagThreshold int
}
// EventServicePolicy specifies the policy for the event service
type EventServicePolicy struct {
ResolverStrategy string
MinBlockHeightResolverMode string
Balancer BalancerType
BlockHeightLagThreshold int
PeerMonitor string
ReconnectBlockHeightLagThreshold int
PeerMonitorPeriod time.Duration
}
// PeerChannelConfig defines the peer capabilities
type PeerChannelConfig struct {
EndorsingPeer bool
ChaincodeQuery bool
LedgerQuery bool
EventSource bool
}
// MatchConfig contains match pattern and substitution pattern
// for pattern matching of network configured hostnames or channel names with static config
type MatchConfig struct {
Pattern string
// these are used for hostname mapping
URLSubstitutionExp string
SSLTargetOverrideURLSubstitutionExp string
MappedHost string
// this is used for Name mapping instead of hostname mappings
MappedName string
//IgnoreEndpoint option to exclude given entity from any kind of search or from entity list
IgnoreEndpoint bool
}