Merge remote-tracking branch 'bitpay/master' into feature/prototype-p2p
This commit is contained in:
commit
4cb232e5ca
15
README.md
15
README.md
|
@ -48,7 +48,6 @@ $ npm install -g bower
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## API
|
|
||||||
|
|
||||||
## Prerequisites
|
## Prerequisites
|
||||||
Get bitcore from github repository:
|
Get bitcore from github repository:
|
||||||
|
@ -62,21 +61,23 @@ $ npm install -g bower
|
||||||
check utils/sync.js --help for options.
|
check utils/sync.js --help for options.
|
||||||
|
|
||||||
|
|
||||||
|
## API
|
||||||
|
|
||||||
|
A REST API is provided at /api. The entry points are:
|
||||||
|
|
||||||
### Blocks
|
### Blocks
|
||||||
```
|
```
|
||||||
/block/[:hash]
|
/api/block/[:hash]
|
||||||
/block/00000000a967199a2fad0877433c93df785a8d8ce062e5f9b451cd1397bdbf62
|
/api/block/00000000a967199a2fad0877433c93df785a8d8ce062e5f9b451cd1397bdbf62
|
||||||
```
|
```
|
||||||
### Transactions
|
### Transactions
|
||||||
```
|
```
|
||||||
/tx/[:txid]
|
/api/tx/[:txid]
|
||||||
/tx/525de308971eabd941b139f46c7198b5af9479325c2395db7f2fb5ae8562556c
|
/api/tx/525de308971eabd941b139f46c7198b5af9479325c2395db7f2fb5ae8562556c
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Troubleshooting
|
## Troubleshooting
|
||||||
If you did not get all library during grunt command, please use the follow command:
|
If you did not get all library during grunt command, please use the follow command:
|
||||||
|
|
||||||
|
|
|
@ -1,15 +1,13 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
|
||||||
var Block = require('../models/Block');
|
|
||||||
//, _ = require('lodash');
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Module dependencies.
|
* Module dependencies.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
var mongoose = require('mongoose'),
|
||||||
|
Block = mongoose.model('Block');
|
||||||
|
//, _ = require('lodash');
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find block by hash ...
|
* Find block by hash ...
|
||||||
|
@ -31,3 +29,41 @@ exports.show = function(req, res) {
|
||||||
res.jsonp(req.block);
|
res.jsonp(req.block);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List of blocks at HomePage
|
||||||
|
*/
|
||||||
|
exports.last_blocks = function(req, res) {
|
||||||
|
Block.find().sort({time:-1}).limit(7).exec(function(err, blocks) {
|
||||||
|
if (err) {
|
||||||
|
res.render('error', {
|
||||||
|
status: 500
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
res.jsonp(blocks);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List of blocks by date
|
||||||
|
*/
|
||||||
|
exports.list = function(req, res) {
|
||||||
|
var findParam = {};
|
||||||
|
|
||||||
|
if (req.query.blockDate) {
|
||||||
|
findParam = {};
|
||||||
|
}
|
||||||
|
|
||||||
|
Block
|
||||||
|
.find(findParam)
|
||||||
|
.limit(5)
|
||||||
|
.exec(function(err, blocks) {
|
||||||
|
if (err) {
|
||||||
|
res.render('error', {
|
||||||
|
status: 500
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
res.jsonp(blocks);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
|
@ -19,6 +19,7 @@ var BlockSchema = new Schema({
|
||||||
unique: true,
|
unique: true,
|
||||||
},
|
},
|
||||||
size: Number,
|
size: Number,
|
||||||
|
height: Number,
|
||||||
confirmations: Number,
|
confirmations: Number,
|
||||||
version: Number,
|
version: Number,
|
||||||
merkleroot: String,
|
merkleroot: String,
|
||||||
|
@ -93,5 +94,4 @@ BlockSchema.statics.fromHash = function(hash, cb) {
|
||||||
}).exec(cb);
|
}).exec(cb);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
module.exports = mongoose.model('Block', BlockSchema);
|
module.exports = mongoose.model('Block', BlockSchema);
|
||||||
|
|
|
@ -23,9 +23,12 @@ script(type='text/javascript', src='/js/directives.js')
|
||||||
script(type='text/javascript', src='/js/filters.js')
|
script(type='text/javascript', src='/js/filters.js')
|
||||||
|
|
||||||
//Application Services
|
//Application Services
|
||||||
|
script(type='text/javascript', src='/js/services/blocks.js')
|
||||||
script(type='text/javascript', src='/js/services/global.js')
|
script(type='text/javascript', src='/js/services/global.js')
|
||||||
|
script(type='text/javascript', src='/js/services/index.js')
|
||||||
|
|
||||||
//Application Controllers
|
//Application Controllers
|
||||||
script(type='text/javascript', src='/js/controllers/index.js')
|
script(type='text/javascript', src='/js/controllers/index.js')
|
||||||
script(type='text/javascript', src='/js/controllers/header.js')
|
script(type='text/javascript', src='/js/controllers/header.js')
|
||||||
|
script(type='text/javascript', src='/js/controllers/blocks.js')
|
||||||
script(type='text/javascript', src='/js/init.js')
|
script(type='text/javascript', src='/js/init.js')
|
||||||
|
|
|
@ -2,24 +2,3 @@ extends layouts/default
|
||||||
|
|
||||||
block content
|
block content
|
||||||
section.container(data-ng-view)
|
section.container(data-ng-view)
|
||||||
|
|
||||||
section.container
|
|
||||||
p ˈmɪst(ə)ri/'
|
|
||||||
| noun
|
|
||||||
audio(src="https://ssl.gstatic.com/dictionary/static/sounds/de/0/mystery.mp3",preload="auto",data-dobid="aud",id="aud")
|
|
||||||
button(onclick="document.getElementById('aud').play()") Play
|
|
||||||
|
|
||||||
ol
|
|
||||||
li
|
|
||||||
strong something that is difficult or impossible to understand or explain.
|
|
||||||
p "the mysteries of outer space"
|
|
||||||
| synonyms: puzzle, enigma, conundrum, riddle, secret, unsolved problem, problem, question, question mark, closed book; secrecy or obscurity.
|
|
||||||
p "much of her past is shrouded in mystery"
|
|
||||||
| synonyms: secrecy, darkness, obscurity, ambiguity, ambiguousness, uncertainty, impenetrability, vagueness, nebulousness; More
|
|
||||||
li
|
|
||||||
strong a person or thing whose identity or nature is puzzling or unknown.
|
|
||||||
p "‘He's a bit of a mystery,’ said Nina"
|
|
||||||
li
|
|
||||||
strong a novel, play, or film dealing with a puzzling crime, especially a murder.
|
|
||||||
p "the 1920s murder mystery, The Ghost Train"
|
|
||||||
| synonyms: thriller, detective story/novel, murder story; More
|
|
||||||
|
|
|
@ -8,8 +8,10 @@ module.exports = function(app) {
|
||||||
|
|
||||||
//Block routes
|
//Block routes
|
||||||
var blocks = require('../app/controllers/blocks');
|
var blocks = require('../app/controllers/blocks');
|
||||||
app.get('/block/:blockHash', blocks.show);
|
app.get('/api/blocks', blocks.list);
|
||||||
|
app.get('/api/block/:blockHash', blocks.show);
|
||||||
app.param('blockHash', blocks.block);
|
app.param('blockHash', blocks.block);
|
||||||
|
app.get('/last_blocks', blocks.last_blocks);
|
||||||
|
|
||||||
var transactions = require('../app/controllers/transactions');
|
var transactions = require('../app/controllers/transactions');
|
||||||
app.get('/tx/:txid', transactions.show);
|
app.get('/tx/:txid', transactions.show);
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
angular.module('mystery', ['ngCookies', 'ngResource', 'ngRoute', 'ui.bootstrap', 'ui.route', 'mystery.system']);
|
angular.module('mystery', ['ngCookies', 'ngResource', 'ngRoute', 'ui.bootstrap', 'ui.route', 'mystery.system', 'mystery.index', 'mystery.blocks']);
|
||||||
|
|
||||||
angular.module('mystery.system', []);
|
angular.module('mystery.system', []);
|
||||||
|
angular.module('mystery.index', []);
|
||||||
|
angular.module('mystery.blocks', []);
|
||||||
|
|
|
@ -4,9 +4,18 @@
|
||||||
angular.module('mystery').config(['$routeProvider',
|
angular.module('mystery').config(['$routeProvider',
|
||||||
function($routeProvider) {
|
function($routeProvider) {
|
||||||
$routeProvider.
|
$routeProvider.
|
||||||
|
when('/block/:blockHash', {
|
||||||
|
templateUrl: 'views/block.html'
|
||||||
|
}).
|
||||||
when('/', {
|
when('/', {
|
||||||
templateUrl: 'views/index.html'
|
templateUrl: 'views/index.html'
|
||||||
}).
|
}).
|
||||||
|
when('/blocks', {
|
||||||
|
templateUrl: 'views/blocks/list.html'
|
||||||
|
}).
|
||||||
|
when('/blocks-date/:blockDate', {
|
||||||
|
templateUrl: 'views/blocks/list_date.html'
|
||||||
|
}).
|
||||||
otherwise({
|
otherwise({
|
||||||
redirectTo: '/'
|
redirectTo: '/'
|
||||||
});
|
});
|
||||||
|
|
|
@ -0,0 +1,30 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
angular.module('mystery.blocks').controller('BlocksController', ['$scope', '$routeParams', '$location', 'Global', 'Block', 'Blocks', function ($scope, $routeParams, $location, Global, Block, Blocks) {
|
||||||
|
$scope.global = Global;
|
||||||
|
|
||||||
|
$scope.list_blocks = function() {
|
||||||
|
Blocks.query(function(blocks) {
|
||||||
|
$scope.blocks = blocks;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
$scope.list_blocks_date = function() {
|
||||||
|
Blocks.query({
|
||||||
|
blockDate: $routeParams.blockDate
|
||||||
|
}, function(blocks) {
|
||||||
|
$scope.blocks = blocks;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
$scope.findOne = function() {
|
||||||
|
Block.get({
|
||||||
|
blockHash: $routeParams.blockHash
|
||||||
|
}, function(block) {
|
||||||
|
$scope.block = block;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
// for avoid warning. please remove when you use Blocks
|
||||||
|
$scope.blocks = Blocks;
|
||||||
|
}]);
|
|
@ -4,11 +4,8 @@ angular.module('mystery.system').controller('HeaderController', ['$scope', 'Glob
|
||||||
$scope.global = Global;
|
$scope.global = Global;
|
||||||
|
|
||||||
$scope.menu = [{
|
$scope.menu = [{
|
||||||
'title': 'Articles',
|
'title': 'Blocks',
|
||||||
'link': 'articles'
|
'link': 'blocks'
|
||||||
}, {
|
|
||||||
'title': 'Create New Article',
|
|
||||||
'link': 'articles/create'
|
|
||||||
}];
|
}];
|
||||||
|
|
||||||
$scope.isCollapsed = false;
|
$scope.isCollapsed = false;
|
||||||
|
|
|
@ -1,5 +1,10 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
angular.module('mystery.system').controller('IndexController', ['$scope', 'Global', function ($scope, Global) {
|
angular.module('mystery.system').controller('IndexController', ['$scope', 'Global', 'Index', function ($scope, Global, Index) {
|
||||||
$scope.global = Global;
|
$scope.global = Global;
|
||||||
|
$scope.last_blocks = function() {
|
||||||
|
Index.query(function(blocks) {
|
||||||
|
$scope.blocks = blocks;
|
||||||
|
});
|
||||||
|
};
|
||||||
}]);
|
}]);
|
|
@ -0,0 +1,11 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
angular.module('mystery.blocks').factory('Block', ['$resource', function($resource) {
|
||||||
|
return $resource('/api/block/:blockHash', {
|
||||||
|
blockHash: '@blockHash'
|
||||||
|
});
|
||||||
|
}]);
|
||||||
|
|
||||||
|
angular.module('mystery.blocks').factory('Blocks', ['$resource', function($resource) {
|
||||||
|
return $resource('/api/blocks');
|
||||||
|
}]);
|
|
@ -0,0 +1,5 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
angular.module('mystery.index').factory('Index', ['$resource', function($resource) {
|
||||||
|
return $resource('/last_blocks');
|
||||||
|
}]);
|
|
@ -0,0 +1,23 @@
|
||||||
|
<section data-ng-controller="BlocksController" data-ng-init="findOne()">
|
||||||
|
<div class="page-header">
|
||||||
|
<h1>Block Page</h1>
|
||||||
|
</div>
|
||||||
|
<table class="table table-striped">
|
||||||
|
<thead>
|
||||||
|
<th>Height</th>
|
||||||
|
<th>Age</th>
|
||||||
|
<th>Transactions</th>
|
||||||
|
<th>Confirmations</th>
|
||||||
|
<th>Size (kB)</th>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td>{{block.height}}</td>
|
||||||
|
<td>{{block.time | date:'short'}}</td>
|
||||||
|
<td>{{block.tx.length }}</td>
|
||||||
|
<td>{{block.confirmations}}</td>
|
||||||
|
<td>{{block.size / 1024}}</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</section>
|
|
@ -0,0 +1,10 @@
|
||||||
|
<section data-ng-controller="BlocksController" data-ng-init="list_blocks()">
|
||||||
|
<div class="page-header">
|
||||||
|
<h1>Blocks by Date</h1>
|
||||||
|
</div>
|
||||||
|
<ul>
|
||||||
|
<li data-ng-repeat="block in blocks">
|
||||||
|
<span>{{block.hash}}</span> {{block.time}}
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</section>
|
|
@ -0,0 +1,10 @@
|
||||||
|
<section data-ng-controller="BlocksController" data-ng-init="list_blocks_date()">
|
||||||
|
<div class="page-header">
|
||||||
|
<h1>Blocks by defined date</h1>
|
||||||
|
</div>
|
||||||
|
<ul>
|
||||||
|
<li data-ng-repeat="block in blocks">
|
||||||
|
<span>{{block.hash}}</span> {{block.time}}
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</section>
|
|
@ -6,13 +6,13 @@
|
||||||
<span class="icon-bar"></span>
|
<span class="icon-bar"></span>
|
||||||
<span class="icon-bar"></span>
|
<span class="icon-bar"></span>
|
||||||
</button>
|
</button>
|
||||||
<a class="navbar-brand" href="#">Mystery</a>
|
<a class="navbar-brand" href="#!">Mystery</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="collapse navbar-collapse">
|
<div class="collapse navbar-collapse">
|
||||||
<ul class="nav navbar-nav">
|
<ul class="nav navbar-nav">
|
||||||
<li class="active"><a href="#">Home</a></li>
|
<li data-ng-repeat="item in menu" ui-route="/{{item.link}}" ng-class="{active: $uiRoute}">
|
||||||
<li><a href="#about">About</a></li>
|
<a href="#!/{{item.link}}">{{item.title}}</a>
|
||||||
<li><a href="#contact">Contact</a></li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,5 +1,23 @@
|
||||||
<section data-ng-controller="IndexController">
|
<section data-ng-controller="IndexController" data-ng-init="last_blocks()">
|
||||||
<div class="page-header">
|
<div class="page-header">
|
||||||
<h1>Hello BitPay!</h1>
|
<h1>Hello BitPay!</h1>
|
||||||
</div>
|
</div>
|
||||||
|
<table class="table table-striped">
|
||||||
|
<thead>
|
||||||
|
<th>Height</th>
|
||||||
|
<th>Age</th>
|
||||||
|
<th>Transactions</th>
|
||||||
|
<th>Confirmations</th>
|
||||||
|
<th>Size (kB)</th>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr data-ng-repeat="block in blocks">
|
||||||
|
<td><a href="#!/block/{{block.hash}}">{{block.height}}</a></td>
|
||||||
|
<td>{{block.time | date:'short'}}</td>
|
||||||
|
<td>{{block.tx.length }}</td>
|
||||||
|
<td>{{block.confirmations}}</td>
|
||||||
|
<td>{{block.size / 1024}}</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
</section>
|
</section>
|
||||||
|
|
Loading…
Reference in New Issue