This repository has been archived by the owner on Apr 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
/
orderer.go
125 lines (100 loc) · 3.59 KB
/
orderer.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
/*
Copyright IBM Corp. 2016 All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/
package config
import (
"time"
"github.com/hyperledger/fabric/common/channelconfig"
ab "github.com/hyperledger/fabric/protos/orderer"
)
// Orderer is a mock implementation of channelconfig.Orderer
type Orderer struct {
// ConsensusTypeVal is returned as the result of ConsensusType()
ConsensusTypeVal string
// ConsensusMetadataVal is returned as the result of ConsensusMetadata()
ConsensusMetadataVal []byte
// ConsensusTypeStateVal is returned as the result of ConsensusState()
ConsensusTypeStateVal ab.ConsensusType_State
// BatchSizeVal is returned as the result of BatchSize()
BatchSizeVal *ab.BatchSize
// BatchTimeoutVal is returned as the result of BatchTimeout()
BatchTimeoutVal time.Duration
// KafkaBrokersVal is returned as the result of KafkaBrokers()
KafkaBrokersVal []string
// MaxChannelsCountVal is returns as the result of MaxChannelsCount()
MaxChannelsCountVal uint64
// OrganizationsVal is returned as the result of Organizations()
OrganizationsVal map[string]channelconfig.OrdererOrg
// CapabilitiesVal is returned as the result of Capabilities()
CapabilitiesVal channelconfig.OrdererCapabilities
}
// ConsensusType returns the ConsensusTypeVal
func (o *Orderer) ConsensusType() string {
return o.ConsensusTypeVal
}
// ConsensusMetadata returns the ConsensusMetadataVal
func (o *Orderer) ConsensusMetadata() []byte {
return o.ConsensusMetadataVal
}
// ConsensusState returns the ConsensusTypeStateVal
func (o *Orderer) ConsensusState() ab.ConsensusType_State {
return o.ConsensusTypeStateVal
}
// BatchSize returns the BatchSizeVal
func (o *Orderer) BatchSize() *ab.BatchSize {
return o.BatchSizeVal
}
// BatchTimeout returns the BatchTimeoutVal
func (o *Orderer) BatchTimeout() time.Duration {
return o.BatchTimeoutVal
}
// KafkaBrokers returns the KafkaBrokersVal
func (o *Orderer) KafkaBrokers() []string {
return o.KafkaBrokersVal
}
// MaxChannelsCount returns the MaxChannelsCountVal
func (o *Orderer) MaxChannelsCount() uint64 {
return o.MaxChannelsCountVal
}
// Organizations returns OrganizationsVal
func (o *Orderer) Organizations() map[string]channelconfig.OrdererOrg {
return o.OrganizationsVal
}
// Capabilities returns CapabilitiesVal
func (o *Orderer) Capabilities() channelconfig.OrdererCapabilities {
return o.CapabilitiesVal
}
// OrdererCapabilities mocks the channelconfig.OrdererCapabilities interface
type OrdererCapabilities struct {
// SupportedErr is returned by Supported()
SupportedErr error
// PredictableChannelTemplateVal is returned by PredictableChannelTemplate()
PredictableChannelTemplateVal bool
// ResubmissionVal is returned by Resubmission()
ResubmissionVal bool
// ExpirationVal is returned by ExpirationCheck()
ExpirationVal bool
ConsensusTypeMigrationVal bool
}
// Supported returns SupportedErr
func (oc *OrdererCapabilities) Supported() error {
return oc.SupportedErr
}
// PredictableChannelTemplate returns PredictableChannelTemplateVal
func (oc *OrdererCapabilities) PredictableChannelTemplate() bool {
return oc.PredictableChannelTemplateVal
}
// Resubmission returns ResubmissionVal
func (oc *OrdererCapabilities) Resubmission() bool {
return oc.ResubmissionVal
}
// ExpirationCheck specifies whether the orderer checks for identity expiration checks
// when validating messages
func (oc *OrdererCapabilities) ExpirationCheck() bool {
return oc.ExpirationVal
}
// ConsensusTypeMigration checks whether the orderer permits a consensus-type migration.
func (oc *OrdererCapabilities) ConsensusTypeMigration() bool {
return oc.ConsensusTypeMigrationVal
}