flosight-api/models/block.js
tenthirtyone b028dead40 Initial Commit
Changelog:
Setup & Foundation
- bcoin
- express
- mongo
- eslint
- logging

Status: Bcoin syncs over network, uses a local leveldb to store blocks and checkpoints. Block event saves data to mongo. Express endpoint for block hashes, stubbed to reply with blockhashes until mongo models are finalized.

ToDo:
Move config out of code
2017-08-02 14:51:06 -04:00

34 lines
732 B
JavaScript

const mongoose = require('mongoose');
const Schema = mongoose.Schema;
const BlockSchema = new Schema({
hash: String,
size: Number,
height: Number,
version: Number,
merkleRoot: String,
tx: Array,
time: Date,
nonce: Number,
bits: Number,
difficulty: Number,
chainwork: Number,
confirmations: Number,
previousBlockHash: String,
nextBlockHash: String,
reward: Number,
timeNormalized: Date,
isMainChain: Boolean,
poolInfo: Object,
transactionCount: Number,
});
BlockSchema.index({ hash: 1 }, { unique: true });
BlockSchema.index({ height: 1 });
BlockSchema.index({ time: 1 });
BlockSchema.index({ timeNormalized: 1 });
const Block = mongoose.model('Block', BlockSchema);
module.exports = Block;