This refactors the code that relies on the database main chain index to use the in-memory block index now that the full index is in memory. This is a major optimization for several functions because they no longer have to first consult the database (which is incredibly slow in many cases due to the way leveldb splits all of the information across files) to perform lookups and determine if blocks are in the main chain. It should also be noted that even though the main chain index is no longer used as of this commit, the code which writes the main chain index entries to the database in connectBlock, disconnectBlock, and createChainState have not been removed because, once that is done, it will no longer be possible to downgrade and thus those changes must be performed along with a database migration and associated version bump. An overview of the changes are as follows: - Update all code which previously used the db to use the main chain by height map instead - Update several internal functions which previously accepted the hash to instead accept the block node as the parameter - Rename fetchMainChainBlockByHash to fetchMainChainBlockByNode - Rename fetchBlockByHash to fetchBlockByNode - Rename dbFetchBlockByHash to dbFetchBlockByNode - Update all callers to use the new names and semantics - Optimize HeaderByHeight to use block index/height map instead of db - Move to chain.go since it no longer involves database I/O - Optimize BlockByHash to use block index instead of db - Move to chain.go since it no longer involves database I/O - Optimize BlockByHeight to use block index/height map instead of db - Move to chain.go since it no longer involves database I/O - Optimize MainChainHasBlock to use block index instead of db - Move to chain.go since it no longer involves database I/O - Removed error return since it can no longer fail - Optimize BlockHeightByHash to use block index instead of db - Move to chain.go since it no longer involves database I/O - Optimize BlockHashByHeight to use block index instead of db - Move to chain.go since it no longer involves database I/O - Optimize HeightRange to use block index instead of db - Move to chain.go since it no longer involves database I/O - Remove several unused functions related to the main chain index - dbFetchHeaderByHash - DBFetchHeaderByHeight - dbFetchBlockByHeight - DBFetchBlockByHeight - dbMainChainHasBlock - DBMainChainHasBlock - Rework IsCheckpointCandidate to use block index - Modify the upgrade code to expose the old dbFetchBlockByHeight function only in the local scope since upgrades require the ability to read the old format - Update indexers to fetch the blocks themselves while only querying chain for chain-related details |
||
|---|---|---|
| addrmgr | ||
| blockchain | ||
| certgen | ||
| chaincfg | ||
| cmd | ||
| connmgr | ||
| database | ||
| dcrec | ||
| dcrjson | ||
| dcrutil | ||
| docs | ||
| gcs | ||
| hdkeychain | ||
| limits | ||
| mempool | ||
| mining | ||
| peer | ||
| release | ||
| rpcclient | ||
| rpctest | ||
| sampleconfig | ||
| txscript | ||
| wire | ||
| .dockerignore | ||
| .gitignore | ||
| .travis.yml | ||
| blocklogger.go | ||
| blockmanager.go | ||
| CHANGES | ||
| config.go | ||
| cpuminer.go | ||
| dcrd.go | ||
| doc.go | ||
| Dockerfile-1.9 | ||
| Dockerfile-1.10 | ||
| go.mod | ||
| go.modverify | ||
| Gopkg.lock | ||
| Gopkg.toml | ||
| ipc.go | ||
| LICENSE | ||
| log.go | ||
| mining_test.go | ||
| mining.go | ||
| miningerror.go | ||
| networkparams_test.go | ||
| params.go | ||
| README.md | ||
| rpcserver_test.go | ||
| rpcserver.go | ||
| rpcserverhelp_test.go | ||
| rpcserverhelp.go | ||
| rpcwebsocket.go | ||
| run_tests.sh | ||
| server.go | ||
| service_windows.go | ||
| signal.go | ||
| signalsigterm.go | ||
| upnp.go | ||
| version.go | ||
dcrd
dcrd is a Decred full node implementation written in Go (golang).
This acts as a chain daemon for the Decred cryptocurrency. dcrd maintains the entire past transactional ledger of Decred and allows relaying of transactions to other Decred nodes across the world. To read more about Decred please see the project documentation.
Note: To send or receive funds and join Proof-of-Stake mining, you will also need dcrwallet.
This project is currently under active development and is in a Beta state. It is extremely stable and has been in production use since February 2016.
It is forked from btcd which is a bitcoin full node implementation written in Go. btcd is a ongoing project under active development. Because dcrd is constantly synced with btcd codebase, it will get the benefit of btcd's ongoing upgrades to peer and connection handling, database optimization and other blockchain related technology improvements.
Requirements
Go 1.9 or newer.
Getting Started
- dcrd (and utilities) will now be installed in either
$GOROOT/binor$GOPATH/bindepending 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
-
Dep
Dep is used to manage project dependencies and provide reproducible builds. To install:
go get -u github.com/golang/dep/cmd/dep
Unfortunately, the use of dep prevents a handy tool such as go get from
automatically downloading, building, and installing the source in a single
command. Instead, the latest project and dependency sources must be first
obtained manually with git and dep, and then go is used to build and
install the project.
Getting the source:
For a first time installation, the project and dependency sources can be
obtained manually with git and dep (create directories as needed):
git clone https://github.com/decred/dcrd $GOPATH/src/github.com/decred/dcrd
cd $GOPATH/src/github.com/decred/dcrd
dep ensure
go install . ./cmd/...
To update an existing source tree, pull the latest changes and install the matching dependencies:
cd $GOPATH/src/github.com/decred/dcrd
git pull
dep ensure
go install . ./cmd/...
For more information about Decred and how to set up your software please go to our docs page at docs.decred.org.
Docker
All tests and linters may be run in a docker container using the script
run_tests.sh. This script defaults to using the current supported version of
go. You can run it with the major version of Go you would like to use as the
only arguement to test a previous on a previous version of Go (generally Decred
supports the current version of Go and the previous one).
./run_tests.sh 1.9
To run the tests locally without docker:
./run_tests.sh local
Contact
If you have any further questions you can find us at:
- irc.freenode.net (channel #decred)
- webchat
- forum.decred.org
- decred.slack.com
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.
