Pass fcoin Block template

This commit is contained in:
Sky Young 2019-07-24 17:46:08 -06:00
parent b13b4f667b
commit 978679cad7

View File

@ -90,7 +90,7 @@ P2P.prototype.getP2PBlock = function(opts, callback) {
self.once(opts.blockHash, callback);
peer.sendMessage(self.messages.GetBlocks(blockFilter));
peer.sendMessage(self.messages.GetBlocks(blockFilter, { Block: BcoinBlock }));
};
P2P.prototype.getHeaders = function(filter) {
@ -278,7 +278,7 @@ P2P.prototype._initP2P = function() {
if (this.node.network === 'regtest') {
Networks.enableRegtest();
}
this.messages = new p2p.Messages({ network: Networks.get(this.node.network), Transaction: BcoinTx });
this.messages = new p2p.Messages({ network: Networks.get(this.node.network), Transaction: BcoinTx, Block: BcoinBlock });
this._peerHeights = [];
this._peers = [];
this._peerIndex = 0;
@ -306,10 +306,9 @@ P2P.prototype._initPubSub = function() {
};
P2P.prototype._onPeerBlock = function(peer, message) {
let block = BcoinBlock.fromRaw(message.block.toBuffer())
this._blockCache.set(block.rhash(), block);
this.emit(block.rhash(), block);
this._broadcast(this.subscriptions.block, 'p2p/block', block);
this._blockCache.set(message.block.rhash(), message.block);
this.emit(message.block.rhash(), message.block);
this._broadcast(this.subscriptions.block, 'p2p/block', message.block);
};
P2P.prototype._onPeerDisconnect = function(peer, addr) {