Skip to content

Commit a78c731

Browse files
committed
style: rename node vars
since this is example, this should make things easier to follow
1 parent 6ec90d3 commit a78c731

File tree

1 file changed

+10
-10
lines changed
  • docs/examples/go-ipfs-as-a-library

1 file changed

+10
-10
lines changed

docs/examples/go-ipfs-as-a-library/main.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -196,12 +196,12 @@ func main() {
196196
defer cancel()
197197

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

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

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

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

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

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

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

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

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

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

293293
bootstrapNodes := []string{
294294
// IPFS Bootstrapper nodes.
@@ -314,7 +314,7 @@ func main() {
314314
}
315315

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

329-
rootNode, err := ipfs.Unixfs().Get(ctx, testCID)
329+
rootNode, err := ipfsB.Unixfs().Get(ctx, testCID)
330330
if err != nil {
331331
panic(fmt.Errorf("could not get file with CID: %s", err))
332332
}

0 commit comments

Comments
 (0)