From abb9076c23adad1d050e22865ec51204daab4573 Mon Sep 17 00:00:00 2001 From: Gabor Hosszu Date: Tue, 9 Aug 2016 16:33:43 +0200 Subject: [PATCH] Use unique ID for queries and if no other specified Change-Id: Ib464c164661f76cb24e5d67cf9993a9b3df27912 Signed-off-by: Gabor Hosszu --- core/devops.go | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/core/devops.go b/core/devops.go index 894e10828dd..3b65c01ddbe 100644 --- a/core/devops.go +++ b/core/devops.go @@ -213,13 +213,21 @@ func (d *Devops) invokeOrQuery(ctx context.Context, chaincodeInvocationSpec *pb. var customIDgenAlg = strings.ToLower(chaincodeInvocationSpec.IdGenerationAlg) var id string var generr error - ctorbytes, merr := proto.Marshal(chaincodeInvocationSpec.ChaincodeSpec.CtorMsg) - if merr != nil { - return nil, fmt.Errorf("Error marshalling constructor: %s", merr) - } - id, generr = util.GenerateIDWithAlg(customIDgenAlg, ctorbytes) - if generr != nil { - return nil, generr + if invoke { + if customIDgenAlg != "" { + ctorbytes, merr := proto.Marshal(chaincodeInvocationSpec.ChaincodeSpec.CtorMsg) + if merr != nil { + return nil, fmt.Errorf("Error marshalling constructor: %s", merr) + } + id, generr = util.GenerateIDWithAlg(customIDgenAlg, ctorbytes) + if generr != nil { + return nil, generr + } + } else { + id = util.GenerateUUID() + } + } else { + id = util.GenerateUUID() } devopsLogger.Infof("Transaction ID: %v", id) var transaction *pb.Transaction