Creates a new Networking Object. This Implements Ethereum's Wire Protocol and provides networking functions.
Parameters
options
Objectoptions.protocolVersion
[Integer] The network version (optional, default1
)options.publicIp
String The public ip address of this instanceoptions.capabilties
Object A hash containing the capbilities of this node and their corrisponding version numbersoptions.timeout
[Integer] The length of time in milliseconds to wait for a peer to response after connecting to it (optional, default20000
)options.maxPeers
[Integer] The max number of peer the network will try to connect to (optional, default10
)options.clientId
String Specifies the client software identity, as a human-readable string
stops the tcp server and disconnects any peers
Parameters
cb
Function the callback
connects to a peer
Parameters
port
Number the port of the peerhost
String the hostname or IP of the peerpeer
cb
Function the callback TODO: fixcb
starts the tcp server
Parameters
port
[Number] The hostname or IP address the server is bound to. Defaults to 0.0.0.0 which means any available network (optional, default30303
)host
[String] The TPC port the server is listening to. Defaults to port 30303 (optional, default'0.0.0.0'
)cb
Emitted when a peer disconnects. Gives the peer to the handler.
Emitted whenever a peer connects. Gives the peer to the handler.
The peer represents a peer on the ethereum network. Peer objects cannot be created directly. The Network
creates them when a connection happens
Parameters
socket
Object an Intialized Sockets. MUST alread be connectednetwork
Object the network that initailized the connectionid
Buffer
Creates a Duplex stream. Uses node's steams
Parameters
opts
Sends the disconnect message, where reason is one of the following integers
- 0x00 - Disconnect requested
- 0x01 - TCP sub-system error
- 0x02 - Bad protocol
- 0x03 - Useless peer
- 0x04 - Too many peers
- 0x05 - Already connected
- 0x06 - Wrong genesis block
- 0x07 - Incompatible network protocols
- 0x08 - Client quitting
Parameters
reason
Inteter
Emitted whenever this peer connects. Gives the peer to the handler.
Emitted when the peer gets data from the network
Emitted when this peer gets a pong
Emitted when this peer disconnects. Gives the peer to the handler.