@@ -22,6 +22,7 @@ import (
22
22
"reflect"
23
23
"regexp"
24
24
25
+ "github.com/hyperledger/fabric/common/configtx/api"
25
26
"github.com/hyperledger/fabric/common/policies"
26
27
cb "github.com/hyperledger/fabric/protos/common"
27
28
"github.com/hyperledger/fabric/protos/utils"
41
42
}
42
43
)
43
44
44
- // Handler provides a hook which allows other pieces of code to participate in config proposals
45
- type Handler interface {
46
- // BeginConfig called when a config proposal is begun
47
- BeginConfig ()
48
-
49
- // RollbackConfig called when a config proposal is abandoned
50
- RollbackConfig ()
51
-
52
- // CommitConfig called when a config proposal is committed
53
- CommitConfig ()
54
-
55
- // ProposeConfig called when config is added to a proposal
56
- ProposeConfig (configItem * cb.ConfigItem ) error
57
- }
58
-
59
- // Manager provides a mechanism to query and update config
60
- type Manager interface {
61
- Resources
62
-
63
- // Apply attempts to apply a configtx to become the new config
64
- Apply (configtx * cb.ConfigEnvelope ) error
65
-
66
- // Validate attempts to validate a new configtx against the current config state
67
- Validate (configtx * cb.ConfigEnvelope ) error
68
-
69
- // ChainID retrieves the chain ID associated with this manager
70
- ChainID () string
71
-
72
- // Sequence returns the current sequence number of the config
73
- Sequence () uint64
74
- }
75
-
76
45
// NewConfigItemPolicyKey is the ID of the policy used when no other policy can be resolved, for instance when attempting to create a new config item
77
46
const NewConfigItemPolicyKey = "NewConfigItemPolicy"
78
47
@@ -83,11 +52,11 @@ func (ap *acceptAllPolicy) Evaluate(signedData []*cb.SignedData) error {
83
52
}
84
53
85
54
type configManager struct {
86
- Initializer
55
+ api. Initializer
87
56
sequence uint64
88
57
chainID string
89
58
config map [cb.ConfigItem_ConfigType ]map [string ]* cb.ConfigItem
90
- callOnUpdate []func (Manager )
59
+ callOnUpdate []func (api. Manager )
91
60
}
92
61
93
62
// computeChainIDAndSequence returns the chain id and the sequence number for a config envelope
@@ -152,7 +121,7 @@ func validateChainID(chainID string) error {
152
121
return nil
153
122
}
154
123
155
- func NewManagerImplNext (configtx * cb.ConfigEnvelope , initializer Initializer , callOnUpdate []func (Manager )) (Manager , error ) {
124
+ func NewManagerImplNext (configtx * cb.ConfigEnvelope , initializer api. Initializer , callOnUpdate []func (api. Manager )) (api. Manager , error ) {
156
125
configNext , err := UnmarshalConfigNext (configtx .Config )
157
126
if err != nil {
158
127
return nil , err
@@ -165,7 +134,7 @@ func NewManagerImplNext(configtx *cb.ConfigEnvelope, initializer Initializer, ca
165
134
166
135
// NewManagerImpl creates a new Manager unless an error is encountered, each element of the callOnUpdate slice
167
136
// is invoked when a new config is committed
168
- func NewManagerImpl (configtx * cb.ConfigEnvelope , initializer Initializer , callOnUpdate []func (Manager )) (Manager , error ) {
137
+ func NewManagerImpl (configtx * cb.ConfigEnvelope , initializer api. Initializer , callOnUpdate []func (api. Manager )) (api. Manager , error ) {
169
138
for ctype := range cb .ConfigItem_ConfigType_name {
170
139
if _ , ok := initializer .Handlers ()[cb .ConfigItem_ConfigType (ctype )]; ! ok {
171
140
return nil , errors .New ("Must supply a handler for all known types" )
0 commit comments