From 41eb1c19e16591c88796a0987b3e45818d6d82f4 Mon Sep 17 00:00:00 2001 From: Jason Dreyzehner Date: Mon, 19 Oct 2015 13:59:58 -0400 Subject: [PATCH] format for new site --- docs/build.md | 17 +++++------- docs/bus.md | 5 ---- docs/errors.md | 5 ---- docs/index.md | 19 +++++--------- docs/node.md | 7 ----- docs/patch.md | 7 +---- docs/release.md | 14 +++------- docs/scaffold.md | 13 +-------- docs/services.md | 55 +++++++++------------------------------ docs/services/address.md | 18 +++---------- docs/services/bitcoind.md | 10 +------ docs/services/db.md | 17 +++--------- docs/services/web.md | 8 +----- docs/testing.md | 8 ++---- 14 files changed, 41 insertions(+), 162 deletions(-) diff --git a/docs/build.md b/docs/build.md index 5de2dc79..fe77a420 100644 --- a/docs/build.md +++ b/docs/build.md @@ -1,13 +1,7 @@ ---- -title: Build & Install -description: Build & installation instructions for Bitcore Node ---- # Build & Install - This includes a detailed instructions for compiling. There are two main parts of the build, compiling Bitcoin Core as a static library and the Node.js bindings. ## Ubuntu 14.04 (Unix/Linux) - If git is not already installed, it can be installed by running: ```bash @@ -16,7 +10,7 @@ git config --global user.email "you@example.com" git config --global user.name "Your Name" ``` -If Node.js v0.12 isn't installed, it can be installed using "nvm", it can be done by following the installation script at https://github.com/creationix/nvm#install-script and then install version v0.12 +If Node.js v0.12 isn't installed, it can be installed using "nvm", it can be done by following the installation script at [https://github.com/creationix/nvm#install-script](https://github.com/creationix/nvm#install-script) and then install version v0.12 ```bash nvm install v0.12 @@ -40,15 +34,16 @@ And finally run the build which will take several minutes. A script in the "bin" ```bash npm install ``` + Once everything is built, you can run bitcore-node via: ```bash npm start ``` + This will then start the syncing process for Bitcoin Core and the extended capabilities as provided by the built-in Address Module (details below). ## Fedora - Later versions of Fedora (>= 22) should also work with this project. The directions for Ubuntu should generally work except the installation of system utilities and libraries is a bit different. Git is already installed and ready for use without installation. ```bash @@ -56,20 +51,19 @@ yum install libtool automake autoconf pkgconfig openssl make gcc gcc-c++ kernel- ``` ## Mac OS X Yosemite - If Xcode is not already installed, it can be installed via the Mac App Store (will take several minutes). XCode includes "Clang", "git" and other build tools. Once Xcode is installed, you'll then need to install "xcode-select" via running in a terminal and following the prompts: ```bash xcode-select --install ``` -If "Homebrew" is not yet installed, it's needed to install "autoconf" and others. You can install it using the script at http://brew.sh and following the directions at https://github.com/Homebrew/homebrew/blob/master/share/doc/homebrew/Installation.md And then run in a terminal: +If "Homebrew" is not yet installed, it's needed to install "autoconf" and others. You can install it using the script at [http://brew.sh](http://brew.sh) and following the directions at [https://github.com/Homebrew/homebrew/blob/master/share/doc/homebrew/Installation.md](https://github.com/Homebrew/homebrew/blob/master/share/doc/homebrew/Installation.md) And then run in a terminal: ```bash brew install autoconf automake libtool openssl pkg-config ``` -If Node.js v0.12 and associated commands "node", "npm" and "nvm" are not already installed, you can use "nvm" by running the script at https://github.com/creationix/nvm#install-script And then run this command to install Node.js v0.12 +If Node.js v0.12 and associated commands "node", "npm" and "nvm" are not already installed, you can use "nvm" by running the script at [https://github.com/creationix/nvm#install-script](https://github.com/creationix/nvm#install-script) And then run this command to install Node.js v0.12 ```bash nvm install v0.12 @@ -87,6 +81,7 @@ And finally run the build which will take several minutes. A script in the "bin" ```bash npm install ``` + Once everything is built, you can run bitcore-node via: ```bash diff --git a/docs/bus.md b/docs/bus.md index 620e3c84..153b9a9c 100644 --- a/docs/bus.md +++ b/docs/bus.md @@ -1,9 +1,4 @@ ---- -title: Bus -description: An event emitter for node events ---- # Bus - The bus provides a way to subscribe to events from any of the services running. It's implemented abstract from transport specific implementation. The primary use of the bus in Bitcore Node is for subscribing to events via a web socket. ## Opening/Closing diff --git a/docs/errors.md b/docs/errors.md index 18753107..e033466b 100644 --- a/docs/errors.md +++ b/docs/errors.md @@ -1,9 +1,4 @@ ---- -title: Errors -description: Errors for Bitcore Node ---- # Errors - Many times there are cases where an error condition can be gracefully handled depending on a particular use. To assist in better error handling, errors will have different types so that it's possible to determine the type of error and handle appropriately. ```js diff --git a/docs/index.md b/docs/index.md index 7d87ebbe..879a7959 100644 --- a/docs/index.md +++ b/docs/index.md @@ -1,9 +1,6 @@ -Bitcore Node -============ - A Bitcoin full node for building applications and services with Node.js. A node is extensible and can be configured to run additional services. At the minimum a node has native bindings to Bitcoin Core with the [Bitcoin Service](services/bitcoind.md). Additional services can be enabled to make a node more useful such as exposing new APIs, adding new indexes for addresses with the [Address Service](services/address.md), running a block explorer, wallet service, and other customizations. -## Install +# Install ```bash npm install -g bitcore @@ -12,15 +9,13 @@ bitcore start Note: For your convenience, we distribute binaries for x86_64 Linux and x86_64 Mac OS X. Upon npm install, the binaries for your platform will be downloaded. For more detailed installation instructions, or if you want to compile the project yourself, then please see the [Build & Install](build.md) documentation to build the project from source. -## Prerequisites - +# Prerequisites - Node.js v0.12 - ~100GB of disk storage - ~4GB of RAM - Mac OS X >= 10.9, Ubuntu >= 12.04 (libc >= 2.15 and libstdc++ >= 6.0.16) -## Configuration - +# Configuration Bitcore includes a Command Line Interface (CLI) for managing, configuring and interfacing with your Bitcore Node. ```bash @@ -38,20 +33,18 @@ To start bitcore as a daemon: bitcore start --daemon ``` -## Add-on Services - +# Add-on Services There are several add-on services available to extend the functionality of Bitcore Node: - - [Insight API](https://github.com/bitpay/insight-api/tree/v0.3.0) - [Insight UI](https://github.com/bitpay/insight/tree/v0.3.0) -## Documentation - +# Documentation - [Services](services.md) - [Bitcoind](services/bitcoind.md) - Native bindings to Bitcoin Core - [Database](services/db.md) - The foundation API methods for getting information about blocks and transactions. - [Address](services/address.md) - Adds additional API methods for querying and subscribing to events with bitcoin addresses. - [Web](services/web.md) - Creates an express application over which services can expose their web/API content + - [Build & Install](build.md) - How to build and install from source - [Testing & Development](testing.md) - Developer guide for testing - [Node](node.md) - Details on the node constructor diff --git a/docs/node.md b/docs/node.md index 8c9bb583..330ab64b 100644 --- a/docs/node.md +++ b/docs/node.md @@ -1,13 +1,7 @@ ---- -title: Node -description: A collection of services run as node. ---- # Node - A node represents a collection of services that are loaded together. For more information about services, please see the [Services Documentation](services.md). ## API Documentation - - `start()` - Will start the node's services in the correct order based on the dependencies of a service. - `stop()` - Will stop the node's services. - `openBus()` - Will create a new event bus to subscribe to events. @@ -50,5 +44,4 @@ node.on('error', function(err) { node.stop(function() { // the shutdown is complete }); - ``` diff --git a/docs/patch.md b/docs/patch.md index 42c55151..86c366c6 100644 --- a/docs/patch.md +++ b/docs/patch.md @@ -1,10 +1,5 @@ ---- -title: Bitcoin Core Patch -description: Description of the patch applied to Bitcoin Core to compile as a static library ---- # Static Library Patch - -To provide native bindings to JavaScript *(or any other language for that matter)*, Bitcoin code, itself, must be linkable. Currently, Bitcoin Core provides a JSON RPC interface to bitcoind as well as a shared library for script validation *(and hopefully more)* called libbitcoinconsensus. There is a node module, [node-libbitcoinconsensus](https://github.com/bitpay/node-libbitcoinconsensus), that exposes these methods. While these interfaces are useful for several use cases, there are additional use cases that are not fulfilled, and being able to implement customized interfaces is necessary. To be able to do this a few simple changes need to be made to Bitcoin Core to compile as a static library. +To provide native bindings to JavaScript _(or any other language for that matter)_, Bitcoin code, itself, must be linkable. Currently, Bitcoin Core provides a JSON RPC interface to bitcoind as well as a shared library for script validation _(and hopefully more)_ called libbitcoinconsensus. There is a node module, [node-libbitcoinconsensus](https://github.com/bitpay/node-libbitcoinconsensus), that exposes these methods. While these interfaces are useful for several use cases, there are additional use cases that are not fulfilled, and being able to implement customized interfaces is necessary. To be able to do this a few simple changes need to be made to Bitcoin Core to compile as a static library. The patch is located at `etc/bitcoin.patch` and adds a configure option `--enable-daemonlib` to compile all object files with `-fPIC` (Position Independent Code - needed to create a shared object), exposes leveldb variables and objects, exposes the threadpool to the bindings, and conditionally includes the main function. diff --git a/docs/release.md b/docs/release.md index 71a76986..29deb20f 100644 --- a/docs/release.md +++ b/docs/release.md @@ -1,9 +1,4 @@ ---- -title: Release Process -description: Description to verify releases ---- # Release Process - Binaries for the C++ binding file (which includes libbitcoind statically linked in) are distributed for convenience. The binary binding file `bitcoind.node` is signed and published to S3 for later download and installation. Source files can also be built if binaries are not desired. ## How to Verify Signatures @@ -14,15 +9,12 @@ gpg --verify bitcoind.node.sig bitcoind.node ``` To verify signatures, use the following PGP keys: - -- @braydonf: https://pgp.mit.edu/pks/lookup?op=get&search=0x9BBF07CAC07A276D -- @kleetus: https://pgp.mit.edu/pks/lookup?op=get&search=0x33195D27EF6BDB7F -- @pnagurny: https://pgp.mit.edu/pks/lookup?op=get&search=0x0909B33F0AA53013 +- @braydonf: [https://pgp.mit.edu/pks/lookup?op=get&search=0x9BBF07CAC07A276D](https://pgp.mit.edu/pks/lookup?op=get&search=0x9BBF07CAC07A276D) +- @kleetus: [https://pgp.mit.edu/pks/lookup?op=get&search=0x33195D27EF6BDB7F](https://pgp.mit.edu/pks/lookup?op=get&search=0x33195D27EF6BDB7F) +- @pnagurny: [https://pgp.mit.edu/pks/lookup?op=get&search=0x0909B33F0AA53013](https://pgp.mit.edu/pks/lookup?op=get&search=0x0909B33F0AA53013) ## How to Release - Ensure you've followed the instructions in the README.md for building the project from source. When building for any platform, be sure to keep in mind the minimum supported C and C++ system libraries and build from source using this library. Example, Ubuntu 12.04 has the earliest system library for Linux that we support, so it would be easiest to build the Linux artifact using this version. You will be using node-gyp to build the C++ bindings. A script will then upload the bindings to S3 for later use. You will also need credentials for BitPay's bitcore-node S3 bucket and be listed as an author for the bitcore-node's npm module. - - Create a file `.bitcore-node-upload.json` in your home directory - The format of this file should be: diff --git a/docs/scaffold.md b/docs/scaffold.md index d44b74e0..2ba2909f 100644 --- a/docs/scaffold.md +++ b/docs/scaffold.md @@ -1,31 +1,20 @@ ---- -title: Scaffolding -description: Description of functions for Bitcore Node configuration ---- # Scaffold - -A collection of functions for creating, managing, starting, stopping and interacting with a Bitcore Node. +A collection of functions for creating, managing, starting, stopping and interacting with a Bitcore node. ## Install - This function will add a service to a node by installing the necessary dependencies and modifying the `bitcore-node.json` configuration. ## Start - This function will load a configuration file `bitcore-node.json` and instantiate and start a node based on the configuration. ## Find Config - This function will recursively find a configuration `bitcore-node.json` file in parent directories and return the result. ## Default Config - This function will return a default configuration with the default services based on environment variables, and will default to using the standard `~/.bitcoin` data directory. ## Uninstall - This function will remove a service from a node by uninstalling the necessary dependencies and modifying the `bitcore-node.json` configuration. ## Call Method - This function will call an API method on a node via the JSON-RPC interface. diff --git a/docs/services.md b/docs/services.md index 4de1dbf4..6ab9cf3c 100644 --- a/docs/services.md +++ b/docs/services.md @@ -1,13 +1,5 @@ ---- -title: Services -description: Overview of Bitcore Node services architecture. ---- # Services - -## Overview - Bitcore Node has a service module system that can start up additional services that can include additional: - - Blockchain indexes (e.g. querying balances for addresses) - API methods - HTTP routes @@ -35,7 +27,7 @@ Services correspond with a Node.js module as described in 'package.json', for ex } ``` -*Note:* If you already have a bitcore-node database, and you want to query data from previous blocks in the blockchain, you will need to reindex. Reindexing right now means deleting your bitcore-node database and resyncing. +_Note:_ If you already have a bitcore-node database, and you want to query data from previous blocks in the blockchain, you will need to reindex. Reindexing right now means deleting your bitcore-node database and resyncing. ## Using Services Programmatically If, instead, you would like to run a custom node, you can include services by including them in your configuration object when initializing a new node. @@ -81,8 +73,8 @@ var myNode = new bitcore.Node({ ] }); ``` -Now that you've loaded your services you can access them via `myNode.services..`. For example -if you wanted to check the balance of an address, you could access the address service like so. + +Now that you've loaded your services you can access them via `myNode.services..`. For example if you wanted to check the balance of an address, you could access the address service like so. ```js myNode.services.address.getBalance('1HB5XMLmzFVj8ALj6mfBsbifRoD4miY36v', false, function(err, total) { @@ -91,9 +83,7 @@ myNode.services.address.getBalance('1HB5XMLmzFVj8ALj6mfBsbifRoD4miY36v', false, ``` ## Writing a Service - A new service can be created by inheriting from `Node.Service` and implementing these methods and properties: - - `Service.dependencies` - An array of services that are needed, this will determine the order that services are started on the node. - `Service.prototype.start()` - Called to start up the service. - `Service.prototype.stop()` - Called to stop the service. @@ -107,14 +97,10 @@ The `package.json` for the service module can either export the `Node.Service` d Please take a look at some of the existing services for implementation specifics. ### Adding an index - -One quite useful feature exposed to services is the ability to index arbitrary data in the blockchain. To do so we make -use of leveldb, a simple key-value store. As a service we can expose a 'blockHandler' function which is called each time -a new block is added or removed from the blockchain. This gives us access to every new transaction received, allowing -us to index them. Let's take a look at an example where we will index the time that a transaction was confirmed. +One quite useful feature exposed to services is the ability to index arbitrary data in the blockchain. To do so we make use of leveldb, a simple key-value store. As a service we can expose a 'blockHandler' function which is called each time a new block is added or removed from the blockchain. This gives us access to every new transaction received, allowing us to index them. Let's take a look at an example where we will index the time that a transaction was confirmed. ```js -//Index prefix, so that we can determine the difference between our index +//Index prefix, so that we can determine the difference between our index //and the indexes provided by other services MyService.datePrefix = new Buffer('10', 'hex'); @@ -163,8 +149,7 @@ MyService.prototype.prototype.blockHandler = function(block, addOutput, callback ``` ### Retrieving data using an index -With our block handler code every transaction in the blockchain will now be indexed. However, if we want to query this -data we need to add a method to our service to expose it. +With our block handler code every transaction in the blockchain will now be indexed. However, if we want to query this data we need to add a method to our service to expose it. ```js @@ -208,20 +193,13 @@ MyService.prototype.getTransactionIdsByDate = function(startDate, endDate, callb }; ``` -If you're new to leveldb and would like to better understand how createReadStream works you can find [more -information here](https://github.com/Level/levelup#dbcreatereadstreamoptions). +If you're new to leveldb and would like to better understand how createReadStream works you can find [more information here](https://github.com/Level/levelup#dbcreatereadstreamoptions). ### Understanding indexes - -You may notice there are several pieces to the index itself. Let's take a look at each piece to make them easier -to understand. +You may notice there are several pieces to the index itself. Let's take a look at each piece to make them easier to understand. #### Prefixes - -Since leveldb is just a simple key-value store we need something to differentiate which keys are part of which index. If -we had two services trying to index on the same key, say a txid, they would overwrite each other and their queries would -return results from the other index. By introducing a unique prefix per index type that we can prepend our indexes with -prevents these collisions. +Since leveldb is just a simple key-value store we need something to differentiate which keys are part of which index. If we had two services trying to index on the same key, say a txid, they would overwrite each other and their queries would return results from the other index. By introducing a unique prefix per index type that we can prepend our indexes with prevents these collisions. ```js //A simple example of indexing the number of inputs and ouputs given a transaction id @@ -247,19 +225,10 @@ var index2key = Buffer.concat([index2prefix, new Buffer(transaction.id)]); var index2value = transaction.outputs.length; ``` -Remember that all indexes are global, so check to make sure no other services you are using make use of the same prefix -you plan to use in your service. We recommend documenting which prefixes you use and that you check for collisions with -popular services if you plan to release your service for others to use. +Remember that all indexes are global, so check to make sure no other services you are using make use of the same prefix you plan to use in your service. We recommend documenting which prefixes you use and that you check for collisions with popular services if you plan to release your service for others to use. #### Index Key - -The index key is the value you want to query by. This value should be deterministic so that it can be removed in the case -of a [re-org](https://en.bitcoin.it/wiki/Chain_Reorganization) resulting in a block removal. The value should be unique, as -no two indexes can be the same value. If you need two indexes with the same key value, consider adding a deterministic -differentiator, such as a position in an array, or instead storing multiple values within the same index data. +The index key is the value you want to query by. This value should be deterministic so that it can be removed in the case of a [re-org](https://en.bitcoin.it/wiki/Chain_Reorganization) resulting in a block removal. The value should be unique, as no two indexes can be the same value. If you need two indexes with the same key value, consider adding a deterministic differentiator, such as a position in an array, or instead storing multiple values within the same index data. #### Index Data - -This is the data which is returned when you search by the index's key. This can be whatever you would like to retrieve. -Try to be efficient by not storing data that is already available elsewhere, such as storing a transaction ID instead of -an entire transaction. +This is the data which is returned when you search by the index's key. This can be whatever you would like to retrieve. Try to be efficient by not storing data that is already available elsewhere, such as storing a transaction ID instead of an entire transaction. diff --git a/docs/services/address.md b/docs/services/address.md index f304dae0..7f46d3ad 100644 --- a/docs/services/address.md +++ b/docs/services/address.md @@ -1,13 +1,7 @@ ---- -title: Address Service -description: Overview of the Address Service for Bitcore Node ---- # Address Service - The address service builds on the [Bitcoin Service](bitcoind.md) and the [Database Service](db.md) to add additional functionality for querying and subscribing to information based on bitcoin addresses. This will typically represent the core functionality for wallet applications. ## API Documentation - These methods are exposed over the JSON-RPC interface and can be called directly from a node via: ```js @@ -54,11 +48,7 @@ node.services.address.getBalance(address, includeMempool, function(err, balance) **View Address History** -This method will give history of an address limited by a range of block heights by using -the "start" and "end" arguments. The "start" value is the more recent, and greater, block height. -The "end" value is the older, and lesser, block height. This feature is most useful for synchronization -as previous history can be omitted. Furthermore for large ranges of block heights, results can be -paginated by using the "from" and "to" arguments. +This method will give history of an address limited by a range of block heights by using the "start" and "end" arguments. The "start" value is the more recent, and greater, block height. The "end" value is the older, and lesser, block height. This feature is most useful for synchronization as previous history can be omitted. Furthermore for large ranges of block heights, results can be paginated by using the "from" and "to" arguments. ```js var addresses = ['mgY65WSfEmsyYaYPQaXhmXMeBhwp4EcsQW']; @@ -73,6 +63,7 @@ node.services.address.getAddressHistory(addresses, options, function(err, histor ``` The history format will be: + ```js { totalCount: 1, // The total number of items within "start" and "end" @@ -109,6 +100,7 @@ node.services.address.getAddressSummary(address, options, function(err, summary) ``` The `summary` will have the format (values are in satoshis): + ```js { totalReceived: 1000000000, @@ -124,9 +116,7 @@ The `summary` will have the format (values are in satoshis): ``` ## Events - For details on instantiating a bus for a node, see the [Bus Documentation](../bus.md). - - Name: `address/transaction`, Arguments: `[address, address...]` - Name: `address/balance`, Arguments: `[address, address...]` @@ -143,4 +133,4 @@ bus.on('address/transaction', function(transaction) { bus.on('address/balance', function(balance) { }); -``` \ No newline at end of file +``` diff --git a/docs/services/bitcoind.md b/docs/services/bitcoind.md index 3d1548e7..eba2b3d5 100644 --- a/docs/services/bitcoind.md +++ b/docs/services/bitcoind.md @@ -1,13 +1,7 @@ ---- -title: Bitcoin Service -description: Overview of the Bitcoin Service for Bitcore Node ---- # Bitcoin Service - The Bitcoin Service adds a native [Node.js](https://nodejs.org) interface to [Bitcoin Core](https://github.com/bitcoin/bitcoin) for querying information about the Bitcoin blockchain. Bindings are linked to Bitcoin Core compiled as a static library. ## API Documentation - These methods are currently only available via directly interfacing with a node: ```js @@ -59,7 +53,6 @@ node.services.bitcoind.getTransactionWithBlockInfo(txid, queryMempool, function( console.log(info.timestamp); // in seconds var transaction = bitcore.Transaction().fromBuffer(transactionBuffer); }); - ``` Send a transaction to the network: @@ -93,7 +86,6 @@ console.log(spent); ``` **Miscellaneous** - - `bitcoind.start(callback)` - Start the JavaScript Bitcoin node, the callback is called when the daemon is ready. - `bitcoind.getInfo()` - Basic information about the chain including total number of blocks. - `bitcoind.isSynced()` - Returns a boolean if the daemon is fully synced (not the initial block download) @@ -101,7 +93,6 @@ console.log(spent); - `bitcoind.stop(callback)` - Stop the JavaScript bitcoin node safely, the callback will be called when bitcoind is closed. This will also be done automatically on `process.exit`. It also takes the bitcoind node off the libuv event loop. If the daemon object is the only thing on the event loop. Node will simply close. ## Events - The Bitcoin Service doesn't expose any events via the Bus, however there are a few events that can be directly registered: ```js @@ -115,6 +106,7 @@ node.services.bitcoind.on('tx', function(txInfo) { ``` The `txInfo` object will have the format: + ```js { buffer: , diff --git a/docs/services/db.md b/docs/services/db.md index 440d1df0..305587a0 100644 --- a/docs/services/db.md +++ b/docs/services/db.md @@ -1,13 +1,7 @@ ---- -title: Database Service -description: Overview of the Database Service for Bitcore Node ---- # Database Service - This service synchronizes a leveldb database with the [Bitcoin Service](bitcoind.md) block chain by connecting and disconnecting blocks to build new indexes that can be queried. Other services can extend the data that is indexed by implementing a `blockHandler` method, similar to the built-in [Address Service](address.md). ## Adding Indexes - For a service to include additional block data, it can implement a `blockHandler` method that will be run to when there are new blocks added or removed. ```js @@ -36,7 +30,6 @@ CustomService.prototype.resetMempoolIndex = function(callback) { ``` ## API Documentation - These methods are exposed over the JSON-RPC interface and can be called directly from a node via: ```js @@ -46,6 +39,7 @@ node.services.db. **Query Blocks by Date** One of the additional indexes created by the Database Service is querying for blocks by ranges of dates: + ```js var newest = 1441914000; // Notice time is in seconds not milliseconds var oldest = 1441911000; @@ -53,7 +47,6 @@ var oldest = 1441911000; node.services.db.getBlockHashesByTimestamp(newest, oldest, function(err, hashes) { // hashes will be an array of block hashes }); - ``` **Working with Blocks and Transactions as Bitcore Instances** @@ -89,17 +82,15 @@ node.services.db.sendTransaction(transaction, function(err) { } // otherwise the transaction has been sent }); - ``` ## Events - For details on instantiating a bus for a node, see the [Bus Documentation](../bus.md). - - Name: `db/transaction` - Name: `db/block` **Examples:** + ```js bus.subscribe('db/transaction'); bus.subscribe('db/block'); @@ -111,13 +102,13 @@ bus.on('db/block', function(blockHash) { bus.on('db/transaction', function(txInfo) { // see below }); - ``` The `txInfo` object will have the format: + ```js { rejected: true, // If the transaction was rejected into the mempool tx: // a Bitcore Transaction instance } -``` \ No newline at end of file +``` diff --git a/docs/services/web.md b/docs/services/web.md index a3e3dd68..61360711 100644 --- a/docs/services/web.md +++ b/docs/services/web.md @@ -1,9 +1,4 @@ ---- -title: Web Service -description: Overview of the Web Service for Bitcore Node ---- # Web Service - The web service creates an express app which can be used by services for setting up web routes for API's, static content, web applications, etc. This allows users to interact with various bitcore node services over one http or https port. In order for your service to add routes, it must implement the `setupRoutes()` and `getRoutePrefix()` methods. @@ -27,7 +22,6 @@ MyService.prototype.getRoutePrefix = function() { ``` ## Configuring Web Service for HTTPS - You can run the web service over https by editing your bitcore node config, setting https to true and adding httpsOptions: ```json @@ -42,4 +36,4 @@ You can run the web service over https by editing your bitcore node config, sett "web" ] } -``` \ No newline at end of file +``` diff --git a/docs/testing.md b/docs/testing.md index e5fe36ed..30658bb6 100644 --- a/docs/testing.md +++ b/docs/testing.md @@ -1,16 +1,11 @@ ---- -title: Development & Testing -description: Notes for development and debugging Bitcore Node ---- # Development & Testing - To run all of the JavaScript tests: ```bash npm run test ``` -To run tests against the bindings, as defined in `bindings.gyp` the regtest feature of Bitcoin Core is used, and to enable this feature we currently need to build with the wallet enabled *(not a part of the regular build)*. To do this, export an environment variable and recompile: +To run tests against the bindings, as defined in `bindings.gyp` the regtest feature of Bitcoin Core is used, and to enable this feature we currently need to build with the wallet enabled _(not a part of the regular build)_. To do this, export an environment variable and recompile: ```bash export BITCORENODE_ENV=test @@ -44,6 +39,7 @@ $ gdb --args node examples/node.js ``` To run mocha from within gdb (notice `_mocha` and not `mocha` so that the tests run in the same process): + ```bash $ gdb --args node /path/to/_mocha -R spec integration/regtest.js ```