Skip to content

Commit 35a0bd4

Browse files
refactor(fabric): Move UnmarshalConfigEnvelope
This commit adds UnmarshalConfigEnvelope to our local protoutils Signed-off-by: Marcus Brandenburger <bur@zurich.ibm.com>
1 parent f10be32 commit 35a0bd4

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

platform/fabric/core/generic/membership/membership.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import (
1818
"github.com/hyperledger/fabric-lib-go/bccsp/factory"
1919
cb "github.com/hyperledger/fabric-protos-go-apiv2/common"
2020
"github.com/hyperledger/fabric/common/channelconfig"
21-
"github.com/hyperledger/fabric/common/configtx"
2221
"github.com/hyperledger/fabric/msp"
2322
)
2423

@@ -72,7 +71,7 @@ func (c *Service) validateConfig(env *cb.Envelope) (*channelconfig.Bundle, error
7271
return nil, errors.Wrapf(err, "cannot get payload from config transaction")
7372
}
7473

75-
cenv, err := configtx.UnmarshalConfigEnvelope(payload.Data)
74+
cenv, err := protoutil.UnmarshalConfigEnvelope(payload.Data)
7675
if err != nil {
7776
return nil, errors.Wrapf(err, "error unmarshalling config which passed initial validity checks")
7877
}

platform/fabric/protoutil/protoutils.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,3 +198,13 @@ func UnmarshalBlock(encoded []byte) (*common.Block, error) {
198198
func ComputeTxID(nonce, creator []byte) string {
199199
return protoutil.ComputeTxID(nonce, creator)
200200
}
201+
202+
// UnmarshalConfigEnvelope attempts to unmarshal bytes to a *cb.ConfigEnvelope
203+
func UnmarshalConfigEnvelope(data []byte) (*common.ConfigEnvelope, error) {
204+
configEnv := &common.ConfigEnvelope{}
205+
err := proto.Unmarshal(data, configEnv)
206+
if err != nil {
207+
return nil, err
208+
}
209+
return configEnv, nil
210+
}

0 commit comments

Comments
 (0)