generate-work-rpc at [a0b0b2d10b]

File examples/generate-work-rpc/generate-work-rpc artifact 727a1db77d part of check-in a0b0b2d10b


#! /usr/bin/env tclsh

package require nano

if {[llength $argv] < 2} {
	puts stderr "Usage: generate-work-rpc <rpcURL> <hash>..."

	exit 1
}

set rpcURL [lindex $argv 0]
set argv [lrange $argv 1 end]

package require http 2
::nano::rpc::client::init url $rpcURL

foreach arg $argv {
	if {[catch {
		set work [::nano::rpc::client work_generate -hash $arg -use_peers true]
		set work [dict get $work work]
	} err]} {
		puts stderr "Error generating work for \"$arg\": $err"
	} else {
		puts "WORK($arg) = $work"
	}
}