It seems the godoc example extraction does not recognize the same syntax
used for functions with receivers when working with interfaces.
So, instead, categorize the example on the interface.
This commit moves the example to a test file so it integrates nicely with
Go's example tooling.
This allows the example output to be tested as a part of running the
normal Go tests to help ensure it doesn't get out of date with the code.
It is also nice to have the example in one place rather than repeating it
in doc.go and README.md.
Links and information about the example have been included in README.md in
place of the example.
This ability for multiple database backends has been available for a long,
long time. Looks like this was simply not updated when the interface was
added.
This commit updates the calls into btcutil and btcwire for the latest API
changes which remove the need for the protocol version for serialization
and deserialization of blocks and transactions.
This commit modifies the way initial database creation is handled.
Previously, the genesis for the main chain was inserted automatically upon
creation of the database. However, that approach caused an issue since
other networks such as the test network don't use the same genesis block
as the main network.
The new approach introduced by this commit is to leave it up to the caller
to insert the desired genesis block. In order to support this, the
InsertBlock function has been modified to allow the first (and only the
first) block to be inserted without having an existing parent. Also, the
NewestSha function has been modified to return a zero hash, -1 for the
height, and no error when the database does not yet have any blocks. This
allows the caller to determine the difference between no blocks and only
the genesis block (in which case the return values would be the genesis
hash and 0 for the height).