Skip to content

Commit

Permalink
Emergency update for busywork
Browse files Browse the repository at this point in the history
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 <bcbrock@us.ibm.com>
  • Loading branch information
bcbrock committed Aug 15, 2016
1 parent 457635a commit 9d197c0
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 25 deletions.
14 changes: 6 additions & 8 deletions tools/busywork/bin/fabricLogger
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ piece of information:

b <n> : Block number <n>
d <ccid> : A chaincode deployment. The <ccid> is the chaincode ID.
i <uuid> : A chaincode invocation. The <uuid> is the transaction UUID.
i <txid> : A chaincode invocation. The <txid> is the transaction ID.

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

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

if {[catch {dict get $tx type} type]} {
err {} \
"$peer @ block $block: " \
"Error parsing type field: $type"
forceBreakOrErrorExit $token
}
if {[catch {dict get $tx uuid} uuid]} {
if {[catch {dict get $tx txid} txid]} {
err {} "$peer @ block $block: " \
"Error parsing uuid field: $uuid"
"Error parsing txid field: $txid"
forceBreakOrErrorExit $token
}
switch $type {
1 {
puts $log "d $uuid"
puts $log "d $txid"
}
2 {
puts $log "i $uuid"
puts $log "i $txid"
}
default {
err {} "$peer @ block $block: " \
Expand Down
32 changes: 15 additions & 17 deletions tools/busywork/tcl/fabric.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -159,14 +159,13 @@ proc ::fabric::deploy {i_peer i_user i_chaincode i_fn i_args {i_retry 0}} {
"path" : "$i_chaincode"
},
"ctorMsg" : {
"function" : "$i_fn",
"args" : [$args]
},
"secureContext": "$i_user"
}
}

set args [argify $i_args]
set args [argify $i_fn $i_args]
set query [subst -nocommand $template]

return [devops $i_peer deploy $query $i_retry]
Expand All @@ -191,14 +190,13 @@ proc ::fabric::devModeDeploy {i_peer i_user i_chaincode i_fn i_args {i_retry 0}}
"name" : "$i_chaincode"
},
"ctorMsg" : {
"function" : "$i_fn",
"args" : [$args]
},
"secureContext": "$i_user"
}
}

set args [argify $i_args]
set args [argify $i_fn $i_args]
set query [subst -nocommand $template]

return [devops $i_peer deploy $query $i_retry]
Expand Down Expand Up @@ -227,15 +225,14 @@ proc ::fabric::invoke {i_peer i_user i_chaincodeName i_fn i_args {i_retry 0}} {
"name" : "$i_chaincodeName"
},
"ctorMsg" : {
"function" : "$i_fn",
"args" : [$args]
},
"secureContext": "$i_user"
}
}
}

set args [argify $i_args]
set args [argify $i_fn $i_args]
set query [subst -nocommand $template]

return [devops $i_peer invoke $query $i_retry]
Expand Down Expand Up @@ -265,15 +262,14 @@ proc ::fabric::query {i_peer i_user i_chaincodeName i_fn i_args {i_retry 0}} {
"name" : "$i_chaincodeName"
},
"ctorMsg" : {
"function" : "$i_fn",
"args" : [$args]
},
"secureContext": "$i_user"
}
}
}

set args [argify $i_args]
set args [argify $i_fn $i_args]
set query [subst -nocommand $template]

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


############################################################################
# argify i_args
# argify i_fn i_args

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

proc ::fabric::argify {i_args} {
proc ::fabric::argify {i_fn i_args} {

set args ""
set args [concat $i_fn $i_args]
set args64 ""
set comma ""
foreach arg $i_args {
set args "$args$comma\"$arg\""
foreach arg $args {
set args64 "$args64$comma\"[binary encode base64 $arg]\""
set comma ,
}
return $args
return $args64
}

0 comments on commit 9d197c0

Please sign in to comment.