<commit_before>const mongoose = require('mongoose');
const Schema = mongoose.Schema;
const async = require('async');
const _ = require('underscore');

const config = require('../config');
const Transaction = mongoose.model('Transaction');
const Coin = mongoose.model('Coin');

const BlockSchema = new Schema({
  network: String,
  height: Number,
  hash: String,
  version: Number,
  merkleRoot: String,
  time: Date,
  timeNormalized: Date,
  nonce: Number,
  previousBlockHash: String,
  nextBlockHash: String,
  transactionCount: Number,
  size: Number,
  bits: Number,
  reward: Number,
  processed: Boolean
});

BlockSchema.index({hash: 1});
BlockSchema.index({height: 1});
BlockSchema.index({timeNormalized: 1});
BlockSchema.index({previousBlockHash: 1});

BlockSchema.statics.addBlock = function(block, callback){
  let header = block.header.toObject();
  let blockTime = header.time * 1000;
  let blockTimeNormalized;
  let height;<commit_msg>adding index and fixing nLocktime<commit_after>const mongoose = require('mongoose');
const Schema = mongoose.Schema;
const async = require('async');
const _ = require('underscore');

const config = require('../config');
const Transaction = mongoose.model('Transaction');
const Coin = mongoose.model('Coin');

const BlockSchema = new Schema({
  network: String,
  height: Number,
  hash: String,
  version: Number,
  merkleRoot: String,
  time: Date,
  timeNormalized: Date,
  nonce: Number,
  previousBlockHash: String,
  nextBlockHash: String,
  transactionCount: Number,
  size: Number,
  bits: Number,
  reward: Number,
  processed: Boolean
});

BlockSchema.index({hash: 1});
BlockSchema.index({height: 1});
BlockSchema.index({timeNormalized: 1});
BlockSchema.index({previousBlockHash: 1});
BlockSchema.index({processed: 1, network:1, height: -1});

BlockSchema.statics.addBlock = function(block, callback){
  let header = block.header.toObject();
  let blockTime = header.time * 1000;
  let blockTimeNormalized;
  let height;
{'fraction_non_alphanumeric': 0.13636363636363635, 'fraction_numerical': 0.009595959595959595, 'mean_word_length': 5.516447368421052, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7515238', 'n_tokens_mistral': 618, 'n_tokens_neox': 608, 'n_words': 160}