Properly deserialize Block using fcoin

This commit is contained in:
Sky Young 2019-07-24 12:56:36 -06:00
parent a062769cc4
commit dae4c318c2
2 changed files with 5 additions and 4 deletions

View File

@ -1,6 +1,7 @@
'use strict';
var bitcore = require('flocore-lib');
var fcoin = require('fcoin');
var Inventory = require('../inventory');
function builder(options) {
@ -15,9 +16,9 @@ function builder(options) {
options.network = bitcore.Networks.defaultNetwork;
}
options.Block = options.Block || bitcore.Block;
options.Block = options.Block || fcoin.Block;
options.BlockHeader = options.BlockHeader || bitcore.BlockHeader;
options.Transaction = options.Transaction || bitcore.Transaction;
options.Transaction = options.Transaction || fcoin.Transaction;
options.MerkleBlock = options.MerkleBlock || bitcore.MerkleBlock;
options.protocolVersion = options.protocolVersion || 70001;

View File

@ -26,7 +26,7 @@ function BlockMessage(arg, options) {
inherits(BlockMessage, Message);
BlockMessage.prototype.setPayload = function(payload) {
if (this.Block.prototype.fromRaw) {
if (typeof this.Block.fromRaw === 'function') {
this.block = this.Block.fromRaw(payload);
} else {
this.block = this.Block.fromBuffer(payload);
@ -34,7 +34,7 @@ BlockMessage.prototype.setPayload = function(payload) {
};
BlockMessage.prototype.getPayload = function() {
if (this.Block.prototype.toRaw) {
if (typeof this.Block.fromRaw === 'function') {
return this.block.toRaw();
}
return this.block.toBuffer();