Skip to content

Commit 8c2e118

Browse files
committed
Merge branch 'master' of github.com:bitpay/mystery into test/test-p2p-sync
2 parents 87913a8 + 8c420d6 commit 8c2e118

File tree

10 files changed

+286
-112
lines changed

10 files changed

+286
-112
lines changed

app/controllers/status.js

+12-6
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,11 @@
55
*/
66

77
var Status = require('../models/Status');
8-
var async = require('async');
98

109
/**
1110
* Status
1211
*/
13-
exports.show = function(req, res) {
12+
exports.show = function(req, res, next) {
1413

1514
if (! req.query.q) {
1615
res.status(400).send('Bad Request');
@@ -19,30 +18,37 @@ exports.show = function(req, res) {
1918
var s = req.query.q;
2019
var d = Status.new();
2120

22-
if (s == 'getInfo') {
21+
if (s === 'getInfo') {
2322
d.getInfo(function(err) {
2423
if (err) next(err);
2524
res.jsonp(d);
2625
});
2726
}
28-
else if (s == 'getDifficulty') {
27+
else if (s === 'getDifficulty') {
2928
d.getDifficulty(function(err) {
3029
if (err) next(err);
3130
res.jsonp(d);
3231
});
3332
}
34-
else if (s == 'getTxOutSetInfo') {
33+
else if (s === 'getTxOutSetInfo') {
3534
d.getTxOutSetInfo(function(err) {
3635
if (err) next(err);
3736
res.jsonp(d);
3837
});
3938
}
40-
else if (s == 'getBestBlockHash') {
39+
else if (s === 'getBestBlockHash') {
4140
d.getBestBlockHash(function(err) {
4241
if (err) next(err);
4342
res.jsonp(d);
4443
});
4544
}
45+
else if (s === 'getLastBlockHash') {
46+
d.getLastBlockHash(function(err) {
47+
if (err) next(err);
48+
res.jsonp(d);
49+
});
50+
}
51+
4652
else {
4753
res.status(400).send('Bad Request');
4854
}

app/models/Status.js

+26
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ function spec() {
1313
this.difficulty = {};
1414
this.txoutsetinfo = {};
1515
this.bestblockhash = {};
16+
this.lastblockhash = {};
1617
}
1718

1819
Status.prototype.getInfo = function(next) {
@@ -79,6 +80,31 @@ function spec() {
7980
});
8081
};
8182

83+
Status.prototype.getLastBlockHash = function(next) {
84+
var that = this;
85+
86+
async.waterfall(
87+
[
88+
function(callback){
89+
rpc.getBlockCount(function(err, bc){
90+
if (err) return callback(err);
91+
callback(null, bc.result);
92+
});
93+
},
94+
function(bc, callback){
95+
rpc.getBlockHash(bc, function(err, bh){
96+
if (err) return callback(err);
97+
callback(null, bh.result);
98+
});
99+
}
100+
],
101+
function (err, result) {
102+
that.lastblockhash = result;
103+
return next();
104+
}
105+
);
106+
};
107+
82108
return Status;
83109

84110
}

app/views/includes/foot.jade

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
//script(type='text/javascript', src='/lib/jquery/jquery.min.js')
66
//script(type='text/javascript', src='/lib/bootstrap/dist/js/bootstrap.min.js')
7+
script(type='text/javascript', src='/socket.io/socket.io.js')
78
script(type='text/javascript', src='/lib/momentjs/moment.js')
89

910
//AngularJS
@@ -27,11 +28,11 @@ script(type='text/javascript', src='/js/directives.js')
2728
script(type='text/javascript', src='/js/filters.js')
2829

2930
//Application Services
31+
script(type='text/javascript', src='/js/services/global.js')
3032
script(type='text/javascript', src='/js/services/status.js')
3133
script(type='text/javascript', src='/js/services/address.js')
3234
script(type='text/javascript', src='/js/services/transactions.js')
3335
script(type='text/javascript', src='/js/services/blocks.js')
34-
script(type='text/javascript', src='/js/services/global.js')
3536
script(type='text/javascript', src='/js/services/index.js')
3637

3738
//Application Controllers

app/views/includes/head.jade

+2-4
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,8 @@ head
88
meta(name="keywords", content="node.js, express, mongoose, mongodb, angularjs")
99
meta(name="description", content="Mystery")
1010

11-
link(href='/img/icons/favicon.ico', rel='shortcut icon', type='image/x-icon')
11+
link(rel='shortcut icon', href='/img/icons/favicon.ico', type='image/x-icon')
1212

13+
link(rel='stylesheet', href='//fonts.googleapis.com/css?family=Ubuntu:300,400,500,700,400italic')
1314
link(rel='stylesheet', href='/lib/bootstrap/dist/css/bootstrap.min.css')
1415
link(rel='stylesheet', href='/css/common.css')
15-
16-
script(src='/socket.io/socket.io.js')
17-

public/css/common.css

+87-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
-------------------------------------------------- */
1111
html,
1212
body {
13+
color: #373D42;
1314
font-family: Ubuntu, sans-serif;
1415
height: 100%;
1516
/* The html and body elements cannot have any padding or margin. */
@@ -74,12 +75,97 @@ body {
7475
line-height: 18px;
7576
}
7677

78+
.col-gray {
79+
background-color: #F4F4F4;
80+
padding: 15px;
81+
margin-top: 10px;
82+
width: 360px;
83+
height: 89%;
84+
border-radius: 5px;
85+
}
86+
87+
.ellipsis {
88+
display: block;
89+
white-space: nowrap;
90+
overflow: hidden;
91+
text-overflow: ellipsis;
92+
}
93+
94+
.line20 {
95+
border: 1px solid #D4D4D4;
96+
margin-bottom: 15px;
97+
}
98+
99+
.line10 {
100+
border: 1px solid #EAEAEA;
101+
margin: 10px 0;
102+
}
103+
104+
.col-gray .address {
105+
float: right;
106+
width: 150px;
107+
}
108+
109+
.block-id {
110+
background: #373D42;
111+
border: 3px solid #FFFFFF;
112+
width: 165px;
113+
height: 165px;
114+
margin: 10px auto;
115+
border-radius: :;px;
116+
}
117+
118+
.block-id h1 {
119+
font-family: Ubuntu-Medium;
120+
font-size: 24px;
121+
color: #FFFFFF;
122+
line-height: 30px;
123+
text-align: center;
124+
}
125+
126+
.icon-block {
127+
font-size: 27px;
128+
color: white;
129+
margin-top: 20px;
130+
}
131+
132+
.block-tx {
133+
border-radius: 2px;
134+
background: #F4F4F4;
135+
margin: 20px 0;
136+
padding: 15px;
137+
}
138+
139+
.btn-primary {
140+
border-radius: 2px;
141+
background: #64920F;
142+
border: 2px solid #557F08;
143+
}
144+
145+
.btn-primary:hover, .btn-primary:focus, .btn-primary:active, .btn-primary.active, .open .dropdown-toggle.btn-primary {
146+
background: #fff;
147+
border: 2px solid #ccc;
148+
color: #373D42;
149+
font-weight: bold;
150+
}
151+
77152
/* Set the fixed height of the footer here */
78153
#footer {
79154
height: 60px;
80155
background-color: #f5f5f5;
81156
}
82157

158+
.line-bot {
159+
padding: 0 0 10px 0;
160+
margin-bottom: 10px;
161+
border-bottom: 2px solid #EAEAEA;
162+
}
163+
164+
.line-top {
165+
padding: 10px 0;
166+
margin-top: 10px;
167+
border-top: 1px solid #EAEAEA;
168+
}
83169

84170
/* Custom page CSS
85171
-------------------------------------------------- */
@@ -102,7 +188,7 @@ body {
102188
}
103189

104190
.address {
105-
font-size: 10px;
191+
font-size: 11px;
106192
}
107193

108194
#search { width: 400px; }

public/js/app.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict';
22

3-
var app = angular.module('mystery',
3+
angular.module('mystery',
44
['ngAnimate',
55
'ngCookies',
66
'ngResource',

public/js/controllers/status.js

+8-4
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,22 @@ angular.module('mystery.status').controller('StatusController', ['$scope', '$rou
77
Status.get({
88
q: q
99
}, function(d) {
10-
if (q == 'getInfo') {
10+
if (q === 'getInfo') {
1111
$scope.info = d.info;
1212
}
13-
if (q == 'getDifficulty') {
13+
if (q === 'getDifficulty') {
1414
$scope.difficulty = d.difficulty;
1515
}
16-
if (q == 'getTxOutSetInfo') {
16+
if (q === 'getTxOutSetInfo') {
1717
$scope.txoutsetinfo = d.txoutsetinfo;
1818
}
19-
if (q == 'getBestBlockHash') {
19+
if (q === 'getBestBlockHash') {
2020
$scope.bestblockhash = d.bestblockhash;
2121
}
22+
if (q === 'getLastBlockHash') {
23+
$scope.lastblockhash = d.lastblockhash;
24+
}
25+
2226
});
2327
};
2428

0 commit comments

Comments
 (0)