Merge pull request #47 from maraoz/feature/update-README-sockets
update README for websocket API
This commit is contained in:
commit
b2425d2af6
38
README.md
38
README.md
|
@ -87,16 +87,16 @@ $ npm install -g bower
|
||||||
|
|
||||||
$ ln -s <path-to-your-clone-repositoy>/bitcore
|
$ ln -s <path-to-your-clone-repositoy>/bitcore
|
||||||
|
|
||||||
## API
|
## Syncing old blockchain data
|
||||||
|
|
||||||
A REST API is provided at /api.
|
Run sync from mystery repository (to save old blocks and transactions in MongoDB):
|
||||||
|
|
||||||
Run sync from mystery repository (to save blocks in MongoDB):
|
|
||||||
|
|
||||||
$ utils/sync.js
|
$ utils/sync.js
|
||||||
|
|
||||||
Check utils/sync.js --help for options.
|
Check utils/sync.js --help for options.
|
||||||
|
|
||||||
|
New blockchain data will be synced while the webserver (server.js) is up, through the p2p module.
|
||||||
|
|
||||||
|
|
||||||
## API
|
## API
|
||||||
|
|
||||||
|
@ -120,7 +120,37 @@ A REST API is provided at /api. The entry points are:
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
## Web Socket API
|
||||||
|
The web socket API is served using [socket.io](http://socket.io) at:
|
||||||
|
```
|
||||||
|
/socket.io/1/
|
||||||
|
```
|
||||||
|
|
||||||
|
Bitcoin network events published are:
|
||||||
|
'tx': new transaction received from network. Data will be a app/models/Transaction object.
|
||||||
|
Sample output:
|
||||||
|
```
|
||||||
|
{
|
||||||
|
"__v":0,
|
||||||
|
"txid":"00c1b1acb310b87085c7deaaeba478cef5dc9519fab87a4d943ecbb39bd5b053",
|
||||||
|
"_id":"52d68099c3fb4c240d000088",
|
||||||
|
"orphaned":false,
|
||||||
|
"processed":false
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
'block': new block received from network. Data will be a app/models/Block object.
|
||||||
|
Sample output:
|
||||||
|
```
|
||||||
|
{
|
||||||
|
"__v":0,
|
||||||
|
"hash":"000000004a3d187c430cd6a5e988aca3b19e1f1d1727a50dead6c8ac26899b96",
|
||||||
|
"time":1389789343,
|
||||||
|
"fromP2P":true,
|
||||||
|
"_id":"52d6809ec3fb4c240d00008c"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
## 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:
|
||||||
|
|
|
@ -6,7 +6,7 @@ angular.module('mystery.system').controller('IndexController', ['$scope', 'Globa
|
||||||
$scope.global = Global;
|
$scope.global = Global;
|
||||||
socket.on('tx', function(data) {
|
socket.on('tx', function(data) {
|
||||||
var tx = data;
|
var tx = data;
|
||||||
console.log('Transaction received! ' + tx);
|
console.log('Transaction received! ' + JSON.stringify(tx));
|
||||||
if ($scope.txs.length === TRANSACTION_DISPLAYED) {
|
if ($scope.txs.length === TRANSACTION_DISPLAYED) {
|
||||||
$scope.txs.pop();
|
$scope.txs.pop();
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@ angular.module('mystery.system').controller('IndexController', ['$scope', 'Globa
|
||||||
|
|
||||||
socket.on('block', function(data) {
|
socket.on('block', function(data) {
|
||||||
var block = data;
|
var block = data;
|
||||||
console.log('Block received! ' + block);
|
console.log('Block received! ' + JSON.stringify(block));
|
||||||
if ($scope.blocks.length === BLOCKS_DISPLAYED) {
|
if ($scope.blocks.length === BLOCKS_DISPLAYED) {
|
||||||
$scope.blocks.pop();
|
$scope.blocks.pop();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue