Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
before('create nodes', async () => {
const [peerId1, peerId2] = await Promise.all([
createPeerId(PeerIds.shift()),
createPeerId(PeerIds.shift())
])
const peerInfo1 = new PeerInfo(peerId1)
peerInfo1.multiaddrs.add('/ip4/0.0.0.0/tcp/8080')
// peerInfo1.multiaddrs.add('/ip4/0.0.0.0/tcp/0/ws')
const peerInfo2 = new PeerInfo(peerId2)
peerInfo2.multiaddrs.add('/ip4/0.0.0.0/tcp/10000')
// peerInfo2.multiaddrs.add('/ip4/0.0.0.0/tcp/0/ws')
libp2p = new Libp2p({ peerInfo: peerInfo1, config: { peerDiscovery: { autoDial: false } } })
remoteLibp2p = new Libp2p({ peerInfo: peerInfo2, config: { peerDiscovery: { autoDial: false } } })
})
it('should add a peerInfo to the book', (done) => {
PeerId.createFromJSON(TestPeerInfos[1].id, (err, id) => {
const peerInfo = new PeerInfo(id)
expect(peerBook.has(peerInfo.id.toB58String())).to.eql(false)
expect(getPeerInfo(peerInfo, peerBook)).to.exist()
expect(peerBook.has(peerInfo.id.toB58String())).to.eql(true)
done(err)
})
})
before((done) => {
PeerId.createFromJSON(nodes.node4, (_, peerId) => {
PeerInfo.create(peerId, (err, peerInfo) => {
peer = peerInfo
peer.multiaddrs.add('/p2p-circuit/ipfs/QmSswe1dCFRepmhjAMR5VfHeokGLcvVggkuDJm7RMfJSrE')
done(err)
})
})
})
before(async () => {
const [peerId, remotePeerId] = await Promise.all([
PeerId.createFromJSON(Peers[0]),
PeerId.createFromJSON(Peers[1])
])
peerInfo = new PeerInfo(peerId)
remotePeerInfo = new PeerInfo(remotePeerId)
remoteLibp2p = new Libp2p({
peerInfo: remotePeerInfo,
modules: {
transport: [Transport],
streamMuxer: [Muxer],
connEncryption: [Crypto]
}
})
remoteLibp2p.handle('/echo/1.0.0', ({ stream }) => pipe(stream, stream))
(cb) => PeerId.createFromJSON(nodes.node4, cb),
(peerId, cb) => PeerInfo.create(peerId, cb),
before(async () => {
const peerId = await PeerId.createFromJSON(Peers[0])
peerInfo = new PeerInfo(peerId)
})
before(async () => {
[localPeer, remotePeer] = (await Promise.all([
PeerId.createFromJSON(Peers[0]),
PeerId.createFromJSON(Peers[1])
])).map(id => new PeerInfo(id))
})
const ethereum = require('../../src')
const idJson = require('./id-1')
const PeerId = require('peer-id')
const PeerInfo = require('peer-info')
const multiaddr = require('multiaddr')
const Block = require('ethereumjs-block')
const async = require('async')
const thousand = require('./../../test/data/real-chain/first-1000-blocks.json')
const id = PeerId.createFromJSON(idJson)
const info = new PeerInfo(id)
const ma = multiaddr('/ip4/127.0.0.1/tcp/12345')
info.multiaddr.add(ma)
const node = new ethereum.Node()
node.start(info, (err) => {
if (err) {
throw err
}
console.log('🎧 Listening on:')
node.libp2p.peerInfo.multiaddrs.forEach((ma) => {
console.log(ma.toString() + '/ipfs/' + id.toB58String())
})
const ethereum = require('../../src')
const idJson = require('./../broadcast-blocks/id-1')
const PeerId = require('peer-id')
const PeerInfo = require('peer-info')
const multiaddr = require('multiaddr')
const Account = require('ethereumjs-account')
const Block = require('ethereumjs-block')
const async = require('async')
const thousand = require('./../../test/data/real-chain/first-1000-blocks.json')
const id = PeerId.createFromJSON(idJson)
const info = new PeerInfo(id)
const ma = multiaddr('/ip4/127.0.0.1/tcp/12345')
info.multiaddr.add(ma)
const node = new ethereum.Node()
node.start(info, (err) => {
if (err) {
throw err
}
console.log('🎧 Listening on:')
node.libp2p.peerInfo.multiaddrs.forEach((ma) => {
console.log(ma.toString() + '/ipfs/' + id.toB58String())
})
function relayInfo () {
const relayId = PeerId.createFromJSON(relayPeerIdJson)
const relayma = multiaddr('/ip4/127.0.0.1/tcp/33333/ws')
const relayInfo = new PeerInfo(relayId)
relayInfo.multiaddr.add(relayma)
return relayInfo
}