[BREAKGLASS] Append-only mirror of github.com/seedhammer/dcrd
Go to file
Dave Collins 4db689e691 database: Major redesign of database package.
This commit contains a complete redesign and rewrite of the database
package that approaches things in a vastly different manner than the
previous version.  This is the first part of several stages that will be
needed to ultimately make use of this new package.

A quick summary of the changes is as follows:

- The previous database could only contain blocks on the main chain and
  reorgs required deleting the blocks from the database.  This made it
  impossible to store orphans and could make external RPC calls for
  information about blocks during the middle of a reorg fail.
- The previous database interface forced a high level of coin-specific
  intelligence such as spend tracking into each backend driver.
- The aforementioned point led to making it difficult to implement new
  backend drivers due to the need to repeat a lot of non-trivial logic
  which is better handled at a higher layer, such as the blockchain
  package.
- The old database stored all blocks in leveldb.  This made it extremely
  inefficient to do things such as lookup headers and individual
  transactions since the entire block had to be loaded from leveldb (which
  entails it doing data copies) to get access.

In order to address all of these concerns, and others not mentioned, the
database interface has been redesigned as follows:

- Two main categories of functionality are provided: block storage and
  metadata storage
- All block storage and metadata storage are done via read-only and
  read-write MVCC transactions with both manual and managed modes
  - Support for multiple concurrent readers and a single writer
  - Readers use a snapshot and therefore are not blocked by the writer
- Some key properties of the block storage and retrieval API:
  - It is generic and does NOT contain additional coin logic such spend
    tracking and block linking
  - Provides access to the raw serialized bytes so deserialization is not
    forced for callers that don't need it
  - Support for fetching headers via independent functions which allows
    implementations to provide significant optimizations
  - Ability to efficiently retrieve arbitrary regions of blocks
    (transactions, scripts, etc)
- A rich metadata storage API is provided:
  - Key/value with arbitrary data
  - Support for buckets and nested buckets
  - Bucket iteration through a couple of different mechanisms
  - Cursors for efficient and direct key seeking
- Supports registration of backend database implementations
- Comprehensive test coverage
- Provides strong documentation with example usage

This commit also contains an implementation of the previously discussed
interface named ffldb (flat file plus leveldb metadata backend).  Here
is a quick overview:

- Highly optimized for read performance with consistent write performance
  regardless of database size
- All blocks are stored in flat files on the file system
- Bulk block region fetching is optimized to perform linear reads which
  improves performance on spindle disks
- Anti-corruption mechanisms:
  - Flat files contain full block checksums to quickly an easily detect
    database corruption without needing to do expensive merkle root
    calculations
  - Metadata checksums
  - Open reconciliation
- Extensive test coverage:
  - Comprehensive blackbox interface testing
  - Whitebox testing which uses intimate knowledge to exercise uncommon
    failure paths such as deleting files out from under the database
  - Corruption tests (replacing random data in the files)

