Input/Output moved back inside Transaction model file
This commit is contained in:
parent
3bf0fe7328
commit
8c5f296980
@ -22,7 +22,7 @@ function start() {
|
||||
|
||||
function processBlock(entry, block, cb) {
|
||||
block.hash = util.revHex(block.hash().toString('hex'));
|
||||
const b = new BlockModel({
|
||||
const newBlock = new BlockModel({
|
||||
hash: block.hash,
|
||||
size: block.size,
|
||||
height: block.height,
|
||||
@ -47,7 +47,7 @@ function processBlock(entry, block, cb) {
|
||||
transactionCount: block.txs.length,
|
||||
});
|
||||
|
||||
b.save((err) => {
|
||||
newBlock.save((err) => {
|
||||
if (err) {
|
||||
console.log(err.message);
|
||||
}
|
||||
@ -55,8 +55,21 @@ function processBlock(entry, block, cb) {
|
||||
}
|
||||
|
||||
function processTx(tx) {
|
||||
console.log(util.revHex(tx.hash().toString('hex')));
|
||||
|
||||
console.log(tx);
|
||||
const t = new Transaction({
|
||||
txid: String,
|
||||
chain: String,
|
||||
blockHeight: Number,
|
||||
blockHash: String,
|
||||
blockTime: Date,
|
||||
blockTimeNormalized: Date,
|
||||
inputs: [Input],
|
||||
outputs: [Output],
|
||||
coinbase: Boolean,
|
||||
fee: Number,
|
||||
inputsProcessed: Boolean,
|
||||
wallets: { type: [Schema.Types.ObjectId] },
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
|
||||
@ -1,14 +0,0 @@
|
||||
const mongoose = require('mongoose');
|
||||
const Schema = mongoose.Schema;
|
||||
|
||||
const Input = new Schema({
|
||||
utxo: String,
|
||||
vout: Number,
|
||||
address: String,
|
||||
amount: Number,
|
||||
wallets: { type: [Schema.Types.ObjectId] },
|
||||
});
|
||||
|
||||
const Input = mongoose.model('Input', Input);
|
||||
|
||||
module.exports = Input;
|
||||
@ -1,13 +0,0 @@
|
||||
const mongoose = require('mongoose');
|
||||
const Schema = mongoose.Schema;
|
||||
|
||||
const Output = new Schema({
|
||||
address: String,
|
||||
amount: Number,
|
||||
vout: Number,
|
||||
wallets: { type: [Schema.Types.ObjectId] },
|
||||
});
|
||||
|
||||
const Output = mongoose.model('Output', Output);
|
||||
|
||||
module.exports = Output;
|
||||
@ -1,5 +1,21 @@
|
||||
const mongoose = require('mongoose');
|
||||
const Schema = mongoose.Schema;
|
||||
|
||||
const InputSchema = new Schema({
|
||||
utxo: String,
|
||||
vout: Number,
|
||||
address: String,
|
||||
amount: Number,
|
||||
wallets: { type: [Schema.Types.ObjectId] },
|
||||
});
|
||||
|
||||
const OutputSchema = new Schema({
|
||||
address: String,
|
||||
amount: Number,
|
||||
vout: Number,
|
||||
wallets: { type: [Schema.Types.ObjectId] },
|
||||
});
|
||||
|
||||
const TransactionSchema = new Schema({
|
||||
txid: String,
|
||||
chain: String,
|
||||
@ -7,8 +23,8 @@ const TransactionSchema = new Schema({
|
||||
blockHash: String,
|
||||
blockTime: Date,
|
||||
blockTimeNormalized: Date,
|
||||
inputs: [Input],
|
||||
outputs: [Output],
|
||||
inputs: [InputSchema],
|
||||
outputs: [OutputSchema],
|
||||
coinbase: Boolean,
|
||||
fee: Number,
|
||||
inputsProcessed: Boolean,
|
||||
@ -27,7 +43,12 @@ TransactionSchema.index({ wallets: 1 }, { sparse: true });
|
||||
TransactionSchema.index({ 'inputs.wallets': 1 }, { sparse: true });
|
||||
TransactionSchema.index({ 'outputs.wallets': 1 }, { sparse: true });
|
||||
|
||||
const Block = mongoose.model('Transaction', TransactionSchema);
|
||||
|
||||
module.exports = Block;
|
||||
const Transaction = mongoose.model('Transaction', TransactionSchema);
|
||||
const Input = mongoose.model('Input', InputSchema);
|
||||
const Output = mongoose.model('Output', OutputSchema);
|
||||
|
||||
module.exports = {
|
||||
Transaction,
|
||||
Input,
|
||||
Output
|
||||
};
|
||||
|
||||
Loading…
Reference in New Issue
Block a user