Created
June 28, 2016 10:45
-
-
Save apiarian/69eb78a0be5fa93d68a99f7e98a4b0b0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use strict; | |
use warnings; | |
sub mkNode { | |
my ($data) = @_; | |
my $node = `echo '{"Data": "$data"}' | ipfs object put`; | |
die "failed to create node" if $?; | |
chomp $node; | |
(undef, $node) = split /\s+/, $node; | |
return $node; | |
} | |
my $head = mkNode("head"); | |
print "head: $head\n"; | |
my $tail = mkNode("tail"); | |
print "tail: $tail\n"; | |
$head = `ipfs object patch add-link $head first-link $tail`; | |
chomp $head; | |
my $head_listing = `ipfs object get $head`; | |
print "head with 1 link: $head\n\t$head_listing"; | |
$head = `ipfs object patch add-link $head second-link $tail`; | |
chomp $head; | |
$head_listing = `ipfs object get $head`; | |
print "head with 2 links: $head\n\t$head_listing"; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment