From ce76c213c44fd4afe398cbf9b0ae3cf1e46b6e81 Mon Sep 17 00:00:00 2001 From: Braydon Fuller Date: Tue, 16 Dec 2014 16:38:39 -0500 Subject: [PATCH] Docs: General documentation for a Pool --- docs/Pool.md | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 docs/Pool.md diff --git a/docs/Pool.md b/docs/Pool.md new file mode 100644 index 000000000..08d3c9557 --- /dev/null +++ b/docs/Pool.md @@ -0,0 +1,28 @@ +# Pool + +A pool maintains a connection of [Peers](Peer.md). A pool will discover peers via DNS seeds, as well as when peer addresses are announced through the network. + +The quickest way to get connected is to run the following: + +```javascript + +var bitcore = require('bitcore'); +var Pool = bitcore.transport.Pool; +var Networks = bitcore.Networks; + +var pool = new Pool(Networks.livenet); + +// connect to the network +pool.connect(); + +// attach peer events +pool.on('peerinv', function(peer, message) { + // a new peer message has arrived +}); + +// will disconnect all peers +pool.disconnect() + +``` + +For more information about Peer events, please read the [Peer](Peer.md) documentation. Peer events are relayed to the pool, a peer event `inv` in the pool would be `peerinv`. When a peer is disconnected the pool will try to connect to the list of known addresses to maintain connection. \ No newline at end of file