Please correct lib/block.js

https://en.bitcoin.it/wiki/Protocol_Specification#block

block message payload
{
version:
prevHash:
merkle_root:
timestamp:
bits:
nonce:
txn_count:
info.txns:
}

請更正,謝謝

can you be more specific please? what’s wrong with block.js?

//Bitcore 0.8.x lib/block.js

Block._fromBufferReader = function _fromBufferReader(br) {
info.magicnum = br.readUInt32LE();
info.size = br.readUInt32LE();
info.header = BlockHeader.fromBufferReader(br);
info.txsvi = Varint(br.readVarintBuf());
var txslen = info.txsvi.toNumber();
info.txs = [];
for (var i = 0; i < txslen; i++) {
info.txs.push(Transaction().fromBufferReader(br));
}
return info;
};

//Bitcore 0.9 lib/block.js

Block._fromBufferReader = function _fromBufferReader(br) {
var info = {};
$.checkState(!br.finished(), ‘No block data received’);
info.header = BlockHeader.fromBufferReader(br);
var transactions = br.readVarintNum();
info.transactions = [];
for (var i = 0; i < transactions; i++) {
info.transactions.push(Transaction().fromBufferReader(br));
}
return info;
};

Thanks! My code can work on Bitcore 0.9 & Bitcore-p2p.
But why my code’s transaction.id return ‘undefined’?
The transaction.id can return tx_hash on Bitcore 0.85 !

peer.on(‘block’,function(message){
console.log(message.block.toObject().transactions[1].id);
}