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) {
|
function processBlock(entry, block, cb) {
|
||||||
block.hash = util.revHex(block.hash().toString('hex'));
|
block.hash = util.revHex(block.hash().toString('hex'));
|
||||||
const b = new BlockModel({
|
const newBlock = new BlockModel({
|
||||||
hash: block.hash,
|
hash: block.hash,
|
||||||
size: block.size,
|
size: block.size,
|
||||||
height: block.height,
|
height: block.height,
|
||||||
@ -47,7 +47,7 @@ function processBlock(entry, block, cb) {
|
|||||||
transactionCount: block.txs.length,
|
transactionCount: block.txs.length,
|
||||||
});
|
});
|
||||||
|
|
||||||
b.save((err) => {
|
newBlock.save((err) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.log(err.message);
|
console.log(err.message);
|
||||||
}
|
}
|
||||||
@ -55,8 +55,21 @@ function processBlock(entry, block, cb) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function processTx(tx) {
|
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 = {
|
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 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({
|
const TransactionSchema = new Schema({
|
||||||
txid: String,
|
txid: String,
|
||||||
chain: String,
|
chain: String,
|
||||||
@ -7,8 +23,8 @@ const TransactionSchema = new Schema({
|
|||||||
blockHash: String,
|
blockHash: String,
|
||||||
blockTime: Date,
|
blockTime: Date,
|
||||||
blockTimeNormalized: Date,
|
blockTimeNormalized: Date,
|
||||||
inputs: [Input],
|
inputs: [InputSchema],
|
||||||
outputs: [Output],
|
outputs: [OutputSchema],
|
||||||
coinbase: Boolean,
|
coinbase: Boolean,
|
||||||
fee: Number,
|
fee: Number,
|
||||||
inputsProcessed: Boolean,
|
inputsProcessed: Boolean,
|
||||||
@ -27,7 +43,12 @@ TransactionSchema.index({ wallets: 1 }, { sparse: true });
|
|||||||
TransactionSchema.index({ 'inputs.wallets': 1 }, { sparse: true });
|
TransactionSchema.index({ 'inputs.wallets': 1 }, { sparse: true });
|
||||||
TransactionSchema.index({ 'outputs.wallets': 1 }, { sparse: true });
|
TransactionSchema.index({ 'outputs.wallets': 1 }, { sparse: true });
|
||||||
|
|
||||||
const Block = mongoose.model('Transaction', TransactionSchema);
|
const Transaction = mongoose.model('Transaction', TransactionSchema);
|
||||||
|
const Input = mongoose.model('Input', InputSchema);
|
||||||
module.exports = Block;
|
const Output = mongoose.model('Output', OutputSchema);
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
Transaction,
|
||||||
|
Input,
|
||||||
|
Output
|
||||||
|
};
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user