Properly deserialize Block using fcoin
This commit is contained in:
parent
a062769cc4
commit
dae4c318c2
@ -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;
|
||||
|
||||
|
||||
@ -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();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user