Skip to content

Commit 9d197c0

Browse files
author
bcbrock
committed
Emergency update for busywork
Due to recent changes in APIs etc., busywork does not work with the current fabric. In the fabricLogger, changed "uuid" to "txid" to match the new protos. In the Tcl library, changed the code to support the new REST API that now simply takes a single list of base64 arguments for invoke and query. Change-Id: I78b8f4343294190c404a1e52a926019c8ad52ae1 Signed-off-by: Bishop Brock <[email protected]>
1 parent 457635a commit 9d197c0

File tree

2 files changed

+21
-25
lines changed

2 files changed

+21
-25
lines changed

tools/busywork/bin/fabricLogger

+6-8
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ piece of information:
2828

2929
b <n> : Block number <n>
3030
d <ccid> : A chaincode deployment. The <ccid> is the chaincode ID.
31-
i <uuid> : A chaincode invocation. The <uuid> is the transaction UUID.
31+
i <txid> : A chaincode invocation. The <txid> is the transaction ID.
3232

3333
Note that the block number is printed _after_ all of the block transactions,
3434
to validate to a 'following' client that all transactions of a block have been
@@ -335,27 +335,25 @@ while {1} {
335335
foreach tx $transactions {
336336

337337
# The chaincodeID comes back as bytes so that it can be
338-
# encrypted. We don't log it or the timestamp now. The
339-
# "UUID" for type 1 (deploy) transactions is actually the
340-
# chaincode name.
338+
# encrypted. We don't log it or the timestamp now.
341339

342340
if {[catch {dict get $tx type} type]} {
343341
err {} \
344342
"$peer @ block $block: " \
345343
"Error parsing type field: $type"
346344
forceBreakOrErrorExit $token
347345
}
348-
if {[catch {dict get $tx uuid} uuid]} {
346+
if {[catch {dict get $tx txid} txid]} {
349347
err {} "$peer @ block $block: " \
350-
"Error parsing uuid field: $uuid"
348+
"Error parsing txid field: $txid"
351349
forceBreakOrErrorExit $token
352350
}
353351
switch $type {
354352
1 {
355-
puts $log "d $uuid"
353+
puts $log "d $txid"
356354
}
357355
2 {
358-
puts $log "i $uuid"
356+
puts $log "i $txid"
359357
}
360358
default {
361359
err {} "$peer @ block $block: " \

tools/busywork/tcl/fabric.tcl

+15-17
Original file line numberDiff line numberDiff line change
@@ -159,14 +159,13 @@ proc ::fabric::deploy {i_peer i_user i_chaincode i_fn i_args {i_retry 0}} {
159159
"path" : "$i_chaincode"
160160
},
161161
"ctorMsg" : {
162-
"function" : "$i_fn",
163162
"args" : [$args]
164163
},
165164
"secureContext": "$i_user"
166165
}
167166
}
168167

169-
set args [argify $i_args]
168+
set args [argify $i_fn $i_args]
170169
set query [subst -nocommand $template]
171170

172171
return [devops $i_peer deploy $query $i_retry]
@@ -191,14 +190,13 @@ proc ::fabric::devModeDeploy {i_peer i_user i_chaincode i_fn i_args {i_retry 0}}
191190
"name" : "$i_chaincode"
192191
},
193192
"ctorMsg" : {
194-
"function" : "$i_fn",
195193
"args" : [$args]
196194
},
197195
"secureContext": "$i_user"
198196
}
199197
}
200198

201-
set args [argify $i_args]
199+
set args [argify $i_fn $i_args]
202200
set query [subst -nocommand $template]
203201

204202
return [devops $i_peer deploy $query $i_retry]
@@ -227,15 +225,14 @@ proc ::fabric::invoke {i_peer i_user i_chaincodeName i_fn i_args {i_retry 0}} {
227225
"name" : "$i_chaincodeName"
228226
},
229227
"ctorMsg" : {
230-
"function" : "$i_fn",
231228
"args" : [$args]
232229
},
233230
"secureContext": "$i_user"
234231
}
235232
}
236233
}
237234

238-
set args [argify $i_args]
235+
set args [argify $i_fn $i_args]
239236
set query [subst -nocommand $template]
240237

241238
return [devops $i_peer invoke $query $i_retry]
@@ -265,15 +262,14 @@ proc ::fabric::query {i_peer i_user i_chaincodeName i_fn i_args {i_retry 0}} {
265262
"name" : "$i_chaincodeName"
266263
},
267264
"ctorMsg" : {
268-
"function" : "$i_fn",
269265
"args" : [$args]
270266
},
271267
"secureContext": "$i_user"
272268
}
273269
}
274270
}
275271

276-
set args [argify $i_args]
272+
set args [argify $i_fn $i_args]
277273
set query [subst -nocommand $template]
278274

279275
return [devops $i_peer query $query $i_retry]
@@ -432,19 +428,21 @@ proc ::fabric::caLogin {i_peer i_user i_secret} {
432428

433429

434430
############################################################################
435-
# argify i_args
431+
# argify i_fn i_args
436432

437-
# Convert a Tcl list to a list of quoted arguments with commas to satisfy the
438-
# JSON format. This needs to be done as a string (rather than as a list),
439-
# otherwise it will be {} quoted when substituted.
433+
# Convert old-style fn + args pair into a list of quoted base64 arguments with
434+
# commas to satisfy the most recent JSON format of the REST API. This needs to
435+
# be done as a string (rather than as a list), otherwise it will be {} quoted
436+
# when substituted.
440437

441-
proc ::fabric::argify {i_args} {
438+
proc ::fabric::argify {i_fn i_args} {
442439

443-
set args ""
440+
set args [concat $i_fn $i_args]
441+
set args64 ""
444442
set comma ""
445-
foreach arg $i_args {
446-
set args "$args$comma\"$arg\""
443+
foreach arg $args {
444+
set args64 "$args64$comma\"[binary encode base64 $arg]\""
447445
set comma ,
448446
}
449-
return $args
447+
return $args64
450448
}

0 commit comments

Comments
 (0)