feat: peer store (#470)

* feat: peer-store v0

* chore: apply suggestions from code review

Co-Authored-By: Jacob Heun <jacobheun@gmail.com>
This commit is contained in:
Vasco Santos
2019-11-06 15:11:13 +01:00
committed by Jacob Heun
parent fba058370a
commit 53bcd2d745
8 changed files with 519 additions and 16 deletions

View File

@ -0,0 +1,24 @@
'use strict'
const PeerId = require('peer-id')
const PeerInfo = require('peer-info')
const Peers = require('../../fixtures/peers')
module.exports.createPeerInfo = async (length) => {
const peers = await Promise.all(
Array.from({ length })
.map((_, i) => PeerId.create())
)
return peers.map((peer) => new PeerInfo(peer))
}
module.exports.createPeerInfoFromFixture = async (length) => {
const peers = await Promise.all(
Array.from({ length })
.map((_, i) => PeerId.createFromJSON(Peers[i]))
)
return peers.map((peer) => new PeerInfo(peer))
}