Socket architecture change. More maleable/easier to wire up events with the node
This commit is contained in:
parent
22c2642653
commit
923128de59
@ -1,5 +1,5 @@
|
|||||||
const config = {
|
const config = {
|
||||||
start_node: false,
|
start_node: true,
|
||||||
logging: 'debug',
|
logging: 'debug',
|
||||||
bcoin: {
|
bcoin: {
|
||||||
network: 'main',
|
network: 'main',
|
||||||
|
|||||||
3
index.js
3
index.js
@ -18,6 +18,3 @@ db.connection.once('open', () => {
|
|||||||
'listening on port 3000');
|
'listening on port 3000');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -34,7 +34,8 @@ app.use((req, res) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const server = require('http').Server(app);
|
const server = require('http').Server(app);
|
||||||
|
const io = require('socket.io')(server);
|
||||||
|
|
||||||
const SocketAPI = require('./socket')(server);
|
const SocketAPI = require('./socket')(io);
|
||||||
|
|
||||||
module.exports = server;
|
module.exports = server;
|
||||||
|
|||||||
@ -1,9 +1,4 @@
|
|||||||
|
module.exports = function addressrouter(io) {
|
||||||
module.exports = function addressrouter(express) {
|
|
||||||
const io = require('socket.io')(express);
|
|
||||||
|
|
||||||
console.log('starting sockets')
|
|
||||||
|
|
||||||
io.on('connection', (socket) => {
|
io.on('connection', (socket) => {
|
||||||
socket.on('subscribe', (data) => {
|
socket.on('subscribe', (data) => {
|
||||||
console.log('subscribe message');
|
console.log('subscribe message');
|
||||||
@ -25,5 +20,4 @@ module.exports = function addressrouter(express) {
|
|||||||
console.log(data);
|
console.log(data);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@ -6,6 +6,8 @@ const addrParser = require('../parser').Address;
|
|||||||
const config = require('../../config');
|
const config = require('../../config');
|
||||||
|
|
||||||
const node = new FullNode(config.bcoin);
|
const node = new FullNode(config.bcoin);
|
||||||
|
let socket;
|
||||||
|
|
||||||
|
|
||||||
function start() {
|
function start() {
|
||||||
node.open()
|
node.open()
|
||||||
@ -22,6 +24,8 @@ function start() {
|
|||||||
BlockParser.parse(entry, block);
|
BlockParser.parse(entry, block);
|
||||||
TxParser.parse(entry, block.txs);
|
TxParser.parse(entry, block.txs);
|
||||||
addrParser.parse(entry, block.txs);
|
addrParser.parse(entry, block.txs);
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
node.pool.on('peer', (peer) => {
|
node.pool.on('peer', (peer) => {
|
||||||
@ -36,6 +40,14 @@ function start() {
|
|||||||
// node.mempool.on('tx' ...)
|
// node.mempool.on('tx' ...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Super Hack
|
||||||
|
function setSocket(client) {
|
||||||
|
console.log('setting socket for node');
|
||||||
|
//socket = client;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
start,
|
start,
|
||||||
|
setSocket,
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user