-
Notifications
You must be signed in to change notification settings - Fork 6
/
configtx.go
69 lines (52 loc) · 1.7 KB
/
configtx.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
/*
Copyright IBM Corp. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/
package configtx
import (
cb "github.com/hyperledger/fabric/protos/common"
)
// Validator is a mock implementation of configtx.Validator
type Validator struct {
// ChainIDVal is returned as the result of ChainID()
ChainIDVal string
// SequenceVal is returned as the result of Sequence()
SequenceVal uint64
// ApplyVal is returned by Apply
ApplyVal error
// AppliedConfigUpdateEnvelope is set by Apply
AppliedConfigUpdateEnvelope *cb.ConfigEnvelope
// ValidateVal is returned by Validate
ValidateVal error
// ProposeConfigUpdateError is returned as the error value for ProposeConfigUpdate
ProposeConfigUpdateError error
// ProposeConfigUpdateVal is returns as the value for ProposeConfigUpdate
ProposeConfigUpdateVal *cb.ConfigEnvelope
// ConfigProtoVal is returned as the value for ConfigProtoVal()
ConfigProtoVal *cb.Config
}
// ConfigProto returns the ConfigProtoVal
func (cm *Validator) ConfigProto() *cb.Config {
return cm.ConfigProtoVal
}
// ConsensusType returns the ConsensusTypeVal
func (cm *Validator) ChainID() string {
return cm.ChainIDVal
}
// BatchSize returns the BatchSizeVal
func (cm *Validator) Sequence() uint64 {
return cm.SequenceVal
}
// ProposeConfigUpdate
func (cm *Validator) ProposeConfigUpdate(update *cb.Envelope) (*cb.ConfigEnvelope, error) {
return cm.ProposeConfigUpdateVal, cm.ProposeConfigUpdateError
}
// Apply returns ApplyVal
func (cm *Validator) Apply(configEnv *cb.ConfigEnvelope) error {
cm.AppliedConfigUpdateEnvelope = configEnv
return cm.ApplyVal
}
// Validate returns ValidateVal
func (cm *Validator) Validate(configEnv *cb.ConfigEnvelope) error {
return cm.ValidateVal
}