Help me navigate apparently out of date examples

Hi all,

I’ve just started using libp2p-js and running the example code, but it appears the api may have changed significantly recently!

I’m running version 0.27.8 of libp2p-js. This was installed using npm install libp2p.

In the transports examples, I see:
node.multiaddrs.forEach((ma) => console.log(ma.toString()));

But multiaddrs is not defined in node, I found multiaddrs defined in peerInfo though.
node.peerInfo.multiaddrs.forEach((ma) => console.log(ma.toString()));

Which appears to work.
I then came to
node1.peerStore.addressBook.set(node2.peerId, node2.multiaddrs);

But addressBook is undefined in node1.peerStore.
I’m struggling to find the correct implementation of this.

I see talk of refactoring in version 0.28 and the only occurrence of addressBook in the libp2p peer-store script is commented out.

Have the examples already been updated to 0.28 code, but the npm repo still points to 0.27.8?

If the examples are up to date, will an upgrade solve my problems?

Thanks in advance!

1 Like

The 0.28 release is planned for this week. The RC has been released which is why the master branch on the github repo is showing the code/examples for it. You can either browser the code for the tag you’re on, https://github.com/libp2p/js-libp2p/tree/v0.27.8, or if you’d like to try out the RC there are directions in the release issue