-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from application-research/ar-test-example
chore: add ar test peer
- Loading branch information
Showing
7 changed files
with
104 additions
and
30 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
whypfs "github.com/application-research/whypfs-core" | ||
"io" | ||
|
||
"github.com/ipfs/go-cid" | ||
) | ||
|
||
// Creating a new whypfs node, bootstrapping it with the default bootstrap peers, adding a file to the whypfs network, and | ||
// then retrieving the file from the whypfs network. | ||
func ArTest() { | ||
ctx, cancel := context.WithCancel(context.Background()) | ||
defer cancel() | ||
|
||
whypfsPeer, err := whypfs.NewNode(whypfs.NewNodeParams{ | ||
Ctx: ctx, | ||
Datastore: whypfs.NewInMemoryDatastore(), | ||
}) | ||
|
||
whypfsPeer.BootstrapPeers(whypfs.DefaultBootstrapPeers()) | ||
|
||
c1, _ := cid.Decode("QmbJGGJkjGfYCmHqwoMjLTbUA6bdcFBbNdWChFY6dKNRWx") | ||
rsc1, err := whypfsPeer.GetFile(ctx, c1) | ||
if err != nil { | ||
panic(err) | ||
} | ||
defer rsc1.Close() | ||
content1, err := io.ReadAll(rsc1) | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
c2, _ := cid.Decode("QmPecv5jpAPVG3LUN8fbptnaPHFzt3SRtxC8e1XZCVMiSM") | ||
rsc2, err := whypfsPeer.GetFile(ctx, c2) | ||
if err != nil { | ||
panic(err) | ||
} | ||
defer rsc2.Close() | ||
content2, err := io.ReadAll(rsc2) | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
fmt.Println(string(content1)) | ||
fmt.Println(string(content2)) | ||
} |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
whypfs "github.com/application-research/whypfs-core" | ||
"github.com/ipfs/go-cid" | ||
) | ||
|
||
// Creating a new whypfs node, bootstrapping it with the default bootstrap peers, adding a file to the whypfs network, and | ||
// then retrieving the file from the whypfs network. | ||
func DirTest() { | ||
ctx, cancel := context.WithCancel(context.Background()) | ||
defer cancel() | ||
|
||
whypfsPeer, err := whypfs.NewNode(whypfs.NewNodeParams{ | ||
Ctx: ctx, | ||
Datastore: whypfs.NewInMemoryDatastore(), | ||
}) | ||
|
||
whypfsPeer.BootstrapPeers(whypfs.DefaultBootstrapPeers()) | ||
|
||
c1, _ := cid.Decode("bafybeigvgzoolc3drupxhlevdp2ugqcrbcsqfmcek2zxiw5wctk3xjpjwy") | ||
rsc1, err := whypfsPeer.GetDirectoryWithCid(ctx, c1) | ||
if err != nil { | ||
panic(err) | ||
} | ||
rsc1.GetNode() | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package main | ||
|
||
import "fmt" | ||
|
||
func main() { | ||
fmt.Println("Testing Grounds Only!") | ||
|
||
} |
This file contains 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
This file contains 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
This file contains 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