Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 9d8b731
Showing
355 changed files
with
347,855 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
lib-cov | ||
|
||
# Coverage directory used by tools like istanbul | ||
coverage | ||
|
||
# nyc test coverage | ||
.nyc_output | ||
|
||
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) | ||
.grunt | ||
|
||
# node-waf configuration | ||
.lock-wscript | ||
|
||
# Compiled binary addons (http://nodejs.org/api/addons.html) | ||
build/Release | ||
|
||
# Dependency directories | ||
node_modules | ||
jspm_packages | ||
|
||
# Optional npm cache directory | ||
.npm | ||
|
||
# Optional REPL history | ||
.node_repl_history | ||
|
||
# local data | ||
data/ | ||
.node-xmlhttprequest-* | ||
.node-xml* | ||
package-lock.json | ||
public/js/stats/The_bomb_chart.js | ||
.gitattributes | ||
.vscode/launch.json | ||
.vscode/settings.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
FROM node:latest | ||
|
||
COPY . / | ||
|
||
RUN npm i | ||
|
||
EXPOSE 3000 | ||
|
||
ENTRYPOINT ["node"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# BlockScan | ||
|
||
## Local installation | ||
|
||
Clone the repo | ||
|
||
Download [Nodejs and npm](https://docs.npmjs.com/getting-started/installing-node "Nodejs install") if you don't have them | ||
|
||
Install dependencies: | ||
|
||
`npm install` | ||
|
||
Install mongodb: | ||
|
||
MacOS: `brew install mongodb` | ||
|
||
Centos: `yum install -y mongodb` | ||
|
||
Ubuntu: `sudo apt-get install -y mongodb-org` | ||
|
||
|
||
## Config RPC and Populate the DB | ||
|
||
This will fetch and parse the entire blockchain. | ||
|
||
modify the var "config" (near the file end) like follow basic settings: | ||
-------------- | ||
var config = | ||
{ | ||
"rpc": 'http://localhost:8545', | ||
"blocks": [ {"start": 0, "end": "latest"}], | ||
"quiet": true, | ||
"terminateAtExistingDB": false, | ||
"listenOnly": false,//false:graber interval. true:grabe by listen new block. | ||
"out": "." | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
#!/usr/bin/env node | ||
//给console.log()增加时间戳 | ||
(function() { //add timestamp to console.log and console.error(from http://yoyo.play175.com) | ||
var date = new Date(); | ||
|
||
function timeFlag() { | ||
date.setTime(Date.now()); | ||
var m = date.getMonth() + 1; | ||
var d = date.getDate(); | ||
var hour = date.getHours(); | ||
var minutes = date.getMinutes(); | ||
var seconds = date.getSeconds(); | ||
var milliseconds = date.getMilliseconds(); | ||
return '[' + ((m < 10) ? '0' + m : m) + '-' + ((d < 10) ? '0' + d : d) + | ||
' ' + ((hour < 10) ? '0' + hour : hour) + ':' + ((minutes < 10) ? '0' + minutes : minutes) + | ||
':' + ((seconds < 10) ? '0' + seconds : seconds) + '.' + ('00' + milliseconds).slice(-3) + '] '; | ||
} | ||
var log = console.log; | ||
console.error = console.log = function() { | ||
var prefix = ''; //cluster.isWorker ? '[WORKER '+cluster.worker.id + '] ' : '[MASTER]'; | ||
if (typeof(arguments[0]) == 'string') { | ||
var first_parameter = arguments[0]; //for this:console.log("%s","str"); | ||
var other_parameters = Array.prototype.slice.call(arguments, 1); | ||
log.apply(console, [prefix + timeFlag() + first_parameter].concat(other_parameters)); | ||
} else { | ||
var args = Array.prototype.slice.call(arguments); | ||
log.apply(console, [prefix + timeFlag()].concat(args)); | ||
} | ||
} | ||
})(); | ||
|
||
require( './db' ); | ||
|
||
var express = require('express'); | ||
var path = require('path'); | ||
var favicon = require('serve-favicon'); | ||
var logger = require('morgan'); | ||
var bodyParser = require('body-parser'); | ||
|
||
var app = express(); | ||
app.set('port', process.env.PORT || 3000); | ||
|
||
// view engine setup | ||
app.set('views', path.join(__dirname, 'views')); | ||
app.set('view engine', 'ejs'); | ||
|
||
// app.use(favicon(__dirname + '/public/favicon.ico')); | ||
// app.use(logger('dev')); | ||
app.use(bodyParser.json()); | ||
app.use(bodyParser.urlencoded({ extended: true })); | ||
app.use(express.static(path.join(__dirname, 'public'))); | ||
|
||
// app libraries | ||
global.__lib = __dirname + '/lib/'; | ||
|
||
|
||
// client | ||
|
||
app.get('/', function(req, res) { | ||
res.render('index'); | ||
}); | ||
require('./routes')(app); | ||
|
||
// let angular catch them | ||
app.use(function(req, res) { | ||
res.render('index'); | ||
}); | ||
|
||
// error handlers | ||
|
||
// development error handler | ||
// will print stacktrace | ||
if (app.get('env') === 'development') { | ||
app.use(function(err, req, res, next) { | ||
res.status(err.status || 500); | ||
res.render('error', { | ||
message: err.message, | ||
error: err | ||
}); | ||
}); | ||
} | ||
|
||
|
||
// production error handler | ||
// no stacktraces leaked to user | ||
app.use(function(err, req, res, next) { | ||
res.status(err.status || 500); | ||
res.render('error', { | ||
message: err.message, | ||
error: {} | ||
}); | ||
}); | ||
|
||
//var io = require('socket.io')(http); | ||
// web3socket(io); | ||
|
||
var http = require('http').Server(app); | ||
http.listen(app.get('port'), '0.0.0.0', function() { | ||
console.log('Express server listening on port ' + app.get('port')); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"rpc": "https://testnet.xinfin.network", | ||
"blocks": [ {"start": 7444859, "end": "latest"}], | ||
"quiet": true, | ||
"terminateAtExistingDB": false, | ||
"listenOnly": false, | ||
"out": "." | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
var mongoose = require( 'mongoose' ); | ||
var Schema = mongoose.Schema; | ||
|
||
var DAOCreatedToken = new Schema( | ||
{ | ||
"transactionHash": {type: String, index: {unique: true}}, | ||
"blockNumber": {type: Number, index: {unique: false}}, | ||
"amount": String, | ||
"to": String, | ||
"timestamp": Number | ||
}); | ||
|
||
var DAOTransferToken = new Schema( | ||
{ | ||
"transactionHash": {type: String, index: {unique: true}}, | ||
"blockNumber": {type: Number, index: {unique: false}}, | ||
"amount": String, | ||
"to": String, | ||
"from": String, | ||
"timestamp": Number | ||
}); | ||
|
||
mongoose.model('DAOCreatedToken', DAOCreatedToken); | ||
mongoose.model('DAOTransferToken', DAOTransferToken); | ||
module.exports.DAOCreatedToken = mongoose.model('DAOCreatedToken'); | ||
module.exports.DAOTransferToken = mongoose.model('DAOTransferToken'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/****** | ||
DEPRECATED -- DO NOT USE | ||
*******/ | ||
var mongoose = require( 'mongoose' ); | ||
var Schema = mongoose.Schema; | ||
|
||
var InternalTransaction = new Schema( | ||
{ | ||
"type": String, | ||
"action": { | ||
"from": String, // for call | ||
"to": String, | ||
"value": String, | ||
"gas": Number, | ||
"input":String, | ||
"callType":String, | ||
"init": String, // for create | ||
"address": String, // for suicide | ||
"refundAddress": String, | ||
"balance": String | ||
}, | ||
"result": { | ||
"gasUsed":Number, | ||
"output":String, | ||
"code": String, | ||
"address": String | ||
}, | ||
"error": String, | ||
"traceAddress":[String], | ||
"subtraces":Number, | ||
"transactionPosition":Number, | ||
"transactionHash": {type: String, index: {unique: false}}, // parent transaction | ||
"blockNumber":{type: Number, index: {unique: false}}, | ||
"timestamp": Number, | ||
"blockHash":String | ||
}); | ||
|
||
mongoose.model('InternalTransaction', InternalTransaction); | ||
module.exports.InternalTransaction = mongoose.model('InternalTransaction'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
var mongoose = require( 'mongoose' ); | ||
var Schema = mongoose.Schema; | ||
|
||
var BlockStat = new Schema( | ||
{ | ||
"number": {type: Number, index: {unique: true}}, | ||
"timestamp": Number, | ||
"difficulty": String, | ||
"hashrate": String, | ||
"txCount": Number, | ||
"gasUsed": Number, | ||
"gasLimit": Number, | ||
"miner": String, | ||
"blockTime": Number, | ||
"uncleCount": Number | ||
}, { capped: { size: 512000, max: 1000}}); | ||
|
||
|
||
mongoose.model('BlockStat', BlockStat); | ||
module.exports.BlockStat = mongoose.model('BlockStat'); |
Oops, something went wrong.