Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

bootstrap peers #506

Closed
wants to merge 3 commits into from
Closed

bootstrap peers #506

wants to merge 3 commits into from

Conversation

heavyk
Copy link

@heavyk heavyk commented Sep 30, 2016

playing around with the code, I couldn't get it transferring ... however, if I dial them, everything is working perfectly.

not sure if this is exactly how you wanted it implemented though. feedback appreciated

cheers

@jbenet jbenet added the status/deferred Conscious decision to pause or backlog label Sep 30, 2016
@daviddias
Copy link
Member

Hey @heavyk, thank you for the PR!

Bootstrap peers are one of the Discovery mechanisms of libp2p, currently implemented in https://github.com/libp2p/js-libp2p-railing, just not attached to the libp2p-builds. Would you like to do that?

Note that the go-ipfs nodes running on bootstrap have version 0.4.3, which doesn't incorporate some spdy fixes that are presente in go-ipfs master, when 0.4.4 is released, you shouldn't have an issue :) (Also one of the reasons we are not enabling this by default)

@heavyk
Copy link
Author

heavyk commented Sep 30, 2016

oh alright, I didn't know about the differences in the versions. I'd be more than happy to implement it using libp2p-railing ... I pushed another commit which implements it how I expected it to go, but I get this error:

Swarm listening on /ip4/127.0.0.1/tcp/59152
/Users/kenny/Projects/js-ipfs/node_modules/peer-book/lib/index.js:19
      peers[peerInfo.id.toB58String()].multiaddr.replace([], peerInfo.multiaddrs);
                                                ^

TypeError: Cannot read property 'replace' of undefined
    at PeerBook.put (/Users/kenny/Projects/js-ipfs/node_modules/peer-book/lib/index.js:19:49)
    at Swarm.self._libp2pNode.swarm.on (/Users/kenny/Projects/js-ipfs/src/core/components/libp2p.js:32:35)
    at emitOne (events.js:101:20)
    at Swarm.emit (events.js:188:7)
    at /Users/kenny/Projects/js-ipfs/node_modules/libp2p-swarm/lib/dial.js:159:19
    at /Users/kenny/Projects/js-ipfs/node_modules/multistream-select/lib/dialer.js:66:9
    at /Users/kenny/Projects/js-ipfs/node_modules/multistream-select/lib/agreement.js:32:5
    at /Users/kenny/Projects/js-ipfs/node_modules/pull-length-prefixed/lib/decode.js:93:9
    at Object.cb (/Users/kenny/Projects/js-ipfs/node_modules/pull-length-prefixed/lib/decode.js:105:5)
    at drain (/Users/kenny/Projects/js-ipfs/node_modules/pull-reader/index.js:39:14)

is my implementation even correct to begin with?


also, I'll be more than happy to help with other parts that need to be done. just point me in the right direction :D

@daviddias
Copy link
Member

@heavyk you missed an 's' in the .multiaddr :)

@heavyk
Copy link
Author

heavyk commented Sep 30, 2016

nope :) that doesn't work either... I instear get this error:

/Users/kenny/Projects/js-ipfs/node_modules/peer-book/lib/index.js:19
      peers[peerInfo.id.toB58String()].multiaddrs.replace([], peerInfo.multiaddrs);
                                                  ^

TypeError: peers[peerInfo.id.toB58String(...)].multiaddrs.replace is not a function
    at PeerBook.put (/Users/kenny/Projects/js-ipfs/node_modules/peer-book/lib/index.js:19:51)
    at Swarm.self._libp2pNode.swarm.on (/Users/kenny/Projects/js-ipfs/src/core/components/libp2p.js:32:35)
    at emitOne (events.js:101:20)
    at Swarm.emit (events.js:188:7)
    at /Users/kenny/Projects/js-ipfs/node_modules/libp2p-swarm/lib/dial.js:159:19
    at /Users/kenny/Projects/js-ipfs/node_modules/multistream-select/lib/dialer.js:66:9
    at /Users/kenny/Projects/js-ipfs/node_modules/multistream-select/lib/agreement.js:32:5
    at /Users/kenny/Projects/js-ipfs/node_modules/pull-length-prefixed/lib/decode.js:93:9
    at Object.cb (/Users/kenny/Projects/js-ipfs/node_modules/pull-length-prefixed/lib/decode.js:105:5)
    at drain (/Users/kenny/Projects/js-ipfs/node_modules/pull-reader/index.js:39:14)

