Skip to content

Commit ad38958

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 ad38958

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-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: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ package protoutil
99
import (
1010
"github.com/hyperledger-labs/fabric-smart-client/pkg/utils/proto"
1111
"github.com/hyperledger/fabric-protos-go-apiv2/common"
12+
cb "github.com/hyperledger/fabric-protos-go-apiv2/common"
1213
"github.com/hyperledger/fabric-protos-go-apiv2/msp"
1314
"github.com/hyperledger/fabric-protos-go-apiv2/peer"
1415
"github.com/hyperledger/fabric/protoutil"
@@ -198,3 +199,13 @@ func UnmarshalBlock(encoded []byte) (*common.Block, error) {
198199
func ComputeTxID(nonce, creator []byte) string {
199200
return protoutil.ComputeTxID(nonce, creator)
200201
}
202+
203+
// UnmarshalConfigEnvelope attempts to unmarshal bytes to a *cb.ConfigEnvelope
204+
func UnmarshalConfigEnvelope(data []byte) (*cb.ConfigEnvelope, error) {
205+
configEnv := &cb.ConfigEnvelope{}
206+
err := proto.Unmarshal(data, configEnv)
207+
if err != nil {
208+
return nil, err
209+
}
210+
return configEnv, nil
211+
}

0 commit comments

Comments
 (0)