src/zero/index.js
function ZNV2Swarm (opt, protocol, zeronet, lp2p) {
  const self = this
  self.proto = self.protocol = new ZProtocol({
    crypto: opt.crypto,
    id: opt.id
  }, zeronet)

  log('creating zeronet swarm')

  const tr = self.transport = {}
  self.multiaddrs = (opt.listen || []).map(m => multiaddr(m));

  (opt.transports || []).forEach(transport => {
    tr[transport.tag || transport.constructor.name] = transport
    if (!transport.listeners) {
      transport.listeners = []
    }
  })

  TRANSPORT(self)
  DIAL(self, lp2p)

  self.advertise = {
    ip: null,
    port: null,
    port_open: null
  }

  let nat
  if (opt.nat) nat = self.nat = new NAT(self, opt)

  self.start = cb => series([
    self.listen,
    nat ? nat.doDefault : cb => cb()
  ], cb)

  self.stop = cb => series([
    self.unlisten
  ], cb)
}
function ZNV2Swarm (opt, protocol, zeronet, lp2p) {
  const self = this
  self.proto = self.protocol = new ZProtocol({
    crypto: opt.crypto,
    id: opt.id
  }, zeronet)

  log('creating zeronet swarm')

  const tr = self.transport = {}
  self.multiaddrs = (opt.listen || []).map(m => multiaddr(m));

  (opt.transports || []).forEach(transport => {
    tr[transport.tag || transport.constructor.name] = transport
    if (!transport.listeners) {
      transport.listeners = []
    }
  })

  TRANSPORT(self)
  DIAL(self, lp2p)

  self.advertise = {
    ip: null,
    port: null,
    port_open: null
  }

  let nat
  if (opt.nat) nat = self.nat = new NAT(self, opt)

  self.start = cb => series([
    self.listen,
    nat ? nat.doDefault : cb => cb()
  ], cb)

  self.stop = cb => series([
    self.unlisten
  ], cb)
}
function ZNV2Swarm ( opt , protocol , zeronet , lp2p ) { const self = this self . proto = self . protocol = new ZProtocol ( { crypto : opt . crypto , id : opt . id } , zeronet ) log ( 'creating zeronet swarm' ) const tr = self . transport = { } self . multiaddrs = ( opt . listen || [ ] ) . map ( m => multiaddr ( m ) ) ; ( opt . transports || [ ] ) . forEach ( transport => { tr [ transport . tag || transport . constructor . name ] = transport if ( ! transport . listeners ) { transport . listeners = [ ] } } ) TRANSPORT ( self ) DIAL ( self , lp2p ) self . advertise = { ip : null , port : null , port_open : null } let nat if ( opt . nat ) nat = self . nat = new NAT ( self , opt ) self . start = cb => series ( [ self . listen , nat ? nat . doDefault : cb => cb ( ) ] , cb ) self . stop = cb => series ( [ self . unlisten ] , cb ) }
ZNv2 swarm using libp2p transports
ZNv2 swarm using libp2p transports