Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .bowerrc

This file was deleted.

11 changes: 0 additions & 11 deletions .ctags

This file was deleted.

21 changes: 0 additions & 21 deletions .editorconfig

This file was deleted.

7 changes: 0 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ npm-debug.log
.nodemonignore

.DS_Store
public/lib/*
db/txs/*
db/txs
db/testnet/txs/*
Expand All @@ -37,10 +36,4 @@ db/blocks
db/testnet/blocks/*
db/testnet/blocks

public/js/angularjs-all.js
public/js/main.js
public/js/vendors.js

public/css/main.css

README.html
91 changes: 4 additions & 87 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ module.exports = function(grunt) {
//Load NPM tasks
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-css');
grunt.loadNpmTasks('grunt-mocha-test');
grunt.loadNpmTasks('grunt-nodemon');
grunt.loadNpmTasks('grunt-concurrent');
Expand All @@ -22,37 +19,12 @@ module.exports = function(grunt) {
files: ['README.md'],
tasks: ['markdown']
},
jade: {
files: ['app/views/**'],
options: {
livereload: true,
},
},
js: {
files: ['Gruntfile.js', 'insight.js', 'app/**/*.js', 'public/js/**'],
files: ['Gruntfile.js', 'insight.js', 'app/**/*.js'],
tasks: ['jshint'],
options: {
livereload: true,
},
},
assets: {
files: ['public/src/**/*.js', 'public/**/*.css'],
tasks: ['compile'],
options: {
livereload: true,
},
},
html: {
files: ['public/views/**'],
options: {
livereload: true,
},
},
css: {
files: ['public/css/**'],
options: {
livereload: true
}
},
// we monitor only app/models/* because we have test for models only now
// test: {
Expand All @@ -62,64 +34,12 @@ module.exports = function(grunt) {
},
jshint: {
all: {
src: ['Gruntfile.js', 'insight.js', 'app/**/*.js', 'public/src/js/**/*.js','lib/*.js'],
src: ['Gruntfile.js', 'insight.js', 'app/**/*.js', 'lib/*.js', 'config/*.js'],
options: {
jshintrc: true
}
}
},
concat: {
options: {
process: function(src, filepath) {
if (filepath.substr(filepath.length - 2) === 'js') {
return '// Source: ' + filepath + '\n' +
src.replace(/(^|\n)[ \t]*('use strict'|"use strict");?\s*/g, '$1');
} else {
return src;
}
}
},
vendors: {
src: ['public/lib/momentjs/min/moment.min.js', 'public/lib/qrcode-generator/js/qrcode.js', 'public/lib/zeroclipboard/ZeroClipboard.min.js'],
dest: 'public/js/vendors.js'
},
angular: {
src: ['public/lib/angular/angular.min.js', 'public/lib/angular-resource/angular-resource.min.js', 'public/lib/angular-route/angular-route.min.js', 'public/lib/angular-qrcode/qrcode.js', 'public/lib/angular-animate/angular-animate.min.js', 'public/lib/angular-bootstrap/ui-bootstrap.min.js', 'public/lib/angular-bootstrap/ui-bootstrap-tpls.min.js', 'public/lib/angular-ui-utils/ui-utils.min.js', 'public/lib/ngprogress/build/ngProgress.min.js'],
dest: 'public/js/angularjs-all.js'
},
main: {
src: ['public/src/js/app.js', 'public/src/js/controllers/*.js', 'public/src/js/services/*.js', 'public/src/js/directives.js', 'public/src/js/filters.js', 'public/src/js/config.js', 'public/src/js/init.js'],
dest: 'public/js/main.js'
},
css: {
src: ['public/src/css/**/*.css'],
dest: 'public/css/main.css'
}
},
uglify: {
options: {
banner: '/*! <%= pkg.name %> <%= pkg.version %> */\n',
mangle: false
},
vendors: {
src: 'public/js/vendors.js',
dest: 'public/js/vendors.min.js'
},
angular: {
src: 'public/js/angularjs-all.js',
dest: 'public/js/angularjs-all.min.js'
},
main: {
src: 'public/js/main.js',
dest: 'public/js/main.min.js'
}
},
cssmin: {
css: {
src: 'public/css/main.css',
dest: 'public/css/main.min.css'
}
},
mochaTest: {
options: {
reporter: 'spec',
Expand All @@ -131,7 +51,7 @@ module.exports = function(grunt) {
script: 'insight.js',
options: {
args: [],
ignore: ['public/**/*.html','public/**/*.css', 'public/**/*.js', 'test/**/*','util/**/*', ,'dev-util/**/*'],
ignore: ['test/**/*', 'util/**/*', 'dev-util/**/*'],
// nodeArgs: ['--debug'],
delayTime: 1,
env: {
Expand Down Expand Up @@ -170,10 +90,7 @@ module.exports = function(grunt) {
grunt.option('force', true);

//Default task(s).
grunt.registerTask('default', ['jshint', 'compile', 'concurrent']);

//Compile task (concat + minify)
grunt.registerTask('compile', ['concat', 'uglify', 'cssmin']);
grunt.registerTask('default', ['jshint', 'concurrent']);

//Test task.
grunt.registerTask('test', ['env:test', 'mochaTest']);
Expand Down
29 changes: 13 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
# *insight*
# *insight API*

*insight* is an open-source bitcoin blockchain explorer with complete REST
and websocket APIs. Insight runs in NodeJS, uses AngularJS for the
front-end and LevelDB for storage.
and websocket APIs. Insight runs in NodeJS and use LevelDB for storage.

Check some screenshots and more details at [insight's project homepage](http://insight.bitcore.io).

Expand All @@ -16,7 +15,7 @@ thru the RPC API, Peer-to-peer protocol and will even read its raw .dat files fo

Configure bitcoind to listen to RPC calls and set `txindex` to true.
The easiest way to do this is by copying `./etc/bitcoind/bitcoin.conf` to your
bitcoin data directory (usually `"~/.bitcoin"` on Linux, `"%appdata%\Bitcoin\"` on Windows,
bitcoin data directory (usually `"~/.bitcoin"` on Linux, `"%appdata%\Bitcoin\"` on Windows,
or `"~/Library/Application Support/Bitcoin"` on Mac OS X).

bitcoind must be running and must have finished downloading the blockchain **before** running *insight*.
Expand All @@ -36,7 +35,7 @@ bitcoind must be running and must have finished downloading the blockchain **bef
Install dependencies:

$ npm install

Run the main application:

$ node insight.js
Expand All @@ -48,7 +47,7 @@ bitcoind must be running and must have finished downloading the blockchain **bef
Please note that the app will need to sync its internal database
with the blockchain state, which may take some time. You can check
sync progress from within the web interface.


## Configuration

Expand All @@ -74,11 +73,11 @@ In case the network is changed (testnet to livenet or vice versa) levelDB databa

The initial synchronization process scans the blockchain from the paired bitcoind server to update addresses and balances. *insight* needs one (and only one) trusted bitcoind node to run. This node must have finished downloading the blockchain befure running *insight*.

While *insight* is synchronizing the website can be accessed (the sync process is embedded in the webserver), but there may be missing data or incorrect balances for addresses. The 'sync' status is shown on the top-right of all pages.
While *insight* is synchronizing the website can be accessed (the sync process is embedded in the webserver), but there may be missing data or incorrect balances for addresses. The 'sync' status is shown on the top-right of all pages.

The blockchain can be read from bitcoind's raw `.dat` files or RPC interface. Reading the information from the `.dat` files is much faster so it's the recommended (and default) alternative. `.dat` files are scanned in the default location for each platform. In case a non-standard location is used, it needs to be defined (see the Configuration section). The synchronization type being used can be seen at the [Status page](http://localhost:3001/status). As of February 2014, using `.dat` files the sync process takes 7 hrs. for livenet and 20 mins. for testnet.

While synchronizing the blockchain, *insight* listens for new blocks and transactions relayed by the bitcoind node. Those are also stored on *insight*'s database. In case *insight* is shutdown for a period of time, restarting it will trigger a partial (historic) synchronization of the blockchain. Depending on the size of that synchronization task, a reverse RPC or forward `.dat` syncing strategy will be used.
While synchronizing the blockchain, *insight* listens for new blocks and transactions relayed by the bitcoind node. Those are also stored on *insight*'s database. In case *insight* is shutdown for a period of time, restarting it will trigger a partial (historic) synchronization of the blockchain. Depending on the size of that synchronization task, a reverse RPC or forward `.dat` syncing strategy will be used.

If bitcoind is shutdown, *insight* needs to be stopped and restarted once bitcoind is restarted.

Expand All @@ -95,9 +94,9 @@ If bitcoind is shutdown, *insight* needs to be stopped and restarted once bitcoi

### DB storage requirement

To store the blockchain and address related information, *insight* uses LevelDB. Two DBs are created: txs and blocks. By default these are stored on
```<insight root>/db```
To store the blockchain and address related information, *insight* uses LevelDB. Two DBs are created: txs and blocks. By default these are stored on
```<insight root>/db```

this can be changed on config/config.js. As of February 2014, storing the livenet blockchain takes ~30GB of disk space (2GB for the testnet).

## Development
Expand All @@ -106,10 +105,6 @@ To run insight locally for development with grunt:

```$ NODE_ENV=development grunt```

To compile and minify the web application's assets:

```$ grunt compile```

To run the tests

```$ grunt test```
Expand All @@ -120,7 +115,9 @@ Contributions and suggestions are welcomed at [insight github repository](https:

## API

A REST API is provided at /api. The entry points are:
By default, insight provides a REST API at /api, but this prefix is configurable from the var `apiPrefix` in the `config.js` file.

The end-points are:


### Block
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/addresses.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ var getAddr = function(req, res, next) {
exports.show = function(req, res, next) {
var a = getAddr(req, res, next);

if (a)
if (a)
a.update(function(err) {
if (err) {
return common.handleErrors(err, res);
Expand All @@ -39,7 +39,7 @@ exports.show = function(req, res, next) {
exports.utxo = function(req, res, next) {
var a = getAddr(req, res, next);

if (a)
if (a)
a.getUtxo(function(err, utxo) {
if (err)
return common.handleErrors(err, res);
Expand Down
12 changes: 9 additions & 3 deletions app/controllers/index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
'use strict';

var _getVersion = function() {
var pjson = require('../../package.json');
return pjson.version;
};

exports.render = function(req, res) {
res.render('index');
var version = _getVersion();
res.send('insight API v' + version);
};

exports.version = function(req, res) {
var pjson = require('../../package.json');
res.json({version: pjson.version});
var version = _getVersion();
res.json({ version: version });
};

2 changes: 1 addition & 1 deletion app/controllers/socket.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ module.exports.broadcastTx = function(tx) {
t = {
txid: tx
};
}
}

else {
t = {
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/transactions.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ var getTransaction = function(txid, cb) {
if (err) console.log(err);

if (!tx || !tx.info) {
console.log('[transactions.js.48]:: TXid %s not found in RPC. CHECK THIS.', txid);
console.log('[transactions.js.48]:: TXid %s not found in RPC. CHECK THIS.', txid);
return ({ txid: txid });
}

Expand Down
12 changes: 0 additions & 12 deletions app/views/404.jade

This file was deleted.

12 changes: 0 additions & 12 deletions app/views/500.jade

This file was deleted.

7 changes: 0 additions & 7 deletions app/views/includes/foot.jade

This file was deleted.

22 changes: 0 additions & 22 deletions app/views/includes/head.jade

This file was deleted.

1 change: 0 additions & 1 deletion app/views/includes/navbar.jade

This file was deleted.

Loading