Skip to content
Snippets Groups Projects

Write `get-file` and commands to get the list of blocks from another node

1 file
+ 6
5
Compare changes
  • Side-by-side
  • Inline
@@ -79,17 +79,18 @@ try {
print "Resuming execution\n"
print "Node 1 starts searching for the providers with the file hash"
let providers = app get-providers --node $SWARM.1.ip_port $file_hash | get 0
let provider = app get-providers --node $SWARM.1.ip_port $file_hash | get 0
print $"The providers are:"
print $providers
print $provider
print "\nNode 1 asks node 0 to provide the list of blocks it has for the file"
let received_block_list = app get-blocks-info-from --node $SWARM.1.ip_port $providers $file_hash | from json
let received_block_list = app get-blocks-info-from --node $SWARM.1.ip_port $provider $file_hash | get block_hashes
print $"The blocks node 0 has are:"
print $received_block_list
print "\nComparing to the actual block list"
print "\nComparing to the actual block list:"
assert equal ($block_hashes |sort) ($received_block_list |sort)
print "Passed ! Block lists are the same"
print "Creating the directory to receive the files"
mkdir $output_dir
@@ -98,7 +99,7 @@ try {
for $i in 0..<($received_block_list | length) {
let $hash = $received_block_list | get $i
print $"Getting block ($hash)"
app get-block-from --node $SWARM.1.ip_port ($providers | get $i) $file_hash ($hash) | get 1 | save $"($output_dir)/($hash)"
app get-block-from --node $SWARM.1.ip_port $provider $file_hash ($hash) | save $"($output_dir)/($hash)"
}
print "Finished getting all the blocks\n"
Loading