forked from ethereumclassic/explorer
-
Notifications
You must be signed in to change notification settings - Fork 3
/
db.js
62 lines (57 loc) · 1.54 KB
/
db.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
var mongoose = require( 'mongoose' );
var Schema = mongoose.Schema;
var Block = new Schema(
{
"number": {type: Number, index: {unique: true}},
"hash": String,
"parentHash": String,
"nonce": String,
"sha3Uncles": String,
"logsBloom": String,
"transactionsRoot": String,
"stateRoot": String,
"receiptRoot": String,
"miner": String,
"difficulty": String,
"totalDifficulty": String,
"size": Number,
"extraData": String,
"gasLimit": Number,
"gasUsed": Number,
"timestamp": Number,
"uncles": [String]
});
var Contract = new Schema(
{
"address": {type: String, index: {unique: true}},
"creationTransaction": String,
"contractName": String,
"compilerVersion": String,
"optimization": Boolean,
"sourceCode": String,
"abi": String,
"byteCode": String
}, {collection: "Contract"});
var Transaction = new Schema(
{
"hash": {type: String, index: {unique: true}},
"nonce": Number,
"blockHash": String,
"blockNumber": Number,
"transactionIndex": Number,
"from": String,
"to": String,
"value": String,
"gas": Number,
"gasPrice": String,
"timestamp": Number,
"input": String
});
mongoose.model('Block', Block);
mongoose.model('Contract', Contract);
mongoose.model('Transaction', Transaction);
module.exports.Block = mongoose.model('Block');
module.exports.Contract = mongoose.model('Contract');
module.exports.Transaction = mongoose.model('Transaction');
mongoose.connect( 'mongodb://localhost/blockDB' );
mongoose.set('debug', true);