reduced block model and parsing.

This commit is contained in:
tenthirtyone 2017-08-17 00:44:50 -04:00
parent 8d733df278
commit 31eecc5afe
2 changed files with 2 additions and 37 deletions

View File

@ -23,42 +23,7 @@ function parse(entry, block) {
nonce: blockJSON.nonce,
txs: block.txs.map((tx) => {
const txJSON = tx.toJSON();
const txRAW = tx.toRaw();
return {
hash: txJSON.hash,
witnessHash: txJSON.witnessHash,
fee: txJSON.fee,
rate: txJSON.rate,
size: txRAW.length,
ps: txJSON.ps,
height: entry.height,
block: util.revHex(entry.hash),
ts: entry.ts,
date: txJSON.date,
index: txJSON.index,
version: txJSON.version,
flag: txJSON.flag,
inputs: tx.inputs.map((input) => {
const inputJSON = input.toJSON();
return new InputModel({
prevout: inputJSON.prevout,
script: inputJSON.script,
witness: inputJSON.witness,
sequence: inputJSON.sequence,
address: inputJSON.address,
});
}),
outputs: tx.outputs.map((output) => {
const outputJSON = output.toJSON();
return new OutputModel({
address: outputJSON.address,
script: outputJSON.script,
value: outputJSON.value,
});
}),
lockTime: txJSON.locktime,
chain: config.bcoin.network,
};
return txJSON.hash;
}),
chainwork: entry.chainwork,
reward,

View File

@ -13,7 +13,7 @@ const BlockSchema = new Schema({
ts: { type: Number, default: 0 },
bits: { type: Number, default: 0 },
nonce: { type: Number, default: 0 },
txs: [Transaction.schema],
txs: [{ type: String, default: '' }],
chainwork: { type: Number, default: 0 },
reward: { type: Number, default: 0 },
network: { type: String, default: '' },