In addition, this commit also contains a new tool under the new database
directory named dbtool which provides a few basic commands for testing the
database.  It is designed around commands, so it could be useful to expand
on in the future.
2016-05-25 23:09:31 -05:00
addrmgr Initial Decred Commit. 2016-02-07 14:00:12 -05:00
blockchain Sync upstream comment and error improvements. 2016-05-21 02:36:11 -05:00
chaincfg chaincfg: Move DNS Seeds to chaincfg. 2016-05-24 10:15:51 -05:00
cmd Bump for v0.1.4 2016-05-25 12:05:45 -04:00
database docs: Make various README.md files consistent. 2016-05-20 16:00:12 -05:00
database2 database: Major redesign of database package. 2016-05-25 23:09:31 -05:00
dcrec docs: Make various README.md files consistent. 2016-05-20 16:00:12 -05:00
dcrjson rpcserver: Add filteraddrs param to srt API. 2016-05-25 11:47:19 -05:00
docs dcrjson: Add optional locktime to createrawtransaction 2016-05-20 22:08:14 -05:00
limits Initial Decred Commit. 2016-02-07 14:00:12 -05:00
peer peer: Unexport the mru inventory map. 2016-05-25 15:16:16 -05:00
release Initial Decred Commit. 2016-02-07 14:00:12 -05:00
txscript docs: Make various README.md files consistent. 2016-05-20 16:00:12 -05:00
wire docs: Make various README.md files consistent. 2016-05-20 16:00:12 -05:00
.gitignore Initial Decred Commit. 2016-02-07 14:00:12 -05:00
.travis.yml TravisCI: Remove external go vet reference. (#655) 2016-04-07 16:10:52 -04:00
blocklogger.go Initial Decred Commit. 2016-02-07 14:00:12 -05:00
blockmanager.go dcrd: do not process empty getdata messages 2016-05-24 15:47:08 -04:00
chainindexer.go Add lookup of ticket commitments to addrindex 2016-03-17 13:46:30 -04:00
CHANGES Initial Decred Commit. 2016-02-07 14:00:12 -05:00
config.go Fix dropaddrindex flag usage message 2016-05-25 12:54:43 -05:00
cpuminer.go mining: Refactor policy into its own struct. 2016-05-25 13:02:44 -05:00
dcrd.go main: Limit garbage collection percentage. (#686) (#187) 2016-05-18 12:48:50 -05:00
deps.txt Add 0.11.1 deps to deps.txt. 2015-05-27 10:50:12 -05:00
discovery.go Initial Decred Commit. 2016-02-07 14:00:12 -05:00
doc.go config: New option --minrelaytxfee 2016-05-19 11:44:08 -05:00
goclean.sh Work on improving the use of analysis tools in goclean.sh 2016-02-12 15:24:32 -05:00
LICENSE Initial Decred Commit. 2016-02-07 14:00:12 -05:00
log.go peer: Refactor peer code into its own package. 2016-05-20 13:58:23 -05:00
mempool.go mempool/mining: Decouple and optimize priority calcs. 2016-05-25 15:40:59 -05:00
mempoolerror.go Initial Decred Commit. 2016-02-07 14:00:12 -05:00
mining_test.go Fix the mining transaction selection algorithm 2016-04-13 17:54:06 -04:00
mining.go mempool/mining: Decouple and optimize priority calcs. 2016-05-25 15:40:59 -05:00
miningerror.go Work on improving the use of analysis tools in goclean.sh 2016-02-12 15:24:32 -05:00
mrunoncemap_test.go Initial Decred Commit. 2016-02-07 14:00:12 -05:00
mrunoncemap.go Initial Decred Commit. 2016-02-07 14:00:12 -05:00
params.go chaincfg: Move DNS Seeds to chaincfg. 2016-05-24 10:15:51 -05:00
policy_test.go mempool: Move checkTransactionStandard to policy. 2016-05-24 13:49:17 -05:00
policy.go mempool/mining: Decouple and optimize priority calcs. 2016-05-25 15:40:59 -05:00
README.md docs: Make various README.md files consistent. 2016-05-20 16:00:12 -05:00
rpcserver.go mempool/mining: Decouple and optimize priority calcs. 2016-05-25 15:40:59 -05:00
rpcserverhelp_test.go Initial Decred Commit. 2016-02-07 14:00:12 -05:00
rpcserverhelp.go rpcserver: Add filteraddrs param to srt API. 2016-05-25 11:47:19 -05:00
rpcwebsocket.go Make PubKey variable names consistent. 2016-05-12 14:43:13 -05:00
sample-dcrd.conf config: New option --minrelaytxfee 2016-05-19 11:44:08 -05:00
server.go mining: Refactor policy into its own struct. 2016-05-25 13:02:44 -05:00
service_windows.go Initial Decred Commit. 2016-02-07 14:00:12 -05:00
signal.go dcrd: handle signal SIGTERM (#688) (#156) 2016-05-06 08:11:35 -05:00
signalsigterm.go dcrd: handle signal SIGTERM (#688) (#156) 2016-05-06 08:11:35 -05:00
upgrade.go Initial Decred Commit. 2016-02-07 14:00:12 -05:00
upnp.go Fixed DeletePortMapping documentation typo 2015-01-01 21:59:57 +01:00
version.go Bump for v0.1.4 2016-05-25 12:05:45 -04:00

dcrd

[Build Status] (https://travis-ci.org/decred/dcrd) ![ISC License] (http://img.shields.io/badge/license-ISC-blue.svg)

dcrd is a Decred full node implementation written in Go (golang).

This project is currently under active development and is in a Beta state. It is extremely stable and has been in production use for over 6 months as of May 2014, however there are still a couple of major features we want to add before we come out of beta.

It properly downloads, validates, and serves the block chain using the exact rules (including bugs) for block acceptance as Bitcoin Core. We have taken great care to avoid dcrd causing a fork to the block chain. It passes all of the 'official' block acceptance tests (https://github.com/TheBlueMatt/test-scripts) as well as all of the JSON test data in the Bitcoin Core code.

It also relays newly mined blocks, maintains a transaction pool, and relays individual transactions that have not yet made it into a block. It ensures all transactions admitted to the pool follow the rules required by the block chain and also includes the same checks which filter transactions based on miner requirements ("standard" transactions) as Bitcoin Core.

One key difference between dcrd and Bitcoin Core is that dcrd does NOT include wallet functionality and this was a very intentional design decision. See the blog entry here for more details. This means you can't actually make or receive payments directly with dcrd. That functionality is provided by the dcrwallet and btcgui projects which are both under active development.

Requirements

Go 1.3 or newer.

Installation

Windows - MSI Available

https://github.com/decred/dcrd/releases

Linux/BSD/MacOSX/POSIX - Build from Source

  • Install Go according to the installation instructions here: http://golang.org/doc/install

  • Ensure Go was installed properly and is a supported version:

$ go version
$ go env GOROOT GOPATH

NOTE: The GOROOT and GOPATH above must not be the same path. It is recommended that GOPATH is set to a directory in your home directory such as ~/goprojects to avoid write permission issues.

  • Run the following command to obtain dcrd, all dependencies, and install it:
$ go get -u github.com/decred/dcrd/...
  • dcrd (and utilities) will now be installed in either $GOROOT/bin or $GOPATH/bin depending on your configuration. If you did not already add the bin directory to your system path during Go installation, we recommend you do so now.

Updating

Windows

Install a newer MSI

Linux/BSD/MacOSX/POSIX - Build from Source

  • Run the following command to update dcrd, all dependencies, and install it:
$ go get -u -v github.com/decred/dcrd/...

Getting Started

dcrd has several configuration options avilable to tweak how it runs, but all of the basic operations described in the intro section work with zero configuration.

Windows (Installed from MSI)

Launch dcrd from your Start menu.

Linux/BSD/POSIX/Source

$ ./dcrd

IRC

  • irc.freenode.net
  • channel #decred
  • webchat

Issue Tracker

The integrated github issue tracker is used for this project.

Documentation

The documentation is a work-in-progress. It is located in the docs folder.

License

dcrd is licensed under the copyfree ISC License.