update README for websocket API

This commit is contained in:
Manuel Araoz 2014-01-15 09:38:27 -03:00
parent 162e989b65
commit 707e47e403
2 changed files with 36 additions and 6 deletions

View File

@ -87,16 +87,16 @@ $ npm install -g bower
$ 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 blocks in MongoDB):
Run sync from mystery repository (to save old blocks and transactions in MongoDB):
$ utils/sync.js
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
@ -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
If you did not get all library during grunt command, please use the follow command:

View File

@ -6,7 +6,7 @@ angular.module('mystery.system').controller('IndexController', ['$scope', 'Globa
$scope.global = Global;
socket.on('tx', function(data) {
var tx = data;
console.log('Transaction received! ' + tx);
console.log('Transaction received! ' + JSON.stringify(tx));
if ($scope.txs.length === TRANSACTION_DISPLAYED) {
$scope.txs.pop();
}
@ -15,7 +15,7 @@ angular.module('mystery.system').controller('IndexController', ['$scope', 'Globa
socket.on('block', function(data) {
var block = data;
console.log('Block received! ' + block);
console.log('Block received! ' + JSON.stringify(block));
if ($scope.blocks.length === BLOCKS_DISPLAYED) {
$scope.blocks.pop();
}