There is support for different storage backends, currently there are two. Each backend can be used with sqlite, postgres or mysql.
The `utxo` backend stores only the minimum amount of information needed to validate new blocks, namely the `Unspent TX Outputs`. So it can be used to independently validate the whole blockchain as it goes, but it cannot query old data or serve blocks to peers. There is however a way to tell it specific addresses for which it will keep the history (the ones in your wallet).
The `sequel` backend stores the whole blockchain into a fully normalized SQL DB. It can be used to run arbitrary queries on the blockchain data, but the database gets huge and it takes a very long time to do an initial sync.
For examples that require storage backends, you can specify them using a
string containing the backend name and a configuration string. The default
backend is +utxo::sqlite:~/.bitcoin-ruby/<network>blocks.db+, which
is a sqlite database called
blocks.db in a directory named
after the network you’re using, inside your homedir.
sequel::sqlite:/ # in-memory sequel::sqlite://bitcoin.db sequel::sqlite:///tmp/bitcoin.db sequel::postgres:/bitcoin sequel::postgres://<user>:<pass>@<host>:<port>/<database>
To implement a custom backend you need to inherit from Bitcoin::Storage::Backends::StoreBase and implement the methods defined there. When returning blocks/tx, you should wrap them in Bitcoin::Storage::Models objects. See the `dummy` backend for a simple example.