727
728
729
730
731
732
733
734
735
736
737
738
739
740
|
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
|
+
|
set blockDict [::nano::block::dict::fromJSON $blockJSON]
tailcall ::nano::block::dict::verifySignature $blockDict
}
proc ::nano::block::dict::work {blockDict args} {
set outputMode "work"
set outputFormat "hex"
foreach arg $args {
switch -- $arg {
"-update" {
set outputMode "update"
}
"-work" {
set outputMode "work"
|
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
|
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
|
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
+
+
+
+
|
return [::nano::block::json::fromDict $blockDict]
}
return $blockDict
}
# Work generation functions
proc ::nano::work::fromWorkData {blockHashOrPublicKey} {
proc ::nano::work::fromWorkData {blockHashOrPublicKey args} {
set outputFormat "hex"
foreach arg $args {
switch -- $arg {
"-hex" {
set outputFormat "hex"
}
"-binary" {
set outputFormat "bytes"
}
default {
return -code error "Invalid option: $arg"
}
}
}
if {[string length $blockHashOrPublicKey] != $::nano::block::hashLength} {
set blockHashOrPublicKey [binary decode hex $blockHashOrPublicKey]
}
set work [binary encode hex [::nano::internal::generateWork $blockHashOrPublicKey]]
set work [string tolower $work]
set work [::nano::internal::generateWork $blockHashOrPublicKey]
if {$outputFormat eq "hex"} {
set work [binary encode hex $work]
set work [string tolower $work]
}
return $work
}
proc ::nano::work::fromBlock {blockData} {
set blockDict [::nano::block::dict::fromBlock $blockData]
set workData [dict get $blockDict _workData]
|