I did get it working though... look at the last commit. I had to put(peerInfo, true) (to force replacement). however, that will yield this error:

/Users/kenny/Projects/js-ipfs/node_modules/peer-book/lib/index.js:19
      peers[peerInfo.id.toB58String()].multiaddr.replace([], peerInfo.multiaddrs);
                                                ^

TypeError: Cannot read property 'replace' of undefined
    at PeerBook.put (/Users/kenny/Projects/js-ipfs/node_modules/peer-book/lib/index.js:19:49)
    at /Users/kenny/Projects/js-ipfs/node_modules/libp2p-ipfs/lib/index.js:147:22
    at /Users/kenny/Projects/js-ipfs/node_modules/libp2p-swarm/lib/dial.js:192:11
    at /Users/kenny/Projects/js-ipfs/node_modules/multistream-select/lib/dialer.js:66:9
    at /Users/kenny/Projects/js-ipfs/node_modules/multistream-select/lib/agreement.js:32:5
    at /Users/kenny/Projects/js-ipfs/node_modules/pull-length-prefixed/lib/decode.js:93:9
    at Object.cb (/Users/kenny/Projects/js-ipfs/node_modules/pull-length-prefixed/lib/decode.js:105:5)
    at drain (/Users/kenny/Projects/js-ipfs/node_modules/pull-reader/index.js:39:14)
    at more (/Users/kenny/Projects/js-ipfs/node_modules/pull-reader/index.js:51:13)
    at Object.reader.read (/Users/kenny/Projects/js-ipfs/node_modules/pull-reader/index.js:95:7)
➜  js-ipfs git:(bootstrap-peers) ✗ atom /Users/kenny/Projects/js-ipfs/node_modules/libp2p-ipfs/lib

so then, I had to go here: https://github.com/ipfs/js-libp2p-ipfs/blob/master/src/index.js#L145 and change that line to: this.peerBook.put(peer, true)

and now everything is all good. I'm not sure that's the right way though...

@heavyk
Copy link
Author

heavyk commented Sep 30, 2016

I see what you're saying about the 's' though... that's an existing error in peer-book

@heavyk
Copy link
Author

heavyk commented Sep 30, 2016

seems the peer-book code is incorrect. you were the last to touch that anyway: libp2p/js-peer-book@e58fa0c

how shall this be fixed then?

@daviddias
Copy link
Member

nvm, when I looked at first, I thought you wanted to access the array directly, the .replace exists: https://github.com/libp2p/js-peer-info/blob/master/src/index.js#L76

@heavyk
Copy link
Author

heavyk commented Sep 30, 2016

really, I'm not sure what I'm not sure what exactly is the desired functionality... though, I can do the work if you tell me how it is you want it.

@daviddias
Copy link
Member

Thank you :) In order to make railing work, we need:

Let me know your questions as you go, and thanks for bearing with the lack of good docs. We have the intent of boosting all our documentation on these things in the next quarter, so that contributions and usage gets way easier.

@daviddias
Copy link
Member

Hi @heavyk, we've added bootstrap through libp2p-railing with this PR #735

Thank you for taking a look at this, we had to refactor to match our libp2p interfaces.

If you are looking for more things to work on, check other issues that are open for contribution here: https://waffle.io/ipfs/js-ipfs

@daviddias daviddias closed this Feb 1, 2017
@daviddias daviddias removed the status/deferred Conscious decision to pause or backlog label Feb 1, 2017
MicrowaveDev pushed a commit to galtproject/js-ipfs that referenced this pull request May 22, 2020
The opts parameter wasn't correctly passed in when calling ipfs.object.stat. This is the test that makes sure opts is being correctly passed to through the send function to the IPFS daemon. 

I've also removed the "base58" encoding that was being passed in for some tests as base58 isn't a valid option for encoding and would provide this error: 

Uncaught AssertionError: expected [Error: invalid encoding: base58] to not exist

Co-Authored-By: Alan Shaw <alan.shaw@protocol.ai>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants