Skip to content

Commit

Permalink
[FAB-2693] (PA) Move identities.proto to proto/msp
Browse files Browse the repository at this point in the history
This is intended for (PA) post-alpha.

https://jira.hyperledger.org/browse/FAB-2693

For some reason, identities.proto is still in fabric/msp rather than in
protos/msp/.  This CR fixes this bug.

Change-Id: I3b337af8f4302866fbeb73d3a7fc5f8f586d5c37
Signed-off-by: Jason Yellick <jyellick@us.ibm.com>
  • Loading branch information
Jason Yellick committed Mar 22, 2017
1 parent 5b59e06 commit 76eedc8
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 49 deletions.
5 changes: 3 additions & 2 deletions core/peer/peer.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import (
"github.com/hyperledger/fabric/msp"
mspmgmt "github.com/hyperledger/fabric/msp/mgmt"
"github.com/hyperledger/fabric/protos/common"
mspprotos "github.com/hyperledger/fabric/protos/msp"
pb "github.com/hyperledger/fabric/protos/peer"
"github.com/hyperledger/fabric/protos/utils"
"github.com/op/go-logging"
Expand Down Expand Up @@ -368,7 +369,7 @@ func buildTrustedRootsForChain(cm configtxapi.Manager) {
for _, root := range v.GetRootCerts() {
sid, err := root.Serialize()
if err == nil {
id := &msp.SerializedIdentity{}
id := &mspprotos.SerializedIdentity{}
err = proto.Unmarshal(sid, id)
if err == nil {
appRootCAs = append(appRootCAs, id.IdBytes)
Expand All @@ -378,7 +379,7 @@ func buildTrustedRootsForChain(cm configtxapi.Manager) {
for _, intermediate := range v.GetIntermediateCerts() {
sid, err := intermediate.Serialize()
if err == nil {
id := &msp.SerializedIdentity{}
id := &mspprotos.SerializedIdentity{}
err = proto.Unmarshal(sid, id)
if err == nil {
appRootCAs = append(appRootCAs, id.IdBytes)
Expand Down
5 changes: 3 additions & 2 deletions msp/identities.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
"github.com/hyperledger/fabric/bccsp"
"github.com/hyperledger/fabric/bccsp/signer"
"github.com/hyperledger/fabric/protos/common"
"github.com/hyperledger/fabric/protos/msp"
"github.com/op/go-logging"
)

Expand Down Expand Up @@ -86,7 +87,7 @@ func (id *identity) GetOrganizationalUnits() []string {
func NewSerializedIdentity(mspID string, certPEM []byte) ([]byte, error) {
// We serialize identities by prepending the MSPID
// and appending the x509 cert in PEM format
sId := &SerializedIdentity{Mspid: mspID, IdBytes: certPEM}
sId := &msp.SerializedIdentity{Mspid: mspID, IdBytes: certPEM}
raw, err := proto.Marshal(sId)
if err != nil {
return nil, fmt.Errorf("Failed serializing identity [%s][% X]: [%s]", mspID, certPEM, err)
Expand Down Expand Up @@ -143,7 +144,7 @@ func (id *identity) Serialize() ([]byte, error) {
}

// We serialize identities by prepending the MSPID and appending the ASN.1 DER content of the cert
sId := &SerializedIdentity{Mspid: id.id.Mspid, IdBytes: pemBytes}
sId := &msp.SerializedIdentity{Mspid: id.id.Mspid, IdBytes: pemBytes}
idBytes, err := proto.Marshal(sId)
if err != nil {
return nil, fmt.Errorf("Could not marshal a SerializedIdentity structure for identity %s, err %s", id.id, err)
Expand Down
4 changes: 2 additions & 2 deletions msp/msp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ func TestSerializeIdentitiesWithWrongMSP(t *testing.T) {
return
}

sid := &SerializedIdentity{}
sid := &msp.SerializedIdentity{}
err = proto.Unmarshal(serializedID, sid)
assert.NoError(t, err)

Expand Down Expand Up @@ -159,7 +159,7 @@ func TestSerializeIdentitiesWithMSPManager(t *testing.T) {
_, err = mspMgr.DeserializeIdentity(serializedID)
assert.NoError(t, err)

sid := &SerializedIdentity{}
sid := &msp.SerializedIdentity{}
err = proto.Unmarshal(serializedID, sid)
assert.NoError(t, err)

Expand Down
2 changes: 1 addition & 1 deletion msp/mspimpl.go
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ func (msp *bccspmsp) DeserializeIdentity(serializedID []byte) (Identity, error)
mspLogger.Infof("Obtaining identity")

// We first deserialize to a SerializedIdentity to get the MSP ID
sId := &SerializedIdentity{}
sId := &m.SerializedIdentity{}
err := proto.Unmarshal(serializedID, sId)
if err != nil {
return nil, fmt.Errorf("Could not deserialize a SerializedIdentity, err %s", err)
Expand Down
4 changes: 3 additions & 1 deletion msp/mspmgrimpl.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ package msp
import (
"fmt"

"github.com/hyperledger/fabric/protos/msp"

"github.com/golang/protobuf/proto"
"github.com/op/go-logging"
)
Expand Down Expand Up @@ -84,7 +86,7 @@ func (mgr *mspManagerImpl) GetMSPs() (map[string]MSP, error) {
// DeserializeIdentity returns an identity given its serialized version supplied as argument
func (mgr *mspManagerImpl) DeserializeIdentity(serializedID []byte) (Identity, error) {
// We first deserialize to a SerializedIdentity to get the MSP ID
sId := &SerializedIdentity{}
sId := &msp.SerializedIdentity{}
err := proto.Unmarshal(serializedID, sId)
if err != nil {
return nil, fmt.Errorf("Could not deserialize a SerializedIdentity, err %s", err)
Expand Down
34 changes: 20 additions & 14 deletions msp/identities.pb.go → protos/msp/identities.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion msp/identities.proto → protos/msp/identities.proto
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ limitations under the License.

syntax = "proto3";

option go_package = "github.com/hyperledger/fabric/msp";
option go_package = "github.com/hyperledger/fabric/protos/msp";

package msp;

Expand Down
33 changes: 7 additions & 26 deletions protos/msp/mspconfig.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 76eedc8

Please sign in to comment.