node-devp2p
or #ethereumjs on freenode
Implements the RPLx transport.
INSTALL
npm install devp2p
#API
Network
new Network([options])
Creates new Network object with the following arguments
Network
options
When creating a Network the following options can be used to configure its behavoir.
timeout
- The lenght of time in milliseconds to wait for a peer to response after connecting to itmaxPeers
- The max number of peer the network will try to connect toclientId
- specifies the client software identity, as a human-readable stringpublicIp
- The public ip of this nodesecretKey
- a 32 byte Buffer
use to encrypte packets and identify the node.subprotocols
- a hash containing the subprotocol name and its corisponding version number
Network
methods
network.listen([port], [host])
start the tcp server
host
- The hostname or IP address the server is bound to. Defaults to 0.0.0.0
which means any available networkport
- The TPC port the server is listening to. Defaults to port 30303
network.connect(peer, [callback])
connect to a peer
peer
- a POJO containing
host
- the hostname or IP of the peerport
- the port of the peerid
- the id/public key of the peer
callback
- a callback function
network.close([callback])
stops the tcp server and disconnects any peers
Network
events
The Network object inherits from Events.EventEmitter
and emits the following events.
connection
- fires whever we connect with a peetr
peer
- The peer that emitted the event
Peer
The peer represents a peer on the ethereum network. Peer objects cannot be created directly.
Peer
methods
peer.sendHello([callback])
Sends the hello message
peer.sendDisconnect(reason, [callback])
Sends the disconnect message, where reason is one of the following integers
0x00
- Disconnect requested0x01
- TCP sub-system error0x02
- Bad protocol0x03
- Useless peer0x04
- Too many peers0x05
- Already connected0x06
- Wrong genesis block0x07
- Incompatible network protocols0x08
- Client quitting
peer.sendPing([callback])
Send Ping
peer.sendPong([callback])
Send Pong
##Peer
events
peer events are the same as Network
events
LICENSE
GPL