fix peermanager example
This commit is contained in:
parent
57c4c20c72
commit
16426d84bd
|
@ -1,3 +1,4 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
// Replace path '..' to 'bitcore' if you are using this example
|
// Replace path '..' to 'bitcore' if you are using this example
|
||||||
// in a different project
|
// in a different project
|
||||||
|
@ -7,18 +8,26 @@ var PeerManager = require('../PeerManager').createClass({
|
||||||
network: networks.testnet
|
network: networks.testnet
|
||||||
});
|
});
|
||||||
|
|
||||||
|
var util= require('util');
|
||||||
|
|
||||||
|
|
||||||
var handleBlock = function(b) {
|
var handleBlock = function(b) {
|
||||||
console.log('block received:', b);
|
console.log('block received:', util.inspect(b.message,{depth:null}));
|
||||||
};
|
};
|
||||||
|
|
||||||
var handleTx = function(b) {
|
var handleTx = function(b) {
|
||||||
console.log('block tx:', b);
|
console.log('block tx:', util.inspect(b.message,{depth:null}));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var handleInv = function(b) {
|
||||||
|
console.log('block inv:', util.inspect(b.message,{depth:null}));
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
var peerman = new PeerManager();
|
var peerman = new PeerManager();
|
||||||
peerman.addPeer( new Peer('127.0.0.1',18333) );
|
peerman.addPeer( new Peer('127.0.0.1',18333) );
|
||||||
peerman.on('connect', function(conn) {
|
peerman.on('connection', function(conn) {
|
||||||
|
conn.on('inv', handleInv);
|
||||||
conn.on('block', handleBlock);
|
conn.on('block', handleBlock);
|
||||||
conn.on('tx', handleTx);
|
conn.on('tx', handleTx);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue