Skip to content

Commit abb9076

Browse files
committed
Use unique ID for queries and if no other specified
Change-Id: Ib464c164661f76cb24e5d67cf9993a9b3df27912 Signed-off-by: Gabor Hosszu <[email protected]>
1 parent eacd0e0 commit abb9076

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

core/devops.go

+15-7
Original file line numberDiff line numberDiff line change
@@ -213,13 +213,21 @@ func (d *Devops) invokeOrQuery(ctx context.Context, chaincodeInvocationSpec *pb.
213213
var customIDgenAlg = strings.ToLower(chaincodeInvocationSpec.IdGenerationAlg)
214214
var id string
215215
var generr error
216-
ctorbytes, merr := proto.Marshal(chaincodeInvocationSpec.ChaincodeSpec.CtorMsg)
217-
if merr != nil {
218-
return nil, fmt.Errorf("Error marshalling constructor: %s", merr)
219-
}
220-
id, generr = util.GenerateIDWithAlg(customIDgenAlg, ctorbytes)
221-
if generr != nil {
222-
return nil, generr
216+
if invoke {
217+
if customIDgenAlg != "" {
218+
ctorbytes, merr := proto.Marshal(chaincodeInvocationSpec.ChaincodeSpec.CtorMsg)
219+
if merr != nil {
220+
return nil, fmt.Errorf("Error marshalling constructor: %s", merr)
221+
}
222+
id, generr = util.GenerateIDWithAlg(customIDgenAlg, ctorbytes)
223+
if generr != nil {
224+
return nil, generr
225+
}
226+
} else {
227+
id = util.GenerateUUID()
228+
}
229+
} else {
230+
id = util.GenerateUUID()
223231
}
224232
devopsLogger.Infof("Transaction ID: %v", id)
225233
var transaction *pb.Transaction

0 commit comments

Comments
 (0)