diff --git a/blockchain/README.md b/blockchain/README.md index e9ff64b11f..6a1db81088 100644 --- a/blockchain/README.md +++ b/blockchain/README.md @@ -3,96 +3,32 @@ blockchain [![Build Status](https://github.com/decred/dcrd/workflows/Build%20and%20Test/badge.svg)](https://github.com/decred/dcrd/actions) [![ISC License](https://img.shields.io/badge/license-ISC-blue.svg)](http://copyfree.org) -[![Doc](https://img.shields.io/badge/doc-reference-blue.svg)](https://pkg.go.dev/github.com/decred/dcrd/blockchain/v3) +[![Doc](https://img.shields.io/badge/doc-reference-blue.svg)](https://pkg.go.dev/github.com/decred/dcrd/blockchain/v4) -Package blockchain implements Decred block handling and chain selection rules. +The blockchain module provides a couple of packages useful for testing: -The Decred block handling and chain selection rules are an integral, and quite -likely the most important, part of Decred. At its core, Decred is a distributed -consensus of which blocks are valid and which ones will comprise the main block -chain (public ledger) that ultimately determines accepted transactions, so it is -extremely important that fully validating nodes agree on all rules. +* [chaingen](./chaingen/README.md) - Provides facilities for generating a full + chain of blocks +* [fullblocktests](./fullblocktests/README.md) - Provides a set of full block + tests to be used for testing the consensus validation rules -At a high level, this package provides support for inserting new blocks into the -block chain according to the aforementioned rules. It includes functionality -such as rejecting duplicate blocks, ensuring blocks and transactions follow all -rules, and best chain selection along with reorganization. +## Sub Modules -Since this package does not deal with other Decred specifics such as network -communication or wallets, it provides a notification system which gives the -caller a high level of flexibility in how they want to react to certain events -such as newly connected main chain blocks which might result in wallet updates. +Note that the following separate sub modules that are not a part of the this +module are also available: -A comprehensive suite of tests is provided to ensure proper functionality. +* [standalone](./standalone/README.md) - Provides standalone functions useful + for working with the Decred blockchain consensus rules. +* [stake](./stake/doc.go) - Contains code for all of dcrd's stake transaction + chain handling and other portions related to the Proof-of-Stake (PoS) system. -## Decred Chain Processing Overview - -Before a block is allowed into the block chain, it must go through an intensive -series of validation rules. The following list serves as a general outline of -those rules to provide some intuition into what is going on under the hood, but -is by no means exhaustive: - - - Reject duplicate blocks - - Perform a series of sanity checks on the block and its transactions such as - verifying proof of work, timestamps, number and character of transactions, - transaction amounts, script complexity, and merkle root calculations - - Compare the block against predetermined checkpoints for expected timestamps - and difficulty based on elapsed time since the checkpoint - - Perform a series of more thorough checks that depend on the block's position - within the block chain such as verifying block difficulties adhere to - difficulty retarget rules, timestamps are after the median of the last - several blocks, all transactions are finalized, checkpoint blocks match, and - block versions are in line with the previous blocks - - Determine how the block fits into the chain and perform different actions - accordingly in order to ensure any side chains which have higher difficulty - than the main chain become the new main chain - - When a block is being connected to the main chain (either through - reorganization of a side chain to the main chain or just extending the - main chain), perform further checks on the block's transactions such as - verifying transaction duplicates, script complexity for the combination of - connected scripts, coinbase maturity, double spends, and connected - transaction values - - Run the transaction scripts to verify the spender is allowed to spend the - coins - - Insert the block into the block database - - ## Processing Order - - This package supports headers-first semantics such that block data can be - processed out of order so long as the associated header is already known. - - The headers themselves, however, must be processed in the correct order since - headers that do not properly connect are rejected. In other words, orphan - headers are not allowed. - -The processing code always maintains the best chain as the branch tip that has -the most cumulative proof of work, so it is important to keep that in mind when -considering errors returned from processing blocks. - -Notably, due to the ability to process blocks out of order, and the fact blocks -can only be fully validated once all of their ancestors have the block data -available, it is to be expected that no error is returned immediately for blocks -that are valid enough to make it to the point they require the remaining -ancestor block data to be fully validated even though they might ultimately end -up failing validation. Similarly, because the data for a block becoming -available makes any of its direct descendants that already have their data -available eligible for validation, an error being returned does not necessarily -mean the block being processed is the one that failed validation. ## Installation and Updating -This package is part of the `github.com/decred/dcrd/blockchain/v3` module. Use -the standard go tooling for working with modules to incorporate it. - -## Examples - -* [ProcessBlock Example](https://pkg.go.dev/github.com/decred/dcrd/blockchain/v3#example-BlockChain.ProcessBlock) - Demonstrates how to create a new chain instance and use ProcessBlock to - attempt to add a block to the chain. This example intentionally - attempts to insert a duplicate genesis block to illustrate how an invalid - block is handled. +This is the `github.com/decred/dcrd/blockchain/v4` module. Use the standard go +tooling for working with modules to incorporate it. ## License -Package blockchain is licensed under the [copyfree](http://copyfree.org) ISC +Module blockchain is licensed under the [copyfree](http://copyfree.org) ISC License. diff --git a/blockchain/go.mod b/blockchain/go.mod index 67e8f7ba91..a62dafd48d 100644 --- a/blockchain/go.mod +++ b/blockchain/go.mod @@ -3,34 +3,21 @@ module github.com/decred/dcrd/blockchain/v5 go 1.17 require ( - github.com/decred/dcrd/blockchain/stake/v5 v5.0.0 - github.com/decred/dcrd/blockchain/standalone/v2 v2.1.0 github.com/decred/dcrd/chaincfg/chainhash v1.0.3 github.com/decred/dcrd/chaincfg/v3 v3.1.1 - github.com/decred/dcrd/crypto/blake256 v1.0.0 - github.com/decred/dcrd/database/v3 v3.0.0 github.com/decred/dcrd/dcrec v1.0.0 github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 github.com/decred/dcrd/dcrutil/v4 v4.0.0 - github.com/decred/dcrd/gcs/v4 v4.0.0 - github.com/decred/dcrd/lru v1.1.1 github.com/decred/dcrd/txscript/v4 v4.0.0 github.com/decred/dcrd/wire v1.5.0 - github.com/decred/slog v1.2.0 - github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 ) require ( github.com/agl/ed25519 v0.0.0-20170116200512-5312a6153412 // indirect github.com/dchest/siphash v1.2.2 // indirect github.com/decred/base58 v1.0.3 // indirect + github.com/decred/dcrd/crypto/blake256 v1.0.0 // indirect github.com/decred/dcrd/crypto/ripemd160 v1.0.1 // indirect github.com/decred/dcrd/dcrec/edwards/v2 v2.0.2 // indirect - github.com/golang/snappy v0.0.4 // indirect -) - -replace ( - github.com/decred/dcrd/blockchain/stake/v5 => ./stake - github.com/decred/dcrd/blockchain/standalone/v2 => ./standalone - github.com/decred/dcrd/gcs/v4 => ../gcs + github.com/decred/slog v1.2.0 // indirect ) diff --git a/blockchain/go.sum b/blockchain/go.sum index 6f85b8f494..ff65dcc695 100644 --- a/blockchain/go.sum +++ b/blockchain/go.sum @@ -16,8 +16,6 @@ github.com/decred/dcrd/crypto/blake256 v1.0.0 h1:/8DMNYp9SGi5f0w7uCm6d6M4OU2rGFK github.com/decred/dcrd/crypto/blake256 v1.0.0/go.mod h1:sQl2p6Y26YV+ZOcSTP6thNdn47hh8kt6rqSlvmrXFAc= github.com/decred/dcrd/crypto/ripemd160 v1.0.1 h1:TjRL4LfftzTjXzaufov96iDAkbY2R3aTvH2YMYa1IOc= github.com/decred/dcrd/crypto/ripemd160 v1.0.1/go.mod h1:F0H8cjIuWTRoixr/LM3REB8obcWkmYx0gbxpQWR8RPg= -github.com/decred/dcrd/database/v3 v3.0.0 h1:7VVN2sWjKB934jvXzjnyGJFUVH9d8Qh5VULi+NMRjek= -github.com/decred/dcrd/database/v3 v3.0.0/go.mod h1:8EyKddB8rXDi6/CDOdYc/7qL1//sb6iwg9DctP0ZJF4= github.com/decred/dcrd/dcrec v1.0.0 h1:W+z6Es+Rai3MXYVoPAxYr5U1DGis0Co33scJ6uH2J6o= github.com/decred/dcrd/dcrec v1.0.0/go.mod h1:HIaqbEJQ+PDzQcORxnqen5/V1FR3B4VpIfmePklt8Q8= github.com/decred/dcrd/dcrec/edwards/v2 v2.0.2 h1:bX7rtGTMBDJxujZ29GNqtn7YCAdINjHKnA6J6tBBv6s= @@ -26,79 +24,9 @@ github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 h1:YLtO71vCjJRCBcrPMtQ9nqBsqpA1 github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1/go.mod h1:hyedUtir6IdtD/7lIxGeCxkaw7y45JueMRL4DIyJDKs= github.com/decred/dcrd/dcrutil/v4 v4.0.0 h1:AY00fWy/ETrMHN0DNV3XUbH1aip2RG1AoTy5dp0+sJE= github.com/decred/dcrd/dcrutil/v4 v4.0.0/go.mod h1:QQpX5WVH3/ixVtiW15xZMe+neugXX3l2bsrYgq6nz4M= -github.com/decred/dcrd/lru v1.1.1 h1:kWFDaW0OWx6AD6Ki342c+JPmHbiVdE6rK81pT3fuo/Y= -github.com/decred/dcrd/lru v1.1.1/go.mod h1:mxKOwFd7lFjN2GZYsiz/ecgqR6kkYAl+0pz0tEMk218= github.com/decred/dcrd/txscript/v4 v4.0.0 h1:BwaBUCMCmg58MCYoBhxVjL8ZZKUIfoJuxu/djmh8h58= github.com/decred/dcrd/txscript/v4 v4.0.0/go.mod h1:OJtxNc5RqwQyfrRnG2gG8uMeNPo8IAJp+TD1UKXkqk8= -github.com/decred/dcrd/wire v1.4.0/go.mod h1:WxC/0K+cCAnBh+SKsRjIX9YPgvrjhmE+6pZlel1G7Ro= github.com/decred/dcrd/wire v1.5.0 h1:3SgcEzSjqAMQvOugP0a8iX7yQSpiVT1yNi9bc4iOXVg= github.com/decred/dcrd/wire v1.5.0/go.mod h1:fzAjVqw32LkbAZIt5mnrvBR751GTa3e0rRQdOIhPY3w= github.com/decred/slog v1.2.0 h1:soHAxV52B54Di3WtKLfPum9OFfWqwtf/ygf9njdfnPM= github.com/decred/slog v1.2.0/go.mod h1:kVXlGnt6DHy2fV5OjSeuvCJ0OmlmTF6LFpEPMu/fOY0= -github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= -github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4= -github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= -github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= -github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= -github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= -github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= -github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= -github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= -github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM= -github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= -github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= -github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= -github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= -github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= -github.com/nxadm/tail v1.4.4 h1:DQuhQpB1tVlglWS2hLQ5OV6B5r8aGxSrPc5Qo6uTN78= -github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= -github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= -github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= -github.com/onsi/ginkgo v1.14.0 h1:2mOpI4JVVPBN+WQRa0WKH2eXR+Ey+uK4n7Zj0aYpIQA= -github.com/onsi/ginkgo v1.14.0/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9klQyY= -github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= -github.com/onsi/gomega v1.10.1 h1:o0+MgICZLuZ7xjH7Vx6zS/zcu93/BEp1VwkIW1mEXCE= -github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= -github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 h1:epCh84lMvA70Z7CTTCmYQn2CKbY8j86K7/FAIr141uY= -github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7/go.mod h1:q4W45IWZaF22tdD+VEXcAWRA037jwmWEB5VWYORlTpc= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200813134508-3edf25e44fcc h1:zK/HqS5bZxDptfPJNq8v7vJfXtkU7r9TLIoSr1bXaP4= -golang.org/x/net v0.0.0-20200813134508-3edf25e44fcc/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= -golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200519105757-fe76b779f299/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200814200057-3d37ad5750ed h1:J22ig1FUekjjkmZUM7pTKixYm8DvrYsvrBZdunYeIuQ= -golang.org/x/sys v0.0.0-20200814200057-3d37ad5750ed/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= -golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= -google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= -google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= -google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= -google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= -google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= -gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= -gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= -gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU= -gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/blockdb.go b/blockdb.go index c25b473ac0..41dcf550ac 100644 --- a/blockdb.go +++ b/blockdb.go @@ -12,9 +12,9 @@ import ( "os" "path/filepath" - "github.com/decred/dcrd/blockchain/v5" "github.com/decred/dcrd/chaincfg/v3" "github.com/decred/dcrd/database/v3" + "github.com/decred/dcrd/internal/blockchain" "github.com/decred/dcrd/internal/progresslog" ) diff --git a/cmd/addblock/addblock.go b/cmd/addblock/addblock.go index f70b005d33..c6c24ea5ae 100644 --- a/cmd/addblock/addblock.go +++ b/cmd/addblock/addblock.go @@ -12,9 +12,9 @@ import ( "path/filepath" "runtime" - "github.com/decred/dcrd/blockchain/v5" - "github.com/decred/dcrd/blockchain/v5/indexers" "github.com/decred/dcrd/database/v3" + "github.com/decred/dcrd/internal/blockchain" + "github.com/decred/dcrd/internal/blockchain/indexers" "github.com/decred/dcrd/internal/limits" "github.com/decred/slog" ) diff --git a/cmd/addblock/import.go b/cmd/addblock/import.go index f210640413..c73ae64964 100644 --- a/cmd/addblock/import.go +++ b/cmd/addblock/import.go @@ -14,11 +14,11 @@ import ( "sync" "time" - "github.com/decred/dcrd/blockchain/v5" - "github.com/decred/dcrd/blockchain/v5/indexers" "github.com/decred/dcrd/chaincfg/chainhash" "github.com/decred/dcrd/database/v3" "github.com/decred/dcrd/dcrutil/v4" + "github.com/decred/dcrd/internal/blockchain" + "github.com/decred/dcrd/internal/blockchain/indexers" "github.com/decred/dcrd/wire" "github.com/syndtr/goleveldb/leveldb" ) diff --git a/dcrd.go b/dcrd.go index 46d46013af..575417cd25 100644 --- a/dcrd.go +++ b/dcrd.go @@ -17,8 +17,8 @@ import ( "runtime/pprof" "strings" - "github.com/decred/dcrd/blockchain/v5" - "github.com/decred/dcrd/blockchain/v5/indexers" + "github.com/decred/dcrd/internal/blockchain" + "github.com/decred/dcrd/internal/blockchain/indexers" "github.com/decred/dcrd/internal/limits" "github.com/decred/dcrd/internal/version" ) diff --git a/gcs/go.sum b/gcs/go.sum index 5d55f8d48d..2ae51c3e62 100644 --- a/gcs/go.sum +++ b/gcs/go.sum @@ -6,8 +6,6 @@ github.com/dchest/siphash v1.2.2 h1:9DFz8tQwl9pTVt5iok/9zKyzA1Q6bRGiF3HPiEEVr9I= github.com/dchest/siphash v1.2.2/go.mod h1:q+IRvb2gOSrUnYoPqHiyHXS0FOBBOdl6tONBlVnOnt4= github.com/decred/base58 v1.0.3 h1:KGZuh8d1WEMIrK0leQRM47W85KqCAdl2N+uagbctdDI= github.com/decred/base58 v1.0.3/go.mod h1:pXP9cXCfM2sFLb2viz2FNIdeMWmZDBKG3ZBYbiSM78E= -github.com/decred/dcrd/blockchain/stake/v5 v5.0.0 h1:PwoCjCTbRvDUZKKs6N2Haus8XcbVXCJ9iGVs8C9sKwQ= -github.com/decred/dcrd/blockchain/stake/v5 v5.0.0/go.mod h1:bOgG7YTbTOWQgtHLL2l1Y9gBHIuM86zwVcQtsoGlZlQ= github.com/decred/dcrd/chaincfg/chainhash v1.0.2/go.mod h1:BpbrGgrPTr3YJYRN3Bm+D9NuaFd+zGyNeIKgrhCXK60= github.com/decred/dcrd/chaincfg/chainhash v1.0.3 h1:PF2czcYZGW3dz4i/35AUfVAgnqHl9TMNQt1ADTYGOoE= github.com/decred/dcrd/chaincfg/chainhash v1.0.3/go.mod h1:BpbrGgrPTr3YJYRN3Bm+D9NuaFd+zGyNeIKgrhCXK60= diff --git a/go.mod b/go.mod index 2a5a592557..e442f7116f 100644 --- a/go.mod +++ b/go.mod @@ -15,6 +15,7 @@ require ( github.com/decred/dcrd/chaincfg/v3 v3.1.1 github.com/decred/dcrd/connmgr/v3 v3.1.0 github.com/decred/dcrd/container/apbf v1.0.0 + github.com/decred/dcrd/crypto/blake256 v1.0.0 github.com/decred/dcrd/crypto/ripemd160 v1.0.1 github.com/decred/dcrd/database/v3 v3.0.0 github.com/decred/dcrd/dcrec v1.0.0 @@ -44,7 +45,6 @@ require ( require ( github.com/agl/ed25519 v0.0.0-20170116200512-5312a6153412 // indirect github.com/dchest/siphash v1.2.2 // indirect - github.com/decred/dcrd/crypto/blake256 v1.0.0 // indirect github.com/decred/dcrd/dcrec/edwards/v2 v2.0.2 // indirect github.com/golang/snappy v0.0.4 // indirect ) diff --git a/blockchain/doc.go b/internal/blockchain/README.md similarity index 74% rename from blockchain/doc.go rename to internal/blockchain/README.md index bc673a71c9..9ad3ba0f2f 100644 --- a/blockchain/doc.go +++ b/internal/blockchain/README.md @@ -1,9 +1,10 @@ -// Copyright (c) 2013-2014 The btcsuite developers -// Copyright (c) 2015-2020 The Decred developers -// Use of this source code is governed by an ISC -// license that can be found in the LICENSE file. +blockchain +========== + +[![Build Status](https://github.com/decred/dcrd/workflows/Build%20and%20Test/badge.svg)](https://github.com/decred/dcrd/actions) +[![ISC License](https://img.shields.io/badge/license-ISC-blue.svg)](http://copyfree.org) +[![Doc](https://img.shields.io/badge/doc-reference-blue.svg)](https://pkg.go.dev/github.com/decred/dcrd/internal/blockchain) -/* Package blockchain implements Decred block handling and chain selection rules. The Decred block handling and chain selection rules are an integral, and quite @@ -22,7 +23,9 @@ communication or wallets, it provides a notification system which gives the caller a high level of flexibility in how they want to react to certain events such as newly connected main chain blocks which might result in wallet updates. -Decred Chain Processing Overview +A comprehensive suite of tests is provided to ensure proper functionality. + +## Decred Chain Processing Overview Before a block is allowed into the block chain, it must go through an intensive series of validation rules. The following list serves as a general outline of @@ -53,14 +56,14 @@ is by no means exhaustive: coins - Insert the block into the block database -Processing Order + ## Processing Order -This package supports headers-first semantics such that block data can be -processed out of order so long as the associated header is already known. + This package supports headers-first semantics such that block data can be + processed out of order so long as the associated header is already known. -The headers themselves, however, must be processed in the correct order since -headers that do not properly connect are rejected. In other words, orphan -headers are not allowed. + The headers themselves, however, must be processed in the correct order since + headers that do not properly connect are rejected. In other words, orphan + headers are not allowed. The processing code always maintains the best chain as the branch tip that has the most cumulative proof of work, so it is important to keep that in mind when @@ -76,7 +79,7 @@ available makes any of its direct descendants that already have their data available eligible for validation, an error being returned does not necessarily mean the block being processed is the one that failed validation. -Errors +## Errors Errors returned by this package have full support for the standard library errors.Is and errors.As methods and are either the raw errors provided by @@ -86,5 +89,21 @@ unexpected errors, such as database errors, versus errors due to rule violations through errors.As. In addition, callers can programmatically determine the specific rule violation by making use of errors.Is with any of the wrapped error kinds. -*/ -package blockchain + +## Installation and Updating + +This package is internal and therefore is neither directly installed nor needs +to be manually updated. + +## Examples + +* [ProcessBlock Example](https://pkg.go.dev/github.com/decred/dcrd/internal/blockchain#example-BlockChain.ProcessBlock) + Demonstrates how to create a new chain instance and use ProcessBlock to + attempt to add a block to the chain. This example intentionally + attempts to insert a duplicate genesis block to illustrate how an invalid + block is handled. + +## License + +Package blockchain is licensed under the [copyfree](http://copyfree.org) ISC +License. diff --git a/blockchain/agendas_test.go b/internal/blockchain/agendas_test.go similarity index 100% rename from blockchain/agendas_test.go rename to internal/blockchain/agendas_test.go diff --git a/blockchain/bench_test.go b/internal/blockchain/bench_test.go similarity index 100% rename from blockchain/bench_test.go rename to internal/blockchain/bench_test.go diff --git a/blockchain/blockindex.go b/internal/blockchain/blockindex.go similarity index 100% rename from blockchain/blockindex.go rename to internal/blockchain/blockindex.go diff --git a/blockchain/blockindex_test.go b/internal/blockchain/blockindex_test.go similarity index 100% rename from blockchain/blockindex_test.go rename to internal/blockchain/blockindex_test.go diff --git a/blockchain/chain.go b/internal/blockchain/chain.go similarity index 99% rename from blockchain/chain.go rename to internal/blockchain/chain.go index d5ffe8fb2c..6098873239 100644 --- a/blockchain/chain.go +++ b/internal/blockchain/chain.go @@ -3,6 +3,8 @@ // Use of this source code is governed by an ISC // license that can be found in the LICENSE file. +// Package blockchain implements Decred block handling and chain selection +// rules. package blockchain import ( @@ -15,14 +17,14 @@ import ( "github.com/decred/dcrd/blockchain/stake/v5" "github.com/decred/dcrd/blockchain/standalone/v2" - "github.com/decred/dcrd/blockchain/v5/indexers" - "github.com/decred/dcrd/blockchain/v5/internal/spendpruner" "github.com/decred/dcrd/chaincfg/chainhash" "github.com/decred/dcrd/chaincfg/v3" "github.com/decred/dcrd/database/v3" "github.com/decred/dcrd/dcrutil/v4" "github.com/decred/dcrd/gcs/v4" "github.com/decred/dcrd/gcs/v4/blockcf2" + "github.com/decred/dcrd/internal/blockchain/indexers" + "github.com/decred/dcrd/internal/blockchain/spendpruner" "github.com/decred/dcrd/lru" "github.com/decred/dcrd/txscript/v4" "github.com/decred/dcrd/wire" diff --git a/blockchain/chain_test.go b/internal/blockchain/chain_test.go similarity index 100% rename from blockchain/chain_test.go rename to internal/blockchain/chain_test.go diff --git a/blockchain/chainio.go b/internal/blockchain/chainio.go similarity index 100% rename from blockchain/chainio.go rename to internal/blockchain/chainio.go diff --git a/blockchain/chainio_test.go b/internal/blockchain/chainio_test.go similarity index 100% rename from blockchain/chainio_test.go rename to internal/blockchain/chainio_test.go diff --git a/blockchain/chainquery.go b/internal/blockchain/chainquery.go similarity index 100% rename from blockchain/chainquery.go rename to internal/blockchain/chainquery.go diff --git a/blockchain/chainview.go b/internal/blockchain/chainview.go similarity index 100% rename from blockchain/chainview.go rename to internal/blockchain/chainview.go diff --git a/blockchain/chainview_test.go b/internal/blockchain/chainview_test.go similarity index 100% rename from blockchain/chainview_test.go rename to internal/blockchain/chainview_test.go diff --git a/blockchain/common_test.go b/internal/blockchain/common_test.go similarity index 100% rename from blockchain/common_test.go rename to internal/blockchain/common_test.go diff --git a/blockchain/compress.go b/internal/blockchain/compress.go similarity index 100% rename from blockchain/compress.go rename to internal/blockchain/compress.go diff --git a/blockchain/compress_test.go b/internal/blockchain/compress_test.go similarity index 100% rename from blockchain/compress_test.go rename to internal/blockchain/compress_test.go diff --git a/blockchain/difficulty.go b/internal/blockchain/difficulty.go similarity index 100% rename from blockchain/difficulty.go rename to internal/blockchain/difficulty.go diff --git a/blockchain/difficulty_test.go b/internal/blockchain/difficulty_test.go similarity index 100% rename from blockchain/difficulty_test.go rename to internal/blockchain/difficulty_test.go diff --git a/blockchain/error.go b/internal/blockchain/error.go similarity index 100% rename from blockchain/error.go rename to internal/blockchain/error.go diff --git a/blockchain/error_test.go b/internal/blockchain/error_test.go similarity index 100% rename from blockchain/error_test.go rename to internal/blockchain/error_test.go diff --git a/blockchain/example_test.go b/internal/blockchain/example_test.go similarity index 98% rename from blockchain/example_test.go rename to internal/blockchain/example_test.go index 30f2170c5f..0ae4b4514e 100644 --- a/blockchain/example_test.go +++ b/internal/blockchain/example_test.go @@ -11,11 +11,11 @@ import ( "os" "path/filepath" - "github.com/decred/dcrd/blockchain/v5" "github.com/decred/dcrd/chaincfg/v3" "github.com/decred/dcrd/database/v3" _ "github.com/decred/dcrd/database/v3/ffldb" "github.com/decred/dcrd/dcrutil/v4" + "github.com/decred/dcrd/internal/blockchain" "github.com/syndtr/goleveldb/leveldb" "github.com/syndtr/goleveldb/leveldb/filter" "github.com/syndtr/goleveldb/leveldb/opt" diff --git a/blockchain/fullblocks_test.go b/internal/blockchain/fullblocks_test.go similarity index 100% rename from blockchain/fullblocks_test.go rename to internal/blockchain/fullblocks_test.go diff --git a/blockchain/fullblocksstakeversion_test.go b/internal/blockchain/fullblocksstakeversion_test.go similarity index 100% rename from blockchain/fullblocksstakeversion_test.go rename to internal/blockchain/fullblocksstakeversion_test.go diff --git a/blockchain/headercmt.go b/internal/blockchain/headercmt.go similarity index 100% rename from blockchain/headercmt.go rename to internal/blockchain/headercmt.go diff --git a/blockchain/headercmt_test.go b/internal/blockchain/headercmt_test.go similarity index 100% rename from blockchain/headercmt_test.go rename to internal/blockchain/headercmt_test.go diff --git a/blockchain/indexers/README.md b/internal/blockchain/indexers/README.md similarity index 86% rename from blockchain/indexers/README.md rename to internal/blockchain/indexers/README.md index d9c5ae6326..18fbbb3798 100644 --- a/blockchain/indexers/README.md +++ b/internal/blockchain/indexers/README.md @@ -3,7 +3,7 @@ indexers [![Build Status](https://github.com/decred/dcrd/workflows/Build%20and%20Test/badge.svg)](https://github.com/decred/dcrd/actions) [![ISC License](https://img.shields.io/badge/license-ISC-blue.svg)](http://copyfree.org) -[![Doc](https://img.shields.io/badge/doc-reference-blue.svg)](https://pkg.go.dev/github.com/decred/dcrd/blockchain/v4/indexers) +[![Doc](https://img.shields.io/badge/doc-reference-blue.svg)](https://pkg.go.dev/github.com/decred/dcrd/internal/blockchain/indexers) Package indexers implements optional block chain indexes. @@ -31,8 +31,8 @@ via an RPC interface. ## Installation and Updating -This package is part of the `github.com/decred/dcrd/blockchain/v4` module. Use -the standard go tooling for working with modules to incorporate it. +This package is internal and therefore is neither directly installed nor needs +to be manually updated. ## License diff --git a/blockchain/indexers/common.go b/internal/blockchain/indexers/common.go similarity index 99% rename from blockchain/indexers/common.go rename to internal/blockchain/indexers/common.go index bfbece1035..d62576c792 100644 --- a/blockchain/indexers/common.go +++ b/internal/blockchain/indexers/common.go @@ -14,12 +14,12 @@ import ( "errors" "fmt" - "github.com/decred/dcrd/blockchain/v5/internal/progresslog" - "github.com/decred/dcrd/blockchain/v5/internal/spendpruner" "github.com/decred/dcrd/chaincfg/chainhash" "github.com/decred/dcrd/chaincfg/v3" "github.com/decred/dcrd/database/v3" "github.com/decred/dcrd/dcrutil/v4" + "github.com/decred/dcrd/internal/blockchain/progresslog" + "github.com/decred/dcrd/internal/blockchain/spendpruner" "github.com/decred/dcrd/wire" ) diff --git a/blockchain/indexers/dropaddrindex.go b/internal/blockchain/indexers/dropaddrindex.go similarity index 100% rename from blockchain/indexers/dropaddrindex.go rename to internal/blockchain/indexers/dropaddrindex.go diff --git a/blockchain/indexers/dropcfindex.go b/internal/blockchain/indexers/dropcfindex.go similarity index 100% rename from blockchain/indexers/dropcfindex.go rename to internal/blockchain/indexers/dropcfindex.go diff --git a/blockchain/indexers/error.go b/internal/blockchain/indexers/error.go similarity index 100% rename from blockchain/indexers/error.go rename to internal/blockchain/indexers/error.go diff --git a/blockchain/indexers/error_test.go b/internal/blockchain/indexers/error_test.go similarity index 100% rename from blockchain/indexers/error_test.go rename to internal/blockchain/indexers/error_test.go diff --git a/blockchain/indexers/existsaddrindex.go b/internal/blockchain/indexers/existsaddrindex.go similarity index 100% rename from blockchain/indexers/existsaddrindex.go rename to internal/blockchain/indexers/existsaddrindex.go diff --git a/blockchain/indexers/existsaddrindex_test.go b/internal/blockchain/indexers/existsaddrindex_test.go similarity index 100% rename from blockchain/indexers/existsaddrindex_test.go rename to internal/blockchain/indexers/existsaddrindex_test.go diff --git a/blockchain/indexers/indexsubscriber.go b/internal/blockchain/indexers/indexsubscriber.go similarity index 99% rename from blockchain/indexers/indexsubscriber.go rename to internal/blockchain/indexers/indexsubscriber.go index 462c42b090..a660e1d0c7 100644 --- a/blockchain/indexers/indexsubscriber.go +++ b/internal/blockchain/indexers/indexsubscriber.go @@ -11,9 +11,9 @@ import ( "sync/atomic" "time" - "github.com/decred/dcrd/blockchain/v5/internal/progresslog" "github.com/decred/dcrd/database/v3" "github.com/decred/dcrd/dcrutil/v4" + "github.com/decred/dcrd/internal/blockchain/progresslog" ) // IndexNtfnType represents an index notification type. diff --git a/blockchain/indexers/indexsubscriber_test.go b/internal/blockchain/indexers/indexsubscriber_test.go similarity index 100% rename from blockchain/indexers/indexsubscriber_test.go rename to internal/blockchain/indexers/indexsubscriber_test.go diff --git a/blockchain/indexers/log.go b/internal/blockchain/indexers/log.go similarity index 100% rename from blockchain/indexers/log.go rename to internal/blockchain/indexers/log.go diff --git a/blockchain/indexers/spendconsumer.go b/internal/blockchain/indexers/spendconsumer.go similarity index 100% rename from blockchain/indexers/spendconsumer.go rename to internal/blockchain/indexers/spendconsumer.go diff --git a/blockchain/indexers/spendconsumer_test.go b/internal/blockchain/indexers/spendconsumer_test.go similarity index 100% rename from blockchain/indexers/spendconsumer_test.go rename to internal/blockchain/indexers/spendconsumer_test.go diff --git a/blockchain/indexers/txindex.go b/internal/blockchain/indexers/txindex.go similarity index 100% rename from blockchain/indexers/txindex.go rename to internal/blockchain/indexers/txindex.go diff --git a/blockchain/indexers/txindex_test.go b/internal/blockchain/indexers/txindex_test.go similarity index 99% rename from blockchain/indexers/txindex_test.go rename to internal/blockchain/indexers/txindex_test.go index ae0c59ea69..64e4d7538e 100644 --- a/blockchain/indexers/txindex_test.go +++ b/internal/blockchain/indexers/txindex_test.go @@ -12,12 +12,12 @@ import ( "time" "github.com/decred/dcrd/blockchain/v5/chaingen" - "github.com/decred/dcrd/blockchain/v5/internal/spendpruner" "github.com/decred/dcrd/chaincfg/chainhash" "github.com/decred/dcrd/chaincfg/v3" "github.com/decred/dcrd/database/v3" _ "github.com/decred/dcrd/database/v3/ffldb" "github.com/decred/dcrd/dcrutil/v4" + "github.com/decred/dcrd/internal/blockchain/spendpruner" "github.com/decred/dcrd/wire" ) diff --git a/blockchain/log.go b/internal/blockchain/log.go similarity index 100% rename from blockchain/log.go rename to internal/blockchain/log.go diff --git a/blockchain/mediantime.go b/internal/blockchain/mediantime.go similarity index 100% rename from blockchain/mediantime.go rename to internal/blockchain/mediantime.go diff --git a/blockchain/mediantime_test.go b/internal/blockchain/mediantime_test.go similarity index 100% rename from blockchain/mediantime_test.go rename to internal/blockchain/mediantime_test.go diff --git a/blockchain/notifications.go b/internal/blockchain/notifications.go similarity index 99% rename from blockchain/notifications.go rename to internal/blockchain/notifications.go index 622d5eb00f..235151feda 100644 --- a/blockchain/notifications.go +++ b/internal/blockchain/notifications.go @@ -8,9 +8,9 @@ package blockchain import ( "fmt" - "github.com/decred/dcrd/blockchain/v5/indexers" "github.com/decred/dcrd/chaincfg/chainhash" "github.com/decred/dcrd/dcrutil/v4" + "github.com/decred/dcrd/internal/blockchain/indexers" ) // NotificationType represents the type of a notification message. diff --git a/blockchain/process.go b/internal/blockchain/process.go similarity index 100% rename from blockchain/process.go rename to internal/blockchain/process.go diff --git a/blockchain/process_test.go b/internal/blockchain/process_test.go similarity index 100% rename from blockchain/process_test.go rename to internal/blockchain/process_test.go diff --git a/blockchain/internal/progresslog/blocklogger.go b/internal/blockchain/progresslog/blocklogger.go similarity index 100% rename from blockchain/internal/progresslog/blocklogger.go rename to internal/blockchain/progresslog/blocklogger.go diff --git a/blockchain/prune.go b/internal/blockchain/prune.go similarity index 100% rename from blockchain/prune.go rename to internal/blockchain/prune.go diff --git a/blockchain/scriptval.go b/internal/blockchain/scriptval.go similarity index 100% rename from blockchain/scriptval.go rename to internal/blockchain/scriptval.go diff --git a/blockchain/sequencelock.go b/internal/blockchain/sequencelock.go similarity index 100% rename from blockchain/sequencelock.go rename to internal/blockchain/sequencelock.go diff --git a/blockchain/sequencelock_test.go b/internal/blockchain/sequencelock_test.go similarity index 100% rename from blockchain/sequencelock_test.go rename to internal/blockchain/sequencelock_test.go diff --git a/blockchain/internal/spendpruner/db.go b/internal/blockchain/spendpruner/db.go similarity index 100% rename from blockchain/internal/spendpruner/db.go rename to internal/blockchain/spendpruner/db.go diff --git a/blockchain/internal/spendpruner/db_test.go b/internal/blockchain/spendpruner/db_test.go similarity index 100% rename from blockchain/internal/spendpruner/db_test.go rename to internal/blockchain/spendpruner/db_test.go diff --git a/blockchain/internal/spendpruner/error.go b/internal/blockchain/spendpruner/error.go similarity index 100% rename from blockchain/internal/spendpruner/error.go rename to internal/blockchain/spendpruner/error.go diff --git a/blockchain/internal/spendpruner/error_test.go b/internal/blockchain/spendpruner/error_test.go similarity index 100% rename from blockchain/internal/spendpruner/error_test.go rename to internal/blockchain/spendpruner/error_test.go diff --git a/blockchain/internal/spendpruner/interface.go b/internal/blockchain/spendpruner/interface.go similarity index 100% rename from blockchain/internal/spendpruner/interface.go rename to internal/blockchain/spendpruner/interface.go diff --git a/blockchain/internal/spendpruner/log.go b/internal/blockchain/spendpruner/log.go similarity index 100% rename from blockchain/internal/spendpruner/log.go rename to internal/blockchain/spendpruner/log.go diff --git a/blockchain/internal/spendpruner/pruner.go b/internal/blockchain/spendpruner/pruner.go similarity index 100% rename from blockchain/internal/spendpruner/pruner.go rename to internal/blockchain/spendpruner/pruner.go diff --git a/blockchain/internal/spendpruner/pruner_test.go b/internal/blockchain/spendpruner/pruner_test.go similarity index 100% rename from blockchain/internal/spendpruner/pruner_test.go rename to internal/blockchain/spendpruner/pruner_test.go diff --git a/blockchain/stakeext.go b/internal/blockchain/stakeext.go similarity index 100% rename from blockchain/stakeext.go rename to internal/blockchain/stakeext.go diff --git a/blockchain/stakenode.go b/internal/blockchain/stakenode.go similarity index 100% rename from blockchain/stakenode.go rename to internal/blockchain/stakenode.go diff --git a/blockchain/stakeversion.go b/internal/blockchain/stakeversion.go similarity index 100% rename from blockchain/stakeversion.go rename to internal/blockchain/stakeversion.go diff --git a/blockchain/stakeversion_test.go b/internal/blockchain/stakeversion_test.go similarity index 100% rename from blockchain/stakeversion_test.go rename to internal/blockchain/stakeversion_test.go diff --git a/blockchain/subsidy.go b/internal/blockchain/subsidy.go similarity index 100% rename from blockchain/subsidy.go rename to internal/blockchain/subsidy.go diff --git a/blockchain/testdata/blocks0to168.bz2 b/internal/blockchain/testdata/blocks0to168.bz2 similarity index 100% rename from blockchain/testdata/blocks0to168.bz2 rename to internal/blockchain/testdata/blocks0to168.bz2 diff --git a/blockchain/testdata/reorgto179.bz2 b/internal/blockchain/testdata/reorgto179.bz2 similarity index 100% rename from blockchain/testdata/reorgto179.bz2 rename to internal/blockchain/testdata/reorgto179.bz2 diff --git a/blockchain/thresholdstate.go b/internal/blockchain/thresholdstate.go similarity index 100% rename from blockchain/thresholdstate.go rename to internal/blockchain/thresholdstate.go diff --git a/blockchain/thresholdstate_test.go b/internal/blockchain/thresholdstate_test.go similarity index 100% rename from blockchain/thresholdstate_test.go rename to internal/blockchain/thresholdstate_test.go diff --git a/blockchain/timesorter.go b/internal/blockchain/timesorter.go similarity index 100% rename from blockchain/timesorter.go rename to internal/blockchain/timesorter.go diff --git a/blockchain/timesorter_test.go b/internal/blockchain/timesorter_test.go similarity index 100% rename from blockchain/timesorter_test.go rename to internal/blockchain/timesorter_test.go diff --git a/blockchain/treasury.go b/internal/blockchain/treasury.go similarity index 100% rename from blockchain/treasury.go rename to internal/blockchain/treasury.go diff --git a/blockchain/treasury_policy_test.go b/internal/blockchain/treasury_policy_test.go similarity index 100% rename from blockchain/treasury_policy_test.go rename to internal/blockchain/treasury_policy_test.go diff --git a/blockchain/treasury_test.go b/internal/blockchain/treasury_test.go similarity index 100% rename from blockchain/treasury_test.go rename to internal/blockchain/treasury_test.go diff --git a/blockchain/upgrade.go b/internal/blockchain/upgrade.go similarity index 100% rename from blockchain/upgrade.go rename to internal/blockchain/upgrade.go diff --git a/blockchain/upgrade_test.go b/internal/blockchain/upgrade_test.go similarity index 100% rename from blockchain/upgrade_test.go rename to internal/blockchain/upgrade_test.go diff --git a/blockchain/utxobackend.go b/internal/blockchain/utxobackend.go similarity index 100% rename from blockchain/utxobackend.go rename to internal/blockchain/utxobackend.go diff --git a/blockchain/utxobackend_test.go b/internal/blockchain/utxobackend_test.go similarity index 100% rename from blockchain/utxobackend_test.go rename to internal/blockchain/utxobackend_test.go diff --git a/blockchain/utxobackenditerator.go b/internal/blockchain/utxobackenditerator.go similarity index 100% rename from blockchain/utxobackenditerator.go rename to internal/blockchain/utxobackenditerator.go diff --git a/blockchain/utxobackendtx.go b/internal/blockchain/utxobackendtx.go similarity index 100% rename from blockchain/utxobackendtx.go rename to internal/blockchain/utxobackendtx.go diff --git a/blockchain/utxocache.go b/internal/blockchain/utxocache.go similarity index 100% rename from blockchain/utxocache.go rename to internal/blockchain/utxocache.go diff --git a/blockchain/utxocache_test.go b/internal/blockchain/utxocache_test.go similarity index 100% rename from blockchain/utxocache_test.go rename to internal/blockchain/utxocache_test.go diff --git a/blockchain/utxoentry.go b/internal/blockchain/utxoentry.go similarity index 100% rename from blockchain/utxoentry.go rename to internal/blockchain/utxoentry.go diff --git a/blockchain/utxoentry_test.go b/internal/blockchain/utxoentry_test.go similarity index 100% rename from blockchain/utxoentry_test.go rename to internal/blockchain/utxoentry_test.go diff --git a/blockchain/utxoio.go b/internal/blockchain/utxoio.go similarity index 100% rename from blockchain/utxoio.go rename to internal/blockchain/utxoio.go diff --git a/blockchain/utxoio_test.go b/internal/blockchain/utxoio_test.go similarity index 100% rename from blockchain/utxoio_test.go rename to internal/blockchain/utxoio_test.go diff --git a/blockchain/utxoviewpoint.go b/internal/blockchain/utxoviewpoint.go similarity index 100% rename from blockchain/utxoviewpoint.go rename to internal/blockchain/utxoviewpoint.go diff --git a/blockchain/utxoviewpoint_test.go b/internal/blockchain/utxoviewpoint_test.go similarity index 100% rename from blockchain/utxoviewpoint_test.go rename to internal/blockchain/utxoviewpoint_test.go diff --git a/blockchain/validate.go b/internal/blockchain/validate.go similarity index 100% rename from blockchain/validate.go rename to internal/blockchain/validate.go diff --git a/blockchain/validate_test.go b/internal/blockchain/validate_test.go similarity index 100% rename from blockchain/validate_test.go rename to internal/blockchain/validate_test.go diff --git a/blockchain/votebits.go b/internal/blockchain/votebits.go similarity index 100% rename from blockchain/votebits.go rename to internal/blockchain/votebits.go diff --git a/blockchain/votebits_test.go b/internal/blockchain/votebits_test.go similarity index 100% rename from blockchain/votebits_test.go rename to internal/blockchain/votebits_test.go diff --git a/internal/mempool/error.go b/internal/mempool/error.go index 45b3776faf..31c71d80cd 100644 --- a/internal/mempool/error.go +++ b/internal/mempool/error.go @@ -9,7 +9,7 @@ import ( "errors" "fmt" - "github.com/decred/dcrd/blockchain/v5" + "github.com/decred/dcrd/internal/blockchain" ) // ErrorKind identifies a kind of error. It has full support for errors.Is and diff --git a/internal/mempool/mempool.go b/internal/mempool/mempool.go index 9d08508039..ad5c3a24ad 100644 --- a/internal/mempool/mempool.go +++ b/internal/mempool/mempool.go @@ -15,11 +15,11 @@ import ( "github.com/decred/dcrd/blockchain/stake/v5" "github.com/decred/dcrd/blockchain/standalone/v2" - "github.com/decred/dcrd/blockchain/v5" - "github.com/decred/dcrd/blockchain/v5/indexers" "github.com/decred/dcrd/chaincfg/chainhash" "github.com/decred/dcrd/chaincfg/v3" "github.com/decred/dcrd/dcrutil/v4" + "github.com/decred/dcrd/internal/blockchain" + "github.com/decred/dcrd/internal/blockchain/indexers" "github.com/decred/dcrd/internal/mining" "github.com/decred/dcrd/txscript/v4" "github.com/decred/dcrd/wire" diff --git a/internal/mempool/mempool_test.go b/internal/mempool/mempool_test.go index 3593a6d6b4..dc1f945690 100644 --- a/internal/mempool/mempool_test.go +++ b/internal/mempool/mempool_test.go @@ -18,12 +18,12 @@ import ( "github.com/decred/dcrd/blockchain/stake/v5" "github.com/decred/dcrd/blockchain/standalone/v2" - "github.com/decred/dcrd/blockchain/v5" "github.com/decred/dcrd/chaincfg/chainhash" "github.com/decred/dcrd/chaincfg/v3" "github.com/decred/dcrd/dcrec" "github.com/decred/dcrd/dcrec/secp256k1/v4" "github.com/decred/dcrd/dcrutil/v4" + "github.com/decred/dcrd/internal/blockchain" "github.com/decred/dcrd/internal/mining" "github.com/decred/dcrd/txscript/v4" "github.com/decred/dcrd/txscript/v4/sign" diff --git a/internal/mempool/policy.go b/internal/mempool/policy.go index 5e58e627f3..3caa358337 100644 --- a/internal/mempool/policy.go +++ b/internal/mempool/policy.go @@ -10,8 +10,8 @@ import ( "time" "github.com/decred/dcrd/blockchain/stake/v5" - "github.com/decred/dcrd/blockchain/v5" "github.com/decred/dcrd/dcrutil/v4" + "github.com/decred/dcrd/internal/blockchain" "github.com/decred/dcrd/txscript/v4" "github.com/decred/dcrd/txscript/v4/stdscript" "github.com/decred/dcrd/wire" diff --git a/internal/mining/bgblktmplgenerator.go b/internal/mining/bgblktmplgenerator.go index d2f12c500c..474cef5fb0 100644 --- a/internal/mining/bgblktmplgenerator.go +++ b/internal/mining/bgblktmplgenerator.go @@ -13,9 +13,9 @@ import ( "time" "github.com/decred/dcrd/blockchain/stake/v5" - "github.com/decred/dcrd/blockchain/v5" "github.com/decred/dcrd/chaincfg/chainhash" "github.com/decred/dcrd/dcrutil/v4" + "github.com/decred/dcrd/internal/blockchain" "github.com/decred/dcrd/lru" "github.com/decred/dcrd/txscript/v4/stdaddr" "github.com/decred/dcrd/wire" diff --git a/internal/mining/cpuminer/cpuminer.go b/internal/mining/cpuminer/cpuminer.go index 4342c8c118..d5f041787a 100644 --- a/internal/mining/cpuminer/cpuminer.go +++ b/internal/mining/cpuminer/cpuminer.go @@ -15,10 +15,10 @@ import ( "time" "github.com/decred/dcrd/blockchain/standalone/v2" - "github.com/decred/dcrd/blockchain/v5" "github.com/decred/dcrd/chaincfg/chainhash" "github.com/decred/dcrd/chaincfg/v3" "github.com/decred/dcrd/dcrutil/v4" + "github.com/decred/dcrd/internal/blockchain" "github.com/decred/dcrd/internal/mining" "github.com/decred/dcrd/wire" ) diff --git a/internal/mining/mining.go b/internal/mining/mining.go index 423d4af6a4..8f881a2555 100644 --- a/internal/mining/mining.go +++ b/internal/mining/mining.go @@ -15,11 +15,11 @@ import ( "github.com/decred/dcrd/blockchain/stake/v5" "github.com/decred/dcrd/blockchain/standalone/v2" - "github.com/decred/dcrd/blockchain/v5" "github.com/decred/dcrd/chaincfg/chainhash" "github.com/decred/dcrd/chaincfg/v3" "github.com/decred/dcrd/dcrutil/v4" "github.com/decred/dcrd/gcs/v4/blockcf2" + "github.com/decred/dcrd/internal/blockchain" "github.com/decred/dcrd/txscript/v4" "github.com/decred/dcrd/txscript/v4/stdaddr" "github.com/decred/dcrd/txscript/v4/stdscript" diff --git a/internal/mining/mining_harness_test.go b/internal/mining/mining_harness_test.go index 37db4ae36b..351f31ef57 100644 --- a/internal/mining/mining_harness_test.go +++ b/internal/mining/mining_harness_test.go @@ -13,12 +13,12 @@ import ( "github.com/decred/dcrd/blockchain/stake/v5" "github.com/decred/dcrd/blockchain/standalone/v2" - "github.com/decred/dcrd/blockchain/v5" "github.com/decred/dcrd/chaincfg/chainhash" "github.com/decred/dcrd/chaincfg/v3" "github.com/decred/dcrd/dcrec" "github.com/decred/dcrd/dcrec/secp256k1/v4" "github.com/decred/dcrd/dcrutil/v4" + "github.com/decred/dcrd/internal/blockchain" "github.com/decred/dcrd/txscript/v4" "github.com/decred/dcrd/txscript/v4/sign" "github.com/decred/dcrd/txscript/v4/stdaddr" diff --git a/internal/mining/mining_test.go b/internal/mining/mining_test.go index 416dc9634d..acf96605a2 100644 --- a/internal/mining/mining_test.go +++ b/internal/mining/mining_test.go @@ -10,10 +10,10 @@ import ( "reflect" "testing" - "github.com/decred/dcrd/blockchain/v5" "github.com/decred/dcrd/chaincfg/chainhash" "github.com/decred/dcrd/chaincfg/v3" "github.com/decred/dcrd/dcrutil/v4" + "github.com/decred/dcrd/internal/blockchain" "github.com/decred/dcrd/txscript/v4" "github.com/decred/dcrd/txscript/v4/stdaddr" "github.com/decred/dcrd/wire" diff --git a/internal/netsync/manager.go b/internal/netsync/manager.go index 6a019e67eb..aae2fd256d 100644 --- a/internal/netsync/manager.go +++ b/internal/netsync/manager.go @@ -15,12 +15,12 @@ import ( "time" "github.com/decred/dcrd/blockchain/stake/v5" - "github.com/decred/dcrd/blockchain/v5" "github.com/decred/dcrd/chaincfg/chainhash" "github.com/decred/dcrd/chaincfg/v3" "github.com/decred/dcrd/container/apbf" "github.com/decred/dcrd/database/v3" "github.com/decred/dcrd/dcrutil/v4" + "github.com/decred/dcrd/internal/blockchain" "github.com/decred/dcrd/internal/mempool" "github.com/decred/dcrd/internal/progresslog" peerpkg "github.com/decred/dcrd/peer/v3" diff --git a/internal/rpcserver/interface.go b/internal/rpcserver/interface.go index 9edac5e7c2..5ad40189b6 100644 --- a/internal/rpcserver/interface.go +++ b/internal/rpcserver/interface.go @@ -12,11 +12,11 @@ import ( "github.com/decred/dcrd/addrmgr/v2" "github.com/decred/dcrd/blockchain/stake/v5" - "github.com/decred/dcrd/blockchain/v5" - "github.com/decred/dcrd/blockchain/v5/indexers" "github.com/decred/dcrd/chaincfg/chainhash" "github.com/decred/dcrd/dcrutil/v4" "github.com/decred/dcrd/gcs/v4" + "github.com/decred/dcrd/internal/blockchain" + "github.com/decred/dcrd/internal/blockchain/indexers" "github.com/decred/dcrd/internal/mempool" "github.com/decred/dcrd/internal/mining" "github.com/decred/dcrd/peer/v3" diff --git a/internal/rpcserver/rpcserver.go b/internal/rpcserver/rpcserver.go index 0a53c2c44f..ee47fcd496 100644 --- a/internal/rpcserver/rpcserver.go +++ b/internal/rpcserver/rpcserver.go @@ -40,13 +40,13 @@ import ( "github.com/decred/dcrd/blockchain/stake/v5" "github.com/decred/dcrd/blockchain/standalone/v2" - "github.com/decred/dcrd/blockchain/v5" "github.com/decred/dcrd/chaincfg/chainhash" "github.com/decred/dcrd/chaincfg/v3" "github.com/decred/dcrd/database/v3" "github.com/decred/dcrd/dcrec/secp256k1/v4/ecdsa" "github.com/decred/dcrd/dcrjson/v4" "github.com/decred/dcrd/dcrutil/v4" + "github.com/decred/dcrd/internal/blockchain" "github.com/decred/dcrd/internal/mempool" "github.com/decred/dcrd/internal/mining" "github.com/decred/dcrd/internal/version" diff --git a/internal/rpcserver/rpcserverhandlers_test.go b/internal/rpcserver/rpcserverhandlers_test.go index 5e823642ce..16db729407 100644 --- a/internal/rpcserver/rpcserverhandlers_test.go +++ b/internal/rpcserver/rpcserverhandlers_test.go @@ -28,8 +28,6 @@ import ( "github.com/decred/dcrd/addrmgr/v2" "github.com/decred/dcrd/blockchain/stake/v5" "github.com/decred/dcrd/blockchain/standalone/v2" - "github.com/decred/dcrd/blockchain/v5" - "github.com/decred/dcrd/blockchain/v5/indexers" "github.com/decred/dcrd/chaincfg/chainhash" "github.com/decred/dcrd/chaincfg/v3" "github.com/decred/dcrd/database/v3" @@ -37,6 +35,8 @@ import ( "github.com/decred/dcrd/dcrutil/v4" "github.com/decred/dcrd/gcs/v4" "github.com/decred/dcrd/gcs/v4/blockcf2" + "github.com/decred/dcrd/internal/blockchain" + "github.com/decred/dcrd/internal/blockchain/indexers" "github.com/decred/dcrd/internal/mempool" "github.com/decred/dcrd/internal/mining" "github.com/decred/dcrd/internal/version" diff --git a/internal/rpcserver/rpcwebsocket.go b/internal/rpcserver/rpcwebsocket.go index 072bbf428e..350eec8ff5 100644 --- a/internal/rpcserver/rpcwebsocket.go +++ b/internal/rpcserver/rpcwebsocket.go @@ -21,12 +21,12 @@ import ( "github.com/decred/dcrd/blockchain/stake/v5" "github.com/decred/dcrd/blockchain/standalone/v2" - "github.com/decred/dcrd/blockchain/v5" "github.com/decred/dcrd/chaincfg/chainhash" "github.com/decred/dcrd/chaincfg/v3" "github.com/decred/dcrd/crypto/ripemd160" "github.com/decred/dcrd/dcrjson/v4" "github.com/decred/dcrd/dcrutil/v4" + "github.com/decred/dcrd/internal/blockchain" "github.com/decred/dcrd/internal/mining" "github.com/decred/dcrd/rpc/jsonrpc/types/v4" "github.com/decred/dcrd/txscript/v4/stdaddr" diff --git a/log.go b/log.go index 1acbb23389..4149604d30 100644 --- a/log.go +++ b/log.go @@ -12,10 +12,10 @@ import ( "github.com/decred/dcrd/addrmgr/v2" "github.com/decred/dcrd/blockchain/stake/v5" - "github.com/decred/dcrd/blockchain/v5" - "github.com/decred/dcrd/blockchain/v5/indexers" "github.com/decred/dcrd/connmgr/v3" "github.com/decred/dcrd/database/v3" + "github.com/decred/dcrd/internal/blockchain" + "github.com/decred/dcrd/internal/blockchain/indexers" "github.com/decred/dcrd/internal/fees" "github.com/decred/dcrd/internal/mempool" "github.com/decred/dcrd/internal/mining" diff --git a/rpcadaptors.go b/rpcadaptors.go index dab96545fc..875f941ee2 100644 --- a/rpcadaptors.go +++ b/rpcadaptors.go @@ -11,10 +11,10 @@ import ( "net" "time" - "github.com/decred/dcrd/blockchain/v5" "github.com/decred/dcrd/chaincfg/chainhash" "github.com/decred/dcrd/chaincfg/v3" "github.com/decred/dcrd/dcrutil/v4" + "github.com/decred/dcrd/internal/blockchain" "github.com/decred/dcrd/internal/mempool" "github.com/decred/dcrd/internal/mining" "github.com/decred/dcrd/internal/mining/cpuminer" diff --git a/rpcclient/go.sum b/rpcclient/go.sum index e3013e2f36..e9144d78c3 100644 --- a/rpcclient/go.sum +++ b/rpcclient/go.sum @@ -6,8 +6,6 @@ github.com/dchest/siphash v1.2.2 h1:9DFz8tQwl9pTVt5iok/9zKyzA1Q6bRGiF3HPiEEVr9I= github.com/dchest/siphash v1.2.2/go.mod h1:q+IRvb2gOSrUnYoPqHiyHXS0FOBBOdl6tONBlVnOnt4= github.com/decred/base58 v1.0.3 h1:KGZuh8d1WEMIrK0leQRM47W85KqCAdl2N+uagbctdDI= github.com/decred/base58 v1.0.3/go.mod h1:pXP9cXCfM2sFLb2viz2FNIdeMWmZDBKG3ZBYbiSM78E= -github.com/decred/dcrd/blockchain/stake/v5 v5.0.0 h1:PwoCjCTbRvDUZKKs6N2Haus8XcbVXCJ9iGVs8C9sKwQ= -github.com/decred/dcrd/blockchain/stake/v5 v5.0.0/go.mod h1:bOgG7YTbTOWQgtHLL2l1Y9gBHIuM86zwVcQtsoGlZlQ= github.com/decred/dcrd/chaincfg/chainhash v1.0.2/go.mod h1:BpbrGgrPTr3YJYRN3Bm+D9NuaFd+zGyNeIKgrhCXK60= github.com/decred/dcrd/chaincfg/chainhash v1.0.3 h1:PF2czcYZGW3dz4i/35AUfVAgnqHl9TMNQt1ADTYGOoE= github.com/decred/dcrd/chaincfg/chainhash v1.0.3/go.mod h1:BpbrGgrPTr3YJYRN3Bm+D9NuaFd+zGyNeIKgrhCXK60= @@ -29,10 +27,6 @@ github.com/decred/dcrd/dcrjson/v4 v4.0.0 h1:KsaFhHAYO+vLYz7Qmx/fs1gOY5ouTEz8hRuD github.com/decred/dcrd/dcrjson/v4 v4.0.0/go.mod h1:DMnSpU8lsVh+Nt5kHl63tkrjBDA7UIs4+ov8Kwwgvjs= github.com/decred/dcrd/dcrutil/v4 v4.0.0 h1:AY00fWy/ETrMHN0DNV3XUbH1aip2RG1AoTy5dp0+sJE= github.com/decred/dcrd/dcrutil/v4 v4.0.0/go.mod h1:QQpX5WVH3/ixVtiW15xZMe+neugXX3l2bsrYgq6nz4M= -github.com/decred/dcrd/gcs/v4 v4.0.0 h1:MjWevhoAzKENUgpaJAbZkJlKDN4HIz2nR/i3laZAT5c= -github.com/decred/dcrd/gcs/v4 v4.0.0/go.mod h1:/OVb/rYrAz4TCtxcPneYfBs0+YI1pGIp8RA6RUNqOp4= -github.com/decred/dcrd/rpc/jsonrpc/types/v3 v3.0.0 h1:WzG2IARR6OghjhWdxfUbXSPE4GEF2hZlCE5y2L/45f4= -github.com/decred/dcrd/rpc/jsonrpc/types/v3 v3.0.0/go.mod h1:1ILDxMKVS/qY71MylpZzuEX4O0u1SON4RPKbaZP71K0= github.com/decred/dcrd/txscript/v4 v4.0.0 h1:BwaBUCMCmg58MCYoBhxVjL8ZZKUIfoJuxu/djmh8h58= github.com/decred/dcrd/txscript/v4 v4.0.0/go.mod h1:OJtxNc5RqwQyfrRnG2gG8uMeNPo8IAJp+TD1UKXkqk8= github.com/decred/dcrd/wire v1.5.0 h1:3SgcEzSjqAMQvOugP0a8iX7yQSpiVT1yNi9bc4iOXVg= diff --git a/server.go b/server.go index 4202ce97d9..d7c0e5d807 100644 --- a/server.go +++ b/server.go @@ -28,8 +28,6 @@ import ( "github.com/decred/dcrd/addrmgr/v2" "github.com/decred/dcrd/blockchain/stake/v5" "github.com/decred/dcrd/blockchain/standalone/v2" - "github.com/decred/dcrd/blockchain/v5" - "github.com/decred/dcrd/blockchain/v5/indexers" "github.com/decred/dcrd/certgen" "github.com/decred/dcrd/chaincfg/chainhash" "github.com/decred/dcrd/chaincfg/v3" @@ -37,6 +35,8 @@ import ( "github.com/decred/dcrd/container/apbf" "github.com/decred/dcrd/database/v3" "github.com/decred/dcrd/dcrutil/v4" + "github.com/decred/dcrd/internal/blockchain" + "github.com/decred/dcrd/internal/blockchain/indexers" "github.com/decred/dcrd/internal/fees" "github.com/decred/dcrd/internal/mempool" "github.com/decred/dcrd/internal/mining"