Skip to content

Commit

Permalink
style: rename node vars
Browse files Browse the repository at this point in the history
since this is example, this should make things easier to follow
  • Loading branch information
lidel committed May 24, 2022
1 parent 6dc4bc2 commit 13a77d6
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions docs/examples/go-ipfs-as-a-library/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,12 +196,12 @@ func main() {
defer cancel()

// Spawn a local peer using a temporary path, for testing purposes
peerAPI, peerNode, err := spawnEphemeral(ctx)
ipfsA, nodeA, err := spawnEphemeral(ctx)
if err != nil {
panic(fmt.Errorf("failed to spawn peer node: %s", err))
}

peerCidFile, err := peerAPI.Unixfs().Add(ctx,
peerCidFile, err := ipfsA.Unixfs().Add(ctx,
files.NewBytesFile([]byte("hello from ipfs 101 in go-ipfs")))
if err != nil {
panic(fmt.Errorf("could not add File: %s", err))
Expand All @@ -211,7 +211,7 @@ func main() {

// Spawn a node using a temporary path, creating a temporary repo for the run
fmt.Println("Spawning node on a temporary repo")
ipfs, _, err := spawnEphemeral(ctx)
ipfsB, _, err := spawnEphemeral(ctx)
if err != nil {
panic(fmt.Errorf("failed to spawn ephemeral node: %s", err))
}
Expand All @@ -231,7 +231,7 @@ func main() {
panic(fmt.Errorf("could not get File: %s", err))
}

cidFile, err := ipfs.Unixfs().Add(ctx, someFile)
cidFile, err := ipfsB.Unixfs().Add(ctx, someFile)
if err != nil {
panic(fmt.Errorf("could not add File: %s", err))
}
Expand All @@ -243,7 +243,7 @@ func main() {
panic(fmt.Errorf("could not get File: %s", err))
}

cidDirectory, err := ipfs.Unixfs().Add(ctx, someDirectory)
cidDirectory, err := ipfsB.Unixfs().Add(ctx, someDirectory)
if err != nil {
panic(fmt.Errorf("could not add Directory: %s", err))
}
Expand All @@ -260,7 +260,7 @@ func main() {
outputPathFile := outputBasePath + strings.Split(cidFile.String(), "/")[2]
outputPathDirectory := outputBasePath + strings.Split(cidDirectory.String(), "/")[2]

rootNodeFile, err := ipfs.Unixfs().Get(ctx, cidFile)
rootNodeFile, err := ipfsB.Unixfs().Get(ctx, cidFile)
if err != nil {
panic(fmt.Errorf("could not get file with CID: %s", err))
}
Expand All @@ -272,7 +272,7 @@ func main() {

fmt.Printf("got file back from IPFS (IPFS path: %s) and wrote it to %s\n", cidFile.String(), outputPathFile)

rootNodeDirectory, err := ipfs.Unixfs().Get(ctx, cidDirectory)
rootNodeDirectory, err := ipfsB.Unixfs().Get(ctx, cidDirectory)
if err != nil {
panic(fmt.Errorf("could not get file with CID: %s", err))
}
Expand All @@ -288,7 +288,7 @@ func main() {

fmt.Println("\n-- Going to connect to a few nodes in the Network as bootstrappers --")

peerMa := fmt.Sprintf("/ip4/127.0.0.1/udp/4010/p2p/%s", peerNode.Identity.String())
peerMa := fmt.Sprintf("/ip4/127.0.0.1/udp/4010/p2p/%s", nodeA.Identity.String())

bootstrapNodes := []string{
// IPFS Bootstrapper nodes.
Expand All @@ -314,7 +314,7 @@ func main() {
}

go func() {
err := connectToPeers(ctx, ipfs, bootstrapNodes)
err := connectToPeers(ctx, ipfsB, bootstrapNodes)
if err != nil {
log.Printf("failed connect to peers: %s", err)
}
Expand All @@ -326,7 +326,7 @@ func main() {
outputPath := outputBasePath + exampleCIDStr
testCID := icorepath.New(exampleCIDStr)

rootNode, err := ipfs.Unixfs().Get(ctx, testCID)
rootNode, err := ipfsB.Unixfs().Get(ctx, testCID)
if err != nil {
panic(fmt.Errorf("could not get file with CID: %s", err))
}
Expand Down

0 comments on commit 13a77d6

Please sign in to comment.