-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathblock.js
More file actions
30 lines (27 loc) · 680 Bytes
/
block.js
File metadata and controls
30 lines (27 loc) · 680 Bytes
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
var sys = require('sys');
require('buffertools');
var Module = require('./webservice').Module;
var bitcoin = require('bitcoin-p2p');
var Util = bitcoin.Util;
var Block = exports.Block = Module.define({
title: "Welcome to your webservice!",
name: "transaction service",
version: "0.1.0",
construct: function (params) {
this.node = params.node;
},
schema: {
'node': { type: bitcoin.Node, required: true }
}
});
Block.method('status', {
schema: {},
handler: function (params, callback) {
var topBlock = this.node.blockChain.getTopBlock();
var data = {
hash: topBlock.getHash().toString('base64'),
height: topBlock.height
};
callback(null, data);
}
});