@@ -10,8 +10,8 @@ import (
10
10
"fmt"
11
11
12
12
"github.com/hyperledger/fabric-lib-go/common/flogging"
13
- cb "github.com/hyperledger/fabric-protos-go-apiv2/common"
14
- mspa "github.com/hyperledger/fabric-protos-go-apiv2/msp"
13
+ "github.com/hyperledger/fabric-protos-go-apiv2/common"
14
+ "github.com/hyperledger/fabric-protos-go-apiv2/msp"
15
15
protosorderer "github.com/hyperledger/fabric-protos-go-apiv2/orderer"
16
16
"github.com/hyperledger/fabric-protos-go-apiv2/orderer/smartbft"
17
17
"github.com/hyperledger/fabric/common/channelconfig"
@@ -27,14 +27,14 @@ import (
27
27
28
28
// Filters applies the filters on the outer envelope
29
29
type Filters interface {
30
- ApplyFilters (channel string , env * cb .Envelope ) error
30
+ ApplyFilters (channel string , env * common .Envelope ) error
31
31
}
32
32
33
33
//go:generate mockery -dir . -name ConfigUpdateProposer -case underscore -output mocks
34
34
35
35
// ConfigUpdateProposer produces a ConfigEnvelope
36
36
type ConfigUpdateProposer interface {
37
- ProposeConfigUpdate (channel string , configtx * cb .Envelope ) (* cb .ConfigEnvelope , error )
37
+ ProposeConfigUpdate (channel string , configtx * common .Envelope ) (* common .ConfigEnvelope , error )
38
38
}
39
39
40
40
//go:generate mockery -dir . -name Bundle -case underscore -output mocks
@@ -60,7 +60,7 @@ type ConfigBlockValidator struct {
60
60
}
61
61
62
62
// ValidateConfig validates config from envelope
63
- func (cbv * ConfigBlockValidator ) ValidateConfig (envelope * cb .Envelope ) error {
63
+ func (cbv * ConfigBlockValidator ) ValidateConfig (envelope * common .Envelope ) error {
64
64
payload , err := protoutil .UnmarshalPayload (envelope .Payload )
65
65
if err != nil {
66
66
return err
@@ -80,18 +80,18 @@ func (cbv *ConfigBlockValidator) ValidateConfig(envelope *cb.Envelope) error {
80
80
}
81
81
82
82
switch chdr .Type {
83
- case int32 (cb .HeaderType_CONFIG ):
84
- configEnvelope := & cb .ConfigEnvelope {}
83
+ case int32 (common .HeaderType_CONFIG ):
84
+ configEnvelope := & common .ConfigEnvelope {}
85
85
if err = proto .Unmarshal (payload .Data , configEnvelope ); err != nil {
86
86
return fmt .Errorf ("data unmarshalling error: %s" , err )
87
87
}
88
88
return cbv .verifyConfigUpdateMsg (envelope , configEnvelope , chdr )
89
89
default :
90
- return errors .Errorf ("unexpected envelope type %s" , cb .HeaderType_name [chdr .Type ])
90
+ return errors .Errorf ("unexpected envelope type %s" , common .HeaderType_name [chdr .Type ])
91
91
}
92
92
}
93
93
94
- func (cbv * ConfigBlockValidator ) checkConsentersMatchPolicy (conf * cb .Config ) error {
94
+ func (cbv * ConfigBlockValidator ) checkConsentersMatchPolicy (conf * common .Config ) error {
95
95
if conf == nil {
96
96
return fmt .Errorf ("empty Config" )
97
97
}
@@ -116,39 +116,39 @@ func (cbv *ConfigBlockValidator) checkConsentersMatchPolicy(conf *cb.Config) err
116
116
return fmt .Errorf ("no values in 'Orderer' group" )
117
117
}
118
118
119
- ords := & cb .Orderers {}
119
+ ords := & common .Orderers {}
120
120
if err := proto .Unmarshal (conf .ChannelGroup .Groups ["Orderer" ].Values ["Orderers" ].Value , ords ); err != nil {
121
121
return err
122
122
}
123
123
124
124
n := len (ords .ConsenterMapping )
125
125
f := (n - 1 ) / 3
126
126
127
- var identities []* mspa .MSPPrincipal
128
- var pols []* cb .SignaturePolicy
127
+ var identities []* msp .MSPPrincipal
128
+ var pols []* common .SignaturePolicy
129
129
for i , consenter := range ords .ConsenterMapping {
130
130
if consenter == nil {
131
131
return fmt .Errorf ("consenter %d in the mapping is empty" , i )
132
132
}
133
- pols = append (pols , & cb .SignaturePolicy {
134
- Type : & cb .SignaturePolicy_SignedBy {
133
+ pols = append (pols , & common .SignaturePolicy {
134
+ Type : & common .SignaturePolicy_SignedBy {
135
135
SignedBy : int32 (i ),
136
136
},
137
137
})
138
- identities = append (identities , & mspa .MSPPrincipal {
139
- PrincipalClassification : mspa .MSPPrincipal_IDENTITY ,
140
- Principal : protoutil .MarshalOrPanic (& mspa .SerializedIdentity {Mspid : consenter .MspId , IdBytes : consenter .Identity }),
138
+ identities = append (identities , & msp .MSPPrincipal {
139
+ PrincipalClassification : msp .MSPPrincipal_IDENTITY ,
140
+ Principal : protoutil .MarshalOrPanic (& msp .SerializedIdentity {Mspid : consenter .MspId , IdBytes : consenter .Identity }),
141
141
})
142
142
}
143
143
144
144
quorumSize := policies .ComputeBFTQuorum (n , f )
145
- sp := & cb .SignaturePolicyEnvelope {
145
+ sp := & common .SignaturePolicyEnvelope {
146
146
Rule : policydsl .NOutOf (int32 (quorumSize ), pols ),
147
147
Identities : identities ,
148
148
}
149
149
150
- expectedConfigPol := & cb .Policy {
151
- Type : int32 (cb .Policy_SIGNATURE ),
150
+ expectedConfigPol := & common .Policy {
151
+ Type : int32 (common .Policy_SIGNATURE ),
152
152
Value : protoutil .MarshalOrPanic (sp ),
153
153
}
154
154
@@ -189,7 +189,7 @@ func (cbv *ConfigBlockValidator) checkConsentersMatchPolicy(conf *cb.Config) err
189
189
return nil
190
190
}
191
191
192
- func (cbv * ConfigBlockValidator ) verifyConfigUpdateMsg (outEnv * cb .Envelope , confEnv * cb .ConfigEnvelope , chdr * cb .ChannelHeader ) error {
192
+ func (cbv * ConfigBlockValidator ) verifyConfigUpdateMsg (outEnv * common .Envelope , confEnv * common .ConfigEnvelope , chdr * common .ChannelHeader ) error {
193
193
if confEnv == nil || confEnv .LastUpdate == nil || confEnv .Config == nil {
194
194
return errors .New ("invalid config envelope" )
195
195
}
@@ -206,7 +206,7 @@ func (cbv *ConfigBlockValidator) verifyConfigUpdateMsg(outEnv *cb.Envelope, conf
206
206
return errors .New ("inner channelheader is nil" )
207
207
}
208
208
209
- typ := cb .HeaderType (chdr .Type )
209
+ typ := common .HeaderType (chdr .Type )
210
210
211
211
cbv .Logger .Infof ("Applying filters for config update of type %s to channel %s" , typ , chdr .ChannelId )
212
212
@@ -215,7 +215,7 @@ func (cbv *ConfigBlockValidator) verifyConfigUpdateMsg(outEnv *cb.Envelope, conf
215
215
return err
216
216
}
217
217
218
- var expectedConfigEnv * cb .ConfigEnvelope
218
+ var expectedConfigEnv * common .ConfigEnvelope
219
219
channelID , err := protoutil .ChannelID (confEnv .LastUpdate )
220
220
if err != nil {
221
221
return errors .Errorf ("error extracting channel ID from config update" )
0 commit comments