Repository: btcsuite/btcd Branch: master Commit: 1c55c7c18179 Files: 3410 Total size: 14.2 MB Directory structure: gitextract_cxjd7vht/ ├── .gemini/ │ ├── config.yaml │ └── styleguide.md ├── .github/ │ ├── ISSUE_TEMPLATE/ │ │ ├── bug_report.md │ │ ├── config.yml │ │ └── feature_request.md │ ├── pull_request_template.md │ └── workflows/ │ ├── Dockerfile │ ├── dimagespub.yml │ └── main.yml ├── .gitignore ├── .golangci.yml ├── CHANGES ├── Dockerfile ├── LICENSE ├── Makefile ├── README.md ├── SECURITY.md ├── addrmgr/ │ ├── addrmanager.go │ ├── addrmanager_internal_test.go │ ├── addrmanager_test.go │ ├── cov_report.sh │ ├── doc.go │ ├── internal_test.go │ ├── knownaddress.go │ ├── knownaddress_test.go │ ├── log.go │ ├── network.go │ ├── network_test.go │ └── test_coverage.txt ├── blockchain/ │ ├── README.md │ ├── accept.go │ ├── bench_test.go │ ├── blockindex.go │ ├── blockindex_test.go │ ├── chain.go │ ├── chain_test.go │ ├── chainio.go │ ├── chainio_test.go │ ├── chainview.go │ ├── chainview_test.go │ ├── checkpoints.go │ ├── common_test.go │ ├── compress.go │ ├── compress_test.go │ ├── difficulty.go │ ├── doc.go │ ├── error.go │ ├── error_test.go │ ├── example_test.go │ ├── fullblocks_test.go │ ├── fullblocktests/ │ │ ├── README.md │ │ ├── doc.go │ │ ├── generate.go │ │ └── params.go │ ├── indexers/ │ │ ├── README.md │ │ ├── addrindex.go │ │ ├── addrindex_test.go │ │ ├── blocklogger.go │ │ ├── cfindex.go │ │ ├── common.go │ │ ├── log.go │ │ ├── manager.go │ │ └── txindex.go │ ├── interfaces.go │ ├── internal/ │ │ ├── testhelper/ │ │ │ ├── README.md │ │ │ └── common.go │ │ └── workmath/ │ │ ├── README.md │ │ ├── difficulty.go │ │ └── difficulty_test.go │ ├── log.go │ ├── mediantime.go │ ├── mediantime_test.go │ ├── merkle.go │ ├── merkle_test.go │ ├── notifications.go │ ├── notifications_test.go │ ├── process.go │ ├── rolling_merkle.go │ ├── rolling_merkle_test.go │ ├── scriptval.go │ ├── scriptval_test.go │ ├── sizehelper.go │ ├── sizehelper_test.go │ ├── testdata/ │ │ ├── 277647.dat.bz2 │ │ ├── 277647.utxostore.bz2 │ │ ├── blk_0_to_4.dat.bz2 │ │ ├── blk_3A.dat.bz2 │ │ ├── blk_4A.dat.bz2 │ │ ├── blk_5A.dat.bz2 │ │ └── reorgtest.hex │ ├── thresholdstate.go │ ├── thresholdstate_test.go │ ├── timesorter.go │ ├── timesorter_test.go │ ├── upgrade.go │ ├── upgrade_test.go │ ├── utxocache.go │ ├── utxocache_test.go │ ├── utxoviewpoint.go │ ├── validate.go │ ├── validate_rapid_test.go │ ├── validate_test.go │ ├── versionbits.go │ └── weight.go ├── btcd.go ├── btcec/ │ ├── README.md │ ├── bench_test.go │ ├── btcec.go │ ├── btcec_test.go │ ├── ciphering.go │ ├── ciphering_test.go │ ├── curve.go │ ├── doc.go │ ├── ecdsa/ │ │ ├── bench_test.go │ │ ├── error.go │ │ ├── example_test.go │ │ ├── signature.go │ │ └── signature_test.go │ ├── ellswift/ │ │ ├── ellswift.go │ │ └── ellswift_test.go │ ├── error.go │ ├── field.go │ ├── field_test.go │ ├── fuzz_test.go │ ├── go.mod │ ├── go.sum │ ├── modnscalar.go │ ├── privkey.go │ ├── pubkey.go │ ├── pubkey_test.go │ └── schnorr/ │ ├── bench_test.go │ ├── error.go │ ├── musig2/ │ │ ├── bench_test.go │ │ ├── context.go │ │ ├── data/ │ │ │ ├── key_agg_vectors.json │ │ │ ├── key_sort_vectors.json │ │ │ ├── nonce_agg_vectors.json │ │ │ ├── nonce_gen_vectors.json │ │ │ ├── sig_agg_vectors.json │ │ │ ├── sign_verify_vectors.json │ │ │ └── tweak_vectors.json │ │ ├── keys.go │ │ ├── keys_test.go │ │ ├── musig2_test.go │ │ ├── nonces.go │ │ ├── nonces_test.go │ │ ├── sign.go │ │ └── sign_test.go │ ├── pubkey.go │ ├── signature.go │ └── signature_test.go ├── btcjson/ │ ├── CONTRIBUTORS │ ├── README.md │ ├── btcdextcmds.go │ ├── btcdextcmds_test.go │ ├── btcdextresults.go │ ├── btcdextresults_test.go │ ├── btcwalletextcmds.go │ ├── btcwalletextcmds_test.go │ ├── chainsvrcmds.go │ ├── chainsvrcmds_test.go │ ├── chainsvrresults.go │ ├── chainsvrresults_test.go │ ├── chainsvrwscmds.go │ ├── chainsvrwscmds_test.go │ ├── chainsvrwsntfns.go │ ├── chainsvrwsntfns_test.go │ ├── chainsvrwsresults.go │ ├── chainsvrwsresults_test.go │ ├── cmdinfo.go │ ├── cmdinfo_test.go │ ├── cmdparse.go │ ├── cmdparse_test.go │ ├── doc.go │ ├── error.go │ ├── error_test.go │ ├── example_test.go │ ├── export_test.go │ ├── help.go │ ├── help_test.go │ ├── helpers.go │ ├── helpers_test.go │ ├── jsonrpc.go │ ├── jsonrpc_test.go │ ├── jsonrpcerr.go │ ├── register.go │ ├── register_test.go │ ├── submitpackage.go │ ├── submitpackage_test.go │ ├── walletsvrcmds.go │ ├── walletsvrcmds_test.go │ ├── walletsvrresults.go │ ├── walletsvrresults_test.go │ ├── walletsvrwscmds.go │ ├── walletsvrwscmds_test.go │ ├── walletsvrwsntfns.go │ ├── walletsvrwsntfns_test.go │ ├── zmqsvrcmds.go │ └── zmqsvrresults.go ├── btcutil/ │ ├── LICENSE │ ├── README.md │ ├── address.go │ ├── address_test.go │ ├── amount.go │ ├── amount_test.go │ ├── appdata.go │ ├── appdata_test.go │ ├── base58/ │ │ ├── README.md │ │ ├── alphabet.go │ │ ├── base58.go │ │ ├── base58_test.go │ │ ├── base58bench_test.go │ │ ├── base58check.go │ │ ├── base58check_test.go │ │ ├── cov_report.sh │ │ ├── doc.go │ │ ├── example_test.go │ │ └── genalphabet.go │ ├── bech32/ │ │ ├── README.md │ │ ├── bech32.go │ │ ├── bech32_test.go │ │ ├── doc.go │ │ ├── error.go │ │ ├── example_test.go │ │ └── version.go │ ├── bench_test.go │ ├── block.go │ ├── block_test.go │ ├── bloom/ │ │ ├── README.md │ │ ├── cov_report.sh │ │ ├── example_test.go │ │ ├── filter.go │ │ ├── filter_test.go │ │ ├── merkleblock.go │ │ ├── merkleblock_test.go │ │ ├── murmurhash3.go │ │ ├── murmurhash3_test.go │ │ └── test_coverage.txt │ ├── certgen.go │ ├── certgen_test.go │ ├── coinset/ │ │ ├── README.md │ │ ├── coins.go │ │ ├── coins_test.go │ │ ├── cov_report.sh │ │ └── test_coverage.txt │ ├── const.go │ ├── cov_report.sh │ ├── doc.go │ ├── example_test.go │ ├── gcs/ │ │ ├── README.md │ │ ├── builder/ │ │ │ ├── builder.go │ │ │ └── builder_test.go │ │ ├── doc.go │ │ ├── gcs.go │ │ ├── gcs_test.go │ │ └── gcsbench_test.go │ ├── go.mod │ ├── go.sum │ ├── hash160.go │ ├── hdkeychain/ │ │ ├── README.md │ │ ├── bench_test.go │ │ ├── cov_report.sh │ │ ├── doc.go │ │ ├── example_test.go │ │ ├── extendedkey.go │ │ ├── extendedkey_test.go │ │ └── test_coverage.txt │ ├── internal_test.go │ ├── net.go │ ├── net_noop.go │ ├── psbt/ │ │ ├── bip32.go │ │ ├── bip32_test.go │ │ ├── creator.go │ │ ├── extractor.go │ │ ├── finalizer.go │ │ ├── go.mod │ │ ├── go.sum │ │ ├── partial_input.go │ │ ├── partial_output.go │ │ ├── partialsig.go │ │ ├── psbt.go │ │ ├── psbt_test.go │ │ ├── signer.go │ │ ├── sort.go │ │ ├── sort_test.go │ │ ├── taproot.go │ │ ├── types.go │ │ ├── updater.go │ │ ├── utils.go │ │ └── utils_test.go │ ├── tx.go │ ├── tx_test.go │ ├── txsort/ │ │ ├── README.md │ │ ├── doc.go │ │ ├── testdata/ │ │ │ ├── bip69-1.hex │ │ │ ├── bip69-2.hex │ │ │ ├── bip69-3.hex │ │ │ ├── bip69-4.hex │ │ │ └── bip69-5.hex │ │ ├── txsort.go │ │ └── txsort_test.go │ ├── wif.go │ └── wif_test.go ├── chaincfg/ │ ├── README.md │ ├── chainhash/ │ │ ├── README.md │ │ ├── doc.go │ │ ├── go.mod │ │ ├── hash.go │ │ ├── hash_test.go │ │ ├── hashfuncs.go │ │ └── hashfuncs_test.go │ ├── deployment_time_frame.go │ ├── doc.go │ ├── genesis.go │ ├── genesis_test.go │ ├── params.go │ ├── params_test.go │ └── register_test.go ├── cmd/ │ ├── addblock/ │ │ ├── addblock.go │ │ ├── config.go │ │ └── import.go │ ├── btcctl/ │ │ ├── btcctl.go │ │ ├── config.go │ │ ├── httpclient.go │ │ └── version.go │ ├── findcheckpoint/ │ │ ├── config.go │ │ └── findcheckpoint.go │ └── gencerts/ │ └── gencerts.go ├── config.go ├── config_test.go ├── connmgr/ │ ├── README.md │ ├── connmanager.go │ ├── connmanager_test.go │ ├── doc.go │ ├── dynamicbanscore.go │ ├── dynamicbanscore_test.go │ ├── log.go │ ├── seed.go │ └── tor.go ├── database/ │ ├── README.md │ ├── cmd/ │ │ └── dbtool/ │ │ ├── fetchblock.go │ │ ├── fetchblockregion.go │ │ ├── globalconfig.go │ │ ├── insecureimport.go │ │ ├── loadheaders.go │ │ ├── main.go │ │ └── signal.go │ ├── doc.go │ ├── driver.go │ ├── driver_test.go │ ├── error.go │ ├── error_test.go │ ├── example_test.go │ ├── export_test.go │ ├── ffldb/ │ │ ├── README.md │ │ ├── bench_test.go │ │ ├── blockio.go │ │ ├── db.go │ │ ├── dbcache.go │ │ ├── doc.go │ │ ├── driver.go │ │ ├── driver_test.go │ │ ├── export.go │ │ ├── interface_test.go │ │ ├── ldbtreapiter.go │ │ ├── mockfile_test.go │ │ ├── reconcile.go │ │ └── whitebox_test.go │ ├── interface.go │ ├── internal/ │ │ └── treap/ │ │ ├── README.md │ │ ├── common.go │ │ ├── common_test.go │ │ ├── doc.go │ │ ├── immutable.go │ │ ├── immutable_test.go │ │ ├── mutable.go │ │ ├── mutable_test.go │ │ ├── treapiter.go │ │ └── treapiter_test.go │ ├── log.go │ └── testdata/ │ └── blocks1-256.bz2 ├── doc.go ├── docs/ │ ├── .gitignore │ ├── Makefile │ ├── code_contribution_guidelines.md │ ├── code_formatting_rules.md │ ├── conf.py │ ├── configuration.md │ ├── configuring_tor.md │ ├── contact.md │ ├── controlling.md │ ├── developer_resources.md │ ├── index.md │ ├── installation.md │ ├── json_rpc_api.md │ ├── make.bat │ ├── mining.md │ ├── requirements.txt │ ├── table_of_content.md │ ├── update.md │ ├── using_docker.md │ └── wallet.md ├── go.mod ├── go.sum ├── integration/ │ ├── README.md │ ├── bip0009_test.go │ ├── chain_test.go │ ├── csv_fork_test.go │ ├── getchaintips_test.go │ ├── invalidate_reconsider_block_test.go │ ├── log.go │ ├── main.go │ ├── prune_test.go │ ├── rawtx_test.go │ ├── rpcserver_test.go │ └── rpctest/ │ ├── README.md │ ├── blockgen.go │ ├── btcd.go │ ├── doc.go │ ├── memwallet.go │ ├── node.go │ ├── rpc_harness.go │ ├── rpc_harness_test.go │ └── utils.go ├── limits/ │ ├── limits_plan9.go │ ├── limits_unix.go │ └── limits_windows.go ├── log.go ├── mempool/ │ ├── README.md │ ├── doc.go │ ├── error.go │ ├── estimatefee.go │ ├── estimatefee_test.go │ ├── interface.go │ ├── log.go │ ├── mempool.go │ ├── mempool_test.go │ ├── mocks.go │ ├── policy.go │ └── policy_test.go ├── mining/ │ ├── README.md │ ├── cpuminer/ │ │ ├── README.md │ │ ├── cpuminer.go │ │ └── log.go │ ├── log.go │ ├── mining.go │ ├── mining_test.go │ ├── policy.go │ └── policy_test.go ├── netsync/ │ ├── README.md │ ├── blocklogger.go │ ├── doc.go │ ├── interface.go │ ├── log.go │ └── manager.go ├── ossec/ │ ├── ossec.go │ └── ossec_openbsd.go ├── params.go ├── peer/ │ ├── README.md │ ├── doc.go │ ├── example_test.go │ ├── log.go │ ├── p2pdowngrader.go │ ├── p2pdowngrader_test.go │ ├── peer.go │ ├── peer_test.go │ └── recover_test.go ├── release/ │ ├── README.md │ └── release.sh ├── rpcadapters.go ├── rpcclient/ │ ├── CONTRIBUTORS │ ├── README.md │ ├── backend_version.go │ ├── backend_version_test.go │ ├── chain.go │ ├── chain_test.go │ ├── cookiefile.go │ ├── doc.go │ ├── errors.go │ ├── errors_test.go │ ├── example_test.go │ ├── examples/ │ │ ├── bitcoincorehttp/ │ │ │ ├── README.md │ │ │ └── main.go │ │ ├── bitcoincorehttpbulk/ │ │ │ ├── README.md │ │ │ └── main.go │ │ ├── bitcoincoreunixsocket/ │ │ │ ├── README.md │ │ │ └── main.go │ │ ├── btcdwebsockets/ │ │ │ ├── README.md │ │ │ └── main.go │ │ ├── btcwalletwebsockets/ │ │ │ ├── README.md │ │ │ └── main.go │ │ └── customcommand/ │ │ ├── README.md │ │ └── main.go │ ├── extensions.go │ ├── infrastructure.go │ ├── infrastructure_test.go │ ├── log.go │ ├── mining.go │ ├── net.go │ ├── notify.go │ ├── rawrequest.go │ ├── rawtransactions.go │ ├── wallet.go │ └── zmq.go ├── rpcserver.go ├── rpcserver_test.go ├── rpcserverhelp.go ├── rpcserverhelp_test.go ├── rpcwebsocket.go ├── sample-btcd.conf ├── scripts/ │ └── tidy_modules.sh ├── server.go ├── service_windows.go ├── signal.go ├── signalsigterm.go ├── txscript/ │ ├── README.md │ ├── bench_test.go │ ├── consensus.go │ ├── data/ │ │ ├── LICENSE │ │ ├── many_inputs_tx.hex │ │ ├── script_tests.json │ │ ├── sighash.json │ │ ├── taproot-ref/ │ │ │ ├── 003af31dd0b5a50c2723531e8ca22ae8ca6e7089 │ │ │ ├── 005e61a50014d33f7309097490534db3c0dc65fe │ │ │ ├── 007f313a1a53428b7fc9eaf54c5d51be20e10567 │ │ │ ├── 00850c1cc564bd0dcbb02c3398f9fc8e0219a317 │ │ │ ├── 0089a0f18b0647cf2bfae0c93e9ae39b345d1611 │ │ │ ├── 00b6fe5a14ee4fb3bb65e0aa28e70cb57f0cd0b0 │ │ │ ├── 00cd1f1ac746e81ae27bfe1e9a383975d0bba949 │ │ │ ├── 00d07d91c86c11dbbd14f4edf55c1f496ffaf010 │ │ │ ├── 00dc037c98e799a31facfab68fce3187ad7a0f68 │ │ │ ├── 00e2723c3cce5d6fa2b7db987e5fbc1d75297650 │ │ │ ├── 00eb1a2b8aed4a406ee59371fa0a50e6679857c1 │ │ │ ├── 0108a92da87f766ee005ac0bb220f78b50d04101 │ │ │ ├── 010cc78772e75503cf488b6267f5891e1495c962 │ │ │ ├── 014aca010656e76077fe517e999ea589e88307d7 │ │ │ ├── 01686c55b9d9f3d0c2d9dc8c0911de32df21a864 │ │ │ ├── 016e25aa492396c1f2937c07dac87f3bce812041 │ │ │ ├── 017f425514c38506670a6136985cf2f693c1851b │ │ │ ├── 0181b63b032265ff6a54d3acaf33d2efc67028ca │ │ │ ├── 018284c1e780a7aacea0d945603d5f06254c5cfe │ │ │ ├── 01ca217ccf1ea0e39003e90d0d3573454b370bd0 │ │ │ ├── 01cc26fa177761f2440d4f78790adfdcb27c9321 │ │ │ ├── 0224ee3efd6d6c2e6024db65267c008a3786f0b2 │ │ │ ├── 0234f23ded5600eb13895b83e3d3208daa621654 │ │ │ ├── 026745c2e6a71ca361cb3f37fe3f4e9c3029688e │ │ │ ├── 026f12b427239f4351f951644afdf9e483ddc4bd │ │ │ ├── 0274119160b74eb12e8b0ea869012528e5c8c64a │ │ │ ├── 02a2d45e622dec5a4342e4be185659da883e8d6d │ │ │ ├── 02bb3113c2f000ec71e0cac539468d820cfa2df6 │ │ │ ├── 02c77525ae2279633746cc24153272f0cbebb2cf │ │ │ ├── 02d1c1fa4446780154693993cbb3b3357d7dc38f │ │ │ ├── 02f4d455a5e5230510c642f46a00e2819cbd49fa │ │ │ ├── 02fcf2313f765802ff09c238af833842580fe461 │ │ │ ├── 0313e7c2127076391d6fd9696d30081eb2c9bfb5 │ │ │ ├── 0325cc06523d6b80529e7b67ea669a8cacc195a1 │ │ │ ├── 032b54a2e80454a2b7039f32a4974095c2f018b0 │ │ │ ├── 035336c778f096bfe56ccd9c44ca36a275649299 │ │ │ ├── 038d58e7a5bd8cd3c42dbd68c099f5900b90ceef │ │ │ ├── 03ac2fb4ae30f213cec9edbaf2796b086134d050 │ │ │ ├── 03b65143f1009a2a8a2f6b758fd8559f040d207c │ │ │ ├── 03bc1ab1714e0ffffffd3593268beb217c603b54 │ │ │ ├── 03bf93a96878a9f8ab6cdeabb7da6656971299e2 │ │ │ ├── 03ec899fb91c58bbb5676ebce177b0b63fa704a1 │ │ │ ├── 03edb43f652ba7e0ad56e117bab26ed1b3cc0b66 │ │ │ ├── 0401cdbd85422acd1857a2cf6024ba4b7b5d909e │ │ │ ├── 040d05cbd66190be71c513b0ebd00bbc34debe8b │ │ │ ├── 04369027c0cf8f61083f8faeaf5d15a4bba2cb26 │ │ │ ├── 043ee2fa352668d08af2912ea4c7dc868039dd7c │ │ │ ├── 046dee126274f9efbec0b1803cf0483b40e0bc0a │ │ │ ├── 047736248915b6ec7bb882618f4c6428dc10bc32 │ │ │ ├── 0496f56b7283138d77bd26aa97936a80588bc908 │ │ │ ├── 04a0415662e8fe755a1cad7e31e996b0f9553a15 │ │ │ ├── 04a9e5bdcdafa1f723281d72593020692f3b5004 │ │ │ ├── 04bb5c8ad218b2ea6cbabde04b776a727cb804d3 │ │ │ ├── 04c14170bf3650e0dee112ba4b888f2e76fc3b69 │ │ │ ├── 04f498a7f3cfb530edcae02afc0d1476b8fbcd8a │ │ │ ├── 0526255fad6bcad83e0f38f3e175d8b55d0113d3 │ │ │ ├── 0530510aa69fa36a6377468b144a6daefe9e0779 │ │ │ ├── 05645a121a9dee2f1e618d22d9c0e11f1729c008 │ │ │ ├── 05723fdb3ecd4a3d4acc01d8ce541e74f11ba38f │ │ │ ├── 0576b0175f23da9546b0ed7d213c1bdf55941dcd │ │ │ ├── 05a7b91a73da2203e485ff51426532165c688040 │ │ │ ├── 05d3a449ff645092d95ff6fa07d433d341861837 │ │ │ ├── 05e7d1f74a0f0d69935dcee5b60fd0b08ff396cf │ │ │ ├── 05f2dfea38b07d623e2947cc2c7963f25a45e24e │ │ │ ├── 05ff688173b90131ed218e693cd3e0735c88955a │ │ │ ├── 060f27e89600b0edaefb344b00420aa71360fd11 │ │ │ ├── 0621f65ed4f98e0fc3ba2caa915de84ac2773b64 │ │ │ ├── 064cb40080f9955f34713af8c9ccd370c7ce8d39 │ │ │ ├── 064f3862567d3645a67ad42e8f1234919491ef00 │ │ │ ├── 06689eea577fd577cf0ed48baa3396126bb6f1b5 │ │ │ ├── 0672af82ea3c78b3ade4b7424ecf5c00466fba2e │ │ │ ├── 06882dd6d50dc8061c56b887fa16764a4db5cc51 │ │ │ ├── 06aa8b12e6ae5c391fb3d92c4050218d552b6923 │ │ │ ├── 06b7ea9f43da11b479b267aca3bdd7cf6fb9cfa7 │ │ │ ├── 06e74af8b10a6ab9ce11036f2747f8034ec3febf │ │ │ ├── 06f54531f7cc822f36462b303f5eed8313ca07f5 │ │ │ ├── 07249b6446b452a9005766194cb824b77c6ed600 │ │ │ ├── 0725dac7b6c36d404b706902e2a350065ba66fbd │ │ │ ├── 073b21ccb622912fef49f0555d5ed7b6ea85ad7e │ │ │ ├── 07904e76401a888153be57bdc173982a4396aea3 │ │ │ ├── 079662a69dfd16ca9215a4e0c822fc44641e72ed │ │ │ ├── 07991f2bbd7bbe3fad499b0c428f795590321613 │ │ │ ├── 07a56716b603afd041d05639404b37744bc2b83c │ │ │ ├── 07aa3010d9cc23f67f6962a7c18f7dedccd7855b │ │ │ ├── 07ae5671fc31d245f515f5c967b4e7cfed38567b │ │ │ ├── 07b8ee857d10f18474e7471c3c27d10be12c5f25 │ │ │ ├── 07cbbc0e4129794730bb9bb49d334b497f11b422 │ │ │ ├── 07d68512aa206614c478ec869a8b7d4f7c32333b │ │ │ ├── 07ff10e93b7bf06e8da854a647ad08d5bc902326 │ │ │ ├── 08106eb8543994958b201f3ce5f42dbbf19adf37 │ │ │ ├── 081a75fb52ef536975050ff3192f6c516b3b557a │ │ │ ├── 08421b069ef3b27abeb764e8412aa879c8bfb0cd │ │ │ ├── 08630f23c6a755790aea6ed91128183d6ddc8291 │ │ │ ├── 086661b19fe6034d3748295413e2b4d4251157aa │ │ │ ├── 08a0635b26ef56d2f6ddd4c31295a8bbde840584 │ │ │ ├── 08a19ba6422f65b65cacb3f20b5507bca39fffc3 │ │ │ ├── 08b5c0ff184e15e9c21e4949e2382b9a71623d3c │ │ │ ├── 08b74fd5e5bdcfc0a22933abb14c20399138f612 │ │ │ ├── 08cb0cb08cfb93d7ca744dbf018072b119fbc650 │ │ │ ├── 08cefa50635850a5a6caa88ddae4d4e4c5178f8b │ │ │ ├── 0918ed067691e99a0ac65b680c99b8a0bd6d2dc2 │ │ │ ├── 0920b0864e2f856ec01587533e768fdc9f982a59 │ │ │ ├── 092dfb3e8b68e6142fcb0a354c4d02c23428b870 │ │ │ ├── 09342cfa6e3461e698ef1f6aceb83fd4a3ccbf35 │ │ │ ├── 0942d800ed811d505130b0e5cca50e722fc4f19b │ │ │ ├── 095bca4fc65d75681b759e14d34e7a5987625ab4 │ │ │ ├── 097dbe987c217c3d9b230bc0e634a9e3f0bab2fd │ │ │ ├── 09b3e7123f40c4ddb240073a912a440a18168c13 │ │ │ ├── 09c225b7d61512e189a466c46243a4511b6eae8d │ │ │ ├── 09cd349f59ff286840fb04789da01062c5d83ba2 │ │ │ ├── 09d7f478f35e48679ca5a97a08febfa49d510081 │ │ │ ├── 0a3e2dd5f11a2182d7b86b927a600bde565229a8 │ │ │ ├── 0a9a9a6e04b0e55c5a90ca23c2586a07ae1fc542 │ │ │ ├── 0aaeeea67c9e79315c703c56429535fd670ef5aa │ │ │ ├── 0abded429f191b0375a464688f06bd465af7c644 │ │ │ ├── 0abdf3a09f88ee47573f9509a323dfd8af89e021 │ │ │ ├── 0ad139668541c092541da58168e6488a1191ff58 │ │ │ ├── 0b0a37b5c9ef3c034545cbefc3e8de97c8b5ea05 │ │ │ ├── 0b0f9ae5467a2c8d14e86527b264cacbf4871500 │ │ │ ├── 0b37dc29cfcef1377a94a17297a0525504b5a9d2 │ │ │ ├── 0b7236484ffa4dee58a006bc3b9e51c30e5cc903 │ │ │ ├── 0b727481698d5b6e33b991da896215f0527335a6 │ │ │ ├── 0b931370dfff16b9e6d9a7a333e61cabe23290eb │ │ │ ├── 0bc98deaaa9007629b3338d906d73f87abce0b62 │ │ │ ├── 0bf313616424ee4fc95cf71286563567fc87c472 │ │ │ ├── 0bfc8b69a3702ac6986ce61b00e837a148e7d0eb │ │ │ ├── 0c00a8351b02f2185ea30aa4052174b38417e0ff │ │ │ ├── 0c02f78d8dd01b33e94abaa865ee6a9792f4ccfa │ │ │ ├── 0c043c49e6d5aafcf072e6be1be89160111fcb16 │ │ │ ├── 0c10be31ac329baf66d4d083563e6a9c3ab9ee59 │ │ │ ├── 0c12817899b35dadda1aee2d0a376b1e6fca73d8 │ │ │ ├── 0c2099a1366325dfb20d310e00b1c1554e93defd │ │ │ ├── 0c4d9a60206c9ad9b61b6120b3b5495408989e96 │ │ │ ├── 0c6dc14de0b80f72306e015b7560fef8a12f722c │ │ │ ├── 0c860ba9e47e23ac7ceaaa948e710e0253317ad1 │ │ │ ├── 0c90542e3f64cf4c09f66ad39471bbed839d46af │ │ │ ├── 0c91906e6830ed3ad8eba843f2cd7c66205a7981 │ │ │ ├── 0cbaaae8f169bef4c71cd090d475e96cc8277741 │ │ │ ├── 0cfce5f569e35c19633d12676981cda0b47a34b9 │ │ │ ├── 0d1dfc0136b588b721884040ebf5911514ebb74f │ │ │ ├── 0d25d4167a2171b28beda354bc7a6b814d718e10 │ │ │ ├── 0d265e43ba90ce1827ee538563c6a293b0b03ff8 │ │ │ ├── 0d3ce2afc206b93ee7c40177e168a295fc3e5ce0 │ │ │ ├── 0d4d3db873cac71185de9e2fa4462b2f3ba96462 │ │ │ ├── 0d5ecc8d0c063c2641c3a8e7adff9ecb0323914a │ │ │ ├── 0d65edb0c2f57a76df2b15cd2c722b18edffbacc │ │ │ ├── 0d687e26341ba489f3d7be5d0b46f4beacaf8358 │ │ │ ├── 0d6ac2e508ad66fe5e2ceb784535d11ee75cbe2f │ │ │ ├── 0d75732bc24cbac5dc017bb967142c5648d55bfd │ │ │ ├── 0d89c8dca6b7a1af5614348af7dd5ae2f65190bf │ │ │ ├── 0dd2ab05d7639afe71f965b79bd7092a935732e5 │ │ │ ├── 0debebb3108bcd03c6d5ce9c5c2ce1a64f8da172 │ │ │ ├── 0e03e6819458e3a55e6655f8ac2fb5cb9b28406b │ │ │ ├── 0e1d5cb6786009b8f3825aeb3f4c7eecc240bf0b │ │ │ ├── 0e1f79030f3681187ce4b16bf43133d56c470a63 │ │ │ ├── 0e229a80fe4e2619a4b272d19ce5815986d08fa2 │ │ │ ├── 0e27294bb1dafe333a689bcad39dff7fb6f9cddf │ │ │ ├── 0e28329dee72cdf3ca474e54b4eae5fb8c42ce45 │ │ │ ├── 0e292d3b3af29268349fe695e0f7ad74c422612d │ │ │ ├── 0e41c7f53cff3726f8dbca36445f5bb99cc7515f │ │ │ ├── 0e73fd872d8f71896397723287ddf1497ea61297 │ │ │ ├── 0ea17004d718ec4b5b84011a18828cf136f86973 │ │ │ ├── 0ea4e4491ee2abc4ea52e48ba33eeccf62d5f85d │ │ │ ├── 0ea84a4a5eee9c0cfe8bd52347d11c08b97d6640 │ │ │ ├── 0eb26606cb3895e3e7c3160a2acb1dd55cfde903 │ │ │ ├── 0ec71de4446b68520af7b2f5cb5495f2f7d56bbc │ │ │ ├── 0ecc927da181cd3e4cf9d00b158c6acd0700b7c0 │ │ │ ├── 0ef9e684b87a52e1d2ec2b274d91ca104093f268 │ │ │ ├── 0f0de5c345a12934d91427634192d4040e5bd1fe │ │ │ ├── 0f1aee7720bb0ab848210f3e547b18c4431e3651 │ │ │ ├── 0f2ec0ef703ae34c9801d778277b221e6ec19ba7 │ │ │ ├── 0f51e2a5ab57413a930a436edf258d17d6ae7de2 │ │ │ ├── 0f7b105b71e9cb68726584b4fa24c0ebd801c4ca │ │ │ ├── 0fa616a640ec4b881c4c4ea08e1a39f481403fe6 │ │ │ ├── 0fabe142a692b593ed073f5db1ef2aca01dbd689 │ │ │ ├── 1000a469dfca1be2144a6563e3bc8e3f5ceb2448 │ │ │ ├── 1007d21149445ee61da9ad4413d7acefa9ede7e3 │ │ │ ├── 100be162498b413ca391dea2387d07097432e64b │ │ │ ├── 101afec325ccd0ecfd32b22bcb5ddb64cbc1c497 │ │ │ ├── 102f84dec76aa32c7c32a67b8398d3433fd9c124 │ │ │ ├── 10549677366e93a6b247cf85ef6b109794e927a0 │ │ │ ├── 10624dd984bc11b57e154d0125049824624ef4b9 │ │ │ ├── 106f9a1f4925d539eab0171af97bfe996099ad01 │ │ │ ├── 107e2cdcdfabb3aca2ab5aa2fd3c97288ca30c94 │ │ │ ├── 109b57979771e9a623eab0dbd365a6eb604e4d39 │ │ │ ├── 10a884685231a301c2628f0607b449081b250ab5 │ │ │ ├── 10e147455c54d7bb8f4395e8f52666ee498a10a3 │ │ │ ├── 10e2ba2a40c7f4b5bbe26a0ae7a814ef9883672e │ │ │ ├── 10fefd7899096dc27cf05039ac9a172231d52173 │ │ │ ├── 1113b16ac0b3e4b76353eb896e7272061f03ff8c │ │ │ ├── 1131434b4bb6f2acbd59abb881c239975a1116af │ │ │ ├── 117e130d533574c601aab37e70b93bae134a6527 │ │ │ ├── 1184f4a41ef45af98fbb77736bcca10e157c347c │ │ │ ├── 118b63929e90757c8ca1ec818ecf53f8b71c70fb │ │ │ ├── 11b1f9db49bba588d8f418e89843ef901274fe93 │ │ │ ├── 11e26aa15592a14b6f7dc59ed4225b0ceeca2418 │ │ │ ├── 11ef5be6a614ca068f2c89bc602378f8ce71d763 │ │ │ ├── 121e9e0d61998a2f829c791e9f23a065b8ce683d │ │ │ ├── 122e57288341172f17f63e1689fc9a205e9e5905 │ │ │ ├── 1260bed4953f82e80f379c79bc4484db28c58d8a │ │ │ ├── 126e5c88c57ce073bc1e63e4306d21823db4b99a │ │ │ ├── 12bcaf48556b4780abcb73c4f32bd274ea7861bb │ │ │ ├── 12e033c1a8f3298a775b13078a77bc8befe4567c │ │ │ ├── 12e5f4d526a722bc9b8f2af83ae028c8ee6b9027 │ │ │ ├── 12fada550b4d90c67f307a0d563ae38283c008fa │ │ │ ├── 13080e256b05f38789902f0dbbc437401d15a3f2 │ │ │ ├── 1318e44a20cde77432578f5126e255855a0f8104 │ │ │ ├── 131ec09b5ca700e6a035eb50138f6a7f62fe3f91 │ │ │ ├── 1337852e30e2d514c14e8123b84fadb9d4aa882f │ │ │ ├── 136bc03e80bca2dc5f71c4fdf91e7d690eac78e2 │ │ │ ├── 1390c111cc1ca46caab6bdee16d74dd49519fb4f │ │ │ ├── 1395575564b7da66e3b458131eaed79bc605b605 │ │ │ ├── 13c9792e4f626e8f900acfa50cf122a5f5f15030 │ │ │ ├── 13d37de420974d4290a6029f20175feb02e1106e │ │ │ ├── 13d9b1cfc7b7864ec3f85c71a1046df30cc17b62 │ │ │ ├── 13ecc0464cacec7245082422e8f3212d959e0fa9 │ │ │ ├── 14450718a3a9e2266004b863df27746606f071ae │ │ │ ├── 146b0be5a219a70b803fc5f82ded6f34e4cf7a6e │ │ │ ├── 1477a76ad0e64b74908b0f8a89549c7cf7190288 │ │ │ ├── 1493716a3ca7c3194959cd177b8dd531b04b0b9f │ │ │ ├── 149679a6778ca49110eaeac21b33cd449242eb91 │ │ │ ├── 149bceae555709818ddc8eb34d3cf4b508780b88 │ │ │ ├── 14a9e9b7200758410bd419f2b0954ec253e17889 │ │ │ ├── 14b46e9b808aa20b426e21803aebd6efffef133f │ │ │ ├── 14b583f6a2bb67ac548a6daf674748880c14916c │ │ │ ├── 14bac90ea6a6692cf7202b96a1c18e47f81a055a │ │ │ ├── 14d0d7bc3443d31977bc6035b1a9bce2c6dc9114 │ │ │ ├── 14d9a8a4291206e2c4d73120dc485bd077e5f66d │ │ │ ├── 14ffecf99f50d1adde6ff14120965c878f744781 │ │ │ ├── 15032320c16e26b0069cf1571846247d073f2efe │ │ │ ├── 150b2d12becd542c0352fdc80bbd85c2901d8228 │ │ │ ├── 152491c8478252c98640ae41d5813cd6cc4800a4 │ │ │ ├── 1532d9cb1517dd25a5c8a93eb64d3962a52cf4cd │ │ │ ├── 154147c0c82e41a7cfdb7b8295df125020cd7113 │ │ │ ├── 154b30ae55351cbd129d9b1b6a6311572840bb26 │ │ │ ├── 15541041a721e558c8cfa7f4ee5f4d09fa6c9065 │ │ │ ├── 157183c1796c9575b6c576a29c98f58fbd42356c │ │ │ ├── 1571fe984911dc73398ce28defbf71e715958a81 │ │ │ ├── 157aebc161b66c638243c0a814262c48979b21de │ │ │ ├── 15b38d795c9bb9ef573b4d2b1ec4af8fc0cd8fb6 │ │ │ ├── 15bed2762ca16694fce3754fdcb0fe404484b18c │ │ │ ├── 15d389f49e1f412ed725252d3ee81230a2e81cd0 │ │ │ ├── 15fcafcc7469d59709774013df0fd9633e820008 │ │ │ ├── 16128f27ae921b87284e0eab75845884e009c865 │ │ │ ├── 1630122f5bef1592ca6b6280297bd620d8ce0ab9 │ │ │ ├── 164113b42e586e2e8ce7bb6fccef9f52a5136708 │ │ │ ├── 164178c636e1e1ccfbe67f53e9209ff1c0e8584a │ │ │ ├── 16431b60ce2185dc8a3e19f1b9325a1078131515 │ │ │ ├── 1658b5c8f7c6d3672d694462a7f53ad3f3596d38 │ │ │ ├── 166cd55c33178000f9e3e3b366ace5266964a5c3 │ │ │ ├── 167a4033a1f4c30b87898758c3868c1025df1694 │ │ │ ├── 167fe32905b764460a1199e4a4ab3d84ef186e2e │ │ │ ├── 1680d648bb0d496b0b5cdc71bd31f42d092b5e31 │ │ │ ├── 168c2988106ea01a8121eba649b024715de5122f │ │ │ ├── 16acfa58909fa72c2eecfaacc8866e7dd1f42fda │ │ │ ├── 16b2bf568fa5aa6e4b5de39fd290f6de49b091ec │ │ │ ├── 16c6bf5c5a6caf8746580f9e01ec4e218a4c0e39 │ │ │ ├── 16ecdda3d618db946d6033f96c780764642e0471 │ │ │ ├── 16f6f25ce07eadca0f3c82818b8910b5006b6aa5 │ │ │ ├── 1715e26f824103c322e360c6d3c237781724ca4e │ │ │ ├── 172062063b7ae63dcffacdd6b98414054d06633e │ │ │ ├── 172b85f2524cbd3f0ca1a41380566b1648c8c405 │ │ │ ├── 172ff5cf4d0d01f9ac160be767a1b233dea05ffa │ │ │ ├── 17405fca2ae8f08cec8849c6a750217abef9ff89 │ │ │ ├── 177f3355a5b98fe40607bd5da8383d7129c515d5 │ │ │ ├── 177f56a1fdc5cc3198a785f6f5e7a55d8c324f16 │ │ │ ├── 179b29b5e6ade731ba119866f25b6743232bd3ec │ │ │ ├── 17b2c3c5c8f5c6d4e3b517021c8e26c982fc552f │ │ │ ├── 17cd80eebaac8182716c6996ad037efac35af699 │ │ │ ├── 17fccd13627419da75dd075f405d0c40a09c652d │ │ │ ├── 184dbb048070da2a1db945f29853600246189da2 │ │ │ ├── 186d4e3b056dbde38d01af9a2095f2b550b930bb │ │ │ ├── 1870a7b0cbdbdbcb7e9f1d248928fe0dca885fbe │ │ │ ├── 1878d0c6c90056867949699c2702dab1671a5739 │ │ │ ├── 187dc420ad18b5fb75f0f40dcfa22e824b23bbd4 │ │ │ ├── 18822bf70764f3c01f808cd81031bdaa811edcaa │ │ │ ├── 189034044dacfcbaac5a98bbd0a33a369683d2d8 │ │ │ ├── 1891c772f3ce8c760b0cf1b52164fe1d2e4ce605 │ │ │ ├── 1894c4ad4a51725e14a4b3ca4124be935f442f98 │ │ │ ├── 1899c6c029807a2b6fb9c8709343768c03f3405b │ │ │ ├── 18ae04d1c49da35415f8e30e1757321ada62e83c │ │ │ ├── 18cd769c18f505e8bc05856ed71e114b5bd9a022 │ │ │ ├── 19056ae532d1819a4355eff6310ab655a5030df5 │ │ │ ├── 190cfc23dd00d10a83315e6bc368d40445cd322f │ │ │ ├── 190dca39f195f8973c60e414fa6fa6aacd3d9290 │ │ │ ├── 191602968fa2af7edef6e40a0c4e4b9e4ef4cd75 │ │ │ ├── 194da7e8add6b9a1ecf41a75f040b4611f016a09 │ │ │ ├── 1969e36c75fe223b6de50a2e92c6ce56dd4915a3 │ │ │ ├── 1970570c77db050bc51d853165e59487dd05c1a7 │ │ │ ├── 197071c336e5f96eeccaa2d253d5c00e0ac7febc │ │ │ ├── 197a3fa4a03436efcb2a86e1f8cbb45de1371615 │ │ │ ├── 19928329d12601dfd9c4a12541e9799fefb5439e │ │ │ ├── 19a982b7ff350572fab07d8c7397bd3e8f2cc04b │ │ │ ├── 19b94494f911d6c8dffa42a0570e686d8d385d0e │ │ │ ├── 19ce749d29e4620af1b8364a70b233842f7e9d56 │ │ │ ├── 1a199a3cd2f3a67e25e36bd4711b535ae3d24e31 │ │ │ ├── 1a3a8c18a8e82421d33989ed4d05f5485999b0db │ │ │ ├── 1a83bda864530d8086caf59fe1272ad5768d34c7 │ │ │ ├── 1a9368b5d21e42219df4751485b7f522507fdefa │ │ │ ├── 1ab6d3c20509931b1abf61a6b45d8069679b66fe │ │ │ ├── 1af45f5f9b4d38fa9b4e939f3e3622bcdf2d29d6 │ │ │ ├── 1afbe3f769c38b8e8b6210ef4c1e57bc6cfd7f8d │ │ │ ├── 1b13c8bd9a345bdcf71eaa1078ef4cb752b3da96 │ │ │ ├── 1b2543854748d5b37077ed3e53a36309f5330a50 │ │ │ ├── 1b3c874362224cdb658666354aa6fb9efff9b371 │ │ │ ├── 1b4bc136aef0b80666d85ce3d93b7996d0ce7ab5 │ │ │ ├── 1b5a41cda693f9d63f77b9b053dbac3106aea789 │ │ │ ├── 1b68c33f2aa26138257e984d7c57524a609332e4 │ │ │ ├── 1b79cd4b2e7a4b311359e56e468853036d3681d5 │ │ │ ├── 1b8f51ede6850bb667b5fd80d78e02cd4832d753 │ │ │ ├── 1bbde099bad78eb5021b57eaf4e9fecec63162ce │ │ │ ├── 1bc3e95ef1ef57164dee0340314916513b071491 │ │ │ ├── 1bc5747eb674dd470ce9e8f236e8c461bd9f5491 │ │ │ ├── 1bc76532e1949261ee2079d9ce81e5bd2ee2c56a │ │ │ ├── 1bfe6046e6cdc344b877ad37196692f2724dfb96 │ │ │ ├── 1c0b90070d5af0e0da662d27418affd7255bb328 │ │ │ ├── 1c1b10df48009861e679c78f57233fcbab1c9c74 │ │ │ ├── 1c1c68f02884233862b5ace3f063b648ef1a8f5b │ │ │ ├── 1c2a334bb5693def73177ba056d467309d1a592a │ │ │ ├── 1c34962adc291e2c8bf6dae66b8fb9c765b86439 │ │ │ ├── 1c385e281c4e1f86fe4c3b41f133fe0f1ad20791 │ │ │ ├── 1c561097325c97828153532b8c7b95b14e46dff4 │ │ │ ├── 1c7cf3e3c8d41ca4743e00d88ec0434c6f31d4c9 │ │ │ ├── 1c903f96be3cd8956476fb915624fb89666a187c │ │ │ ├── 1c929a0b875b383b7f3db0d168424cf2ba6d3cd5 │ │ │ ├── 1c974326af0bc49a9f389a9c91eda58bdb47ef17 │ │ │ ├── 1caae5c5cd8d5b5cbaed34c3bffbfa19df6aa109 │ │ │ ├── 1cb39f47f10b248d485afd4c83fa450fe4dcf928 │ │ │ ├── 1cc704edb370c2b52aa731bd30ea881ee0b2eb53 │ │ │ ├── 1cf397672140f803d1c48c64b7a9b55ed395d983 │ │ │ ├── 1d396736b3bc9203fa55467a0775f7a058a44b05 │ │ │ ├── 1d4be0ac5b202d439cadb143602ea3459a3eea33 │ │ │ ├── 1d66bb4f8ee00895bb9533eb0329de6d26b4e395 │ │ │ ├── 1d6b45d432e1a9f7bcf2692c87fd3865d9e96451 │ │ │ ├── 1d6c3731bc1125e0c52a0356e80d994f891c5e9c │ │ │ ├── 1d83703eed5baa3599b3562c9ea6f395f0ecacbd │ │ │ ├── 1da56d6e6d60e92c14472e47b665a85be68598f1 │ │ │ ├── 1dd5926d9df81e85da3075d37f0702718c88900e │ │ │ ├── 1ddf875ca22b308639d7b1cab6ee74ea77bc6bce │ │ │ ├── 1de45c6257377171ec1383ff685db7ce8e13d8c4 │ │ │ ├── 1de7bbede303fc60efdde225de97fe6e4cfb88ef │ │ │ ├── 1df8c615c5b7d5080d1019801137bdc97c72d639 │ │ │ ├── 1e2b8ba68f2655f0f5159ba8ee446f920bd6f384 │ │ │ ├── 1e2f14f392e271b5a594679f83b4847d83b8109a │ │ │ ├── 1e2fa5e498506cf0c5adee563fba8cdb0900cb86 │ │ │ ├── 1e32a9cc12b73e8a61aaf4c846d1cd0ffa78bf93 │ │ │ ├── 1e5a2d83584c4f1ccd8746aa4cc87f3b5c520e63 │ │ │ ├── 1e754a40c050fe3c356b0e253ed22633f2c5edb5 │ │ │ ├── 1e841722ec03b5be4c1001e90d8019bf9e01d892 │ │ │ ├── 1ea62bf92cf8078007e5cd279d0ac921980c1395 │ │ │ ├── 1ec26ee9e524029b8cf64e318125007a12c085d1 │ │ │ ├── 1eed48f62357914c0650cba567a06e37071db51e │ │ │ ├── 1f06a021e51a7104e4b8be0ce9c51232c8fd6c77 │ │ │ ├── 1f21715d338b4550c3e7e74321d26de8853626f0 │ │ │ ├── 1f33b328ec921a865dddc299139161f27b477147 │ │ │ ├── 1f59389661d72064b929ee2bac0a3f2782c99fb1 │ │ │ ├── 1f7d7d9cf1ac6252c762a06bdb35e619ce77741d │ │ │ ├── 1fa141a9352d1d89d10a4d09abf044c9506a4bac │ │ │ ├── 1fa4445b8704e72f4df267622d688919d1c6a44e │ │ │ ├── 1fbfc728d51680fcfeadde2a9e6fa7d1ac3996ec │ │ │ ├── 1fcd778862db2069278171a2ee940bf756a2bdab │ │ │ ├── 1fcd7eddbae73818ef08042df1c443c53fab0c49 │ │ │ ├── 1fd0cbef8f091c8edefa214a32625302e2f3a6d8 │ │ │ ├── 1fe16cf825c0f639b3abd120fa85f9a344d3e514 │ │ │ ├── 1fe6f643a391a7f73e3577d1f4e57935064e1c84 │ │ │ ├── 1fe7d8f0f7839c475eb9dbd113d0ac120b1301fa │ │ │ ├── 1ff8cc1006122254a00dc42299f828366e65b691 │ │ │ ├── 202c9cc0aac7d6c5172f0818c8d0d3405649d29b │ │ │ ├── 20372276860410d8622c60d5ec72e5716e313dfc │ │ │ ├── 203cda36559f2e342d3921d1f1f5ab05e330fe7f │ │ │ ├── 2068fcad81b42ac14a337456c1c0e850bc5567e8 │ │ │ ├── 2071f151f52b689e1e3c9f2b0372a3c1ca4c6dc9 │ │ │ ├── 2089f610f91855cc26e8760f3910284181dc1b86 │ │ │ ├── 209d75465a4314536f2bbabf6ada3622bec989d5 │ │ │ ├── 20cd1af7438c223f49d33ed3693631c63f6c3234 │ │ │ ├── 21227867cfe4806f692be272ca5b865dcecc1894 │ │ │ ├── 213cd49c2b13fe3ee6d2220f5f96b63c748d1add │ │ │ ├── 2152488b729a3937e9f4e83bbefbb36d961013ca │ │ │ ├── 215ddb94c508c11099b9268dbf4ce0d7f7d18977 │ │ │ ├── 21a38194825eb39a4a0ae99128be4409c90d420d │ │ │ ├── 21a967d5a754fe4909db382de1d7debbb040d069 │ │ │ ├── 21b086a0fcb5394bca5e13730e9801a167031fd3 │ │ │ ├── 21b915be35d2383f8baacd2d513b5cdd06836ebd │ │ │ ├── 21c64c51dc34976712f8356ed25d28cb2506a3bd │ │ │ ├── 21cd99bcb03828e0395286a09e866684d6c569f0 │ │ │ ├── 21f06e9520e734ab7974353357c55b81e5ee87a9 │ │ │ ├── 22089449f264bdccac5901669554a20c01c7632d │ │ │ ├── 223d492bc034d65fae5c76008697dc6455711a0b │ │ │ ├── 227dc7dc4b5fedba0f90b82d69d0f8f6785c49f3 │ │ │ ├── 228fadb4fab77130e6a42578be8c100758962a74 │ │ │ ├── 229254c58edf03c88b0434f339de04542e82f168 │ │ │ ├── 229a032ed00e20e08e27892cc81b53b28e1d245d │ │ │ ├── 22a01d7a209edd8694bd9edb1c95de74dbed6fc4 │ │ │ ├── 22b9de25667093d760c9e17c5477dead3043b33e │ │ │ ├── 23157f2fc305799762478817c79fe62d896edd22 │ │ │ ├── 2334138f3c633d853dbab847307d9950c227ac09 │ │ │ ├── 2341c37b333e27f887345a539b3a46aa15fe6738 │ │ │ ├── 234eb0340c07ea7d86dcfac62e971eae6dbc359d │ │ │ ├── 2363727c5d55ff4d6eaaf41f33d420d94aa0259e │ │ │ ├── 2364ebc1025f0c764130435a3da1d5febf1ac0a5 │ │ │ ├── 23873275d271cfb7c8271e4058054ab8102b18bd │ │ │ ├── 23ce0a835c3fef13acabbe51379451af1bad4377 │ │ │ ├── 23ee2abacaf9004b59fb4b0c0bf4fb0518c0b719 │ │ │ ├── 24189b1ed398f5834d414ec0517d0e4ec49e5123 │ │ │ ├── 2447d402d9160d103faa8fce8f16b8201a516a4c │ │ │ ├── 244d1fe0151e8979539727b36d9efd4236889b85 │ │ │ ├── 24b9d083b99a1fda505df14b9b98cadbf34618a3 │ │ │ ├── 24bbb3bb32575090a29c31c6d367e46898dc602a │ │ │ ├── 24d0fbfa8bd2c68fd6ee1e4839bb0d5bb73ef21a │ │ │ ├── 24e2153d05b71ded99689e64661aa90af06300e2 │ │ │ ├── 24f5f696fe56cb9b25c9d12a9606b6d6f531d6db │ │ │ ├── 24f8bbbbf4e945080301e930844b08d263783100 │ │ │ ├── 250db3e160a3b1e5fb27d5880463b82d2da450a9 │ │ │ ├── 253542d32b85965ac57232e3741542be2aa8d091 │ │ │ ├── 25452194c45988fdb9442f977481e8fb95b4ad75 │ │ │ ├── 2546c1139a14d6b2b3d6b9918c96de6e589fbf07 │ │ │ ├── 255e0819d8c9639459a4e49579fbd923cdf9240e │ │ │ ├── 25608654bdece6361519480d9115afff3312cb31 │ │ │ ├── 25bdf9d085288589dbb23f1fc7d98f7783cb09fe │ │ │ ├── 25e7910e53d821321fab3c8bb9db847f37fff616 │ │ │ ├── 25f13dc685e40d3fb22819356cbba4a5a6789e15 │ │ │ ├── 25fd25289846f102771af05c1445e63acb583b93 │ │ │ ├── 2619632226257817c56eb288a9d2075e56dd0e34 │ │ │ ├── 26300a1704f502625832730a36d0088f21a46e2f │ │ │ ├── 265d0640e2752abb03fbe0a1b150f575f8469aa5 │ │ │ ├── 2669c9c65bf3af74d4482204c70ea69545d8babf │ │ │ ├── 266c1691a90b2a342849d25e3704659308c45951 │ │ │ ├── 2670c894e879a8499f50e08ae018e501b6693152 │ │ │ ├── 2692015cba943bdfa1b324204d53284234754d15 │ │ │ ├── 26fbe1c5bd294a3fc35af2e36f46c951b25e5cc3 │ │ │ ├── 2721ca2fc08ca7ae38cc809a3799bf618ce5a75d │ │ │ ├── 2756fd453011fa7471613114061631b066029dc5 │ │ │ ├── 278eb959a30cf3ec8163a007eb3f89ef107765ea │ │ │ ├── 27ab4c447f840d27a13d145eb27c80db511a400a │ │ │ ├── 27aff0ad61d128505e22df766c0492e316fbd9a9 │ │ │ ├── 27b9b3e3bde2958e048cee68f2493d41648987d3 │ │ │ ├── 27be24f0f9eb749b51dc6e83c6ab5c8637349a25 │ │ │ ├── 27d37797fa4bb9c3bba68f9967eab892fec70642 │ │ │ ├── 27f1dbe3a65014c59ae266af3346177a5a57d4e5 │ │ │ ├── 2807a46ba9b453c2f9e4af2406b26ed38137b216 │ │ │ ├── 280d6a9607ad78d3eb40f04e5b5a76c6f8eb4c02 │ │ │ ├── 28259bbbf78c881c7400ac4602722df51776ffe0 │ │ │ ├── 284cac89d0553dfdc596ce4bfc4251fd2115cb15 │ │ │ ├── 2872201824aca727042b22cae049102582283dd9 │ │ │ ├── 288e61a59fe0099d03730d5c9d59712f743123a2 │ │ │ ├── 28a21b4f4afeb9c978b1290c620548f1f33e127e │ │ │ ├── 28b1a2ce5cf374a3ce64a6c7853fdbb6a15d1e25 │ │ │ ├── 28f223ee6f9c2562b1e382ea899bc7f88e63490e │ │ │ ├── 28f4e044d59009036250527f061daea52c6b5917 │ │ │ ├── 290325a794a4307e35ab570d847c9854f6d63001 │ │ │ ├── 290a1cf15d24d80b8dba0ba4397f5a7eb13382d0 │ │ │ ├── 29186f53cff8c33b62ccd1cec92b4c6b02c8c2c8 │ │ │ ├── 29306f00a438f213a01ebd7a7b0d04ae25d239ad │ │ │ ├── 297a3281b6d5be24c14d7ff51f2fbfe46ed86f1a │ │ │ ├── 297a666c7fc982a83775114d7c6821fb42031e06 │ │ │ ├── 299581f978295f5b97afd9102abe9746f3633e76 │ │ │ ├── 29cceb8deed87738d060e1bd5338ab0536f8d2a6 │ │ │ ├── 29ce41699e783cf1ab6b5b84bcc1f8da679ce8cd │ │ │ ├── 29d289d23bf6e34dbfac501041222a1978cc95d2 │ │ │ ├── 29dc54df002663eb3874c3fb7d3952e70b1d1779 │ │ │ ├── 29dd1cab8fbe87bf2eba3c671a6054c32e47ee9f │ │ │ ├── 29ec9ea0cab2025b952a31c864a85546c8a8f032 │ │ │ ├── 29ef22549cd23bb217da411a3ca72d83c71150d6 │ │ │ ├── 29f6acfc391f9db2fecb96ea0a708da396ed202e │ │ │ ├── 2a46178ff8d5794433a794e9fe86b9b5fc268cc7 │ │ │ ├── 2a479685fd7da722bb6722ebc37d68cccb881ee6 │ │ │ ├── 2a4e458a761d418129aa4d22bbbd076927fcef77 │ │ │ ├── 2a4e61567a20b2e90af1a0fb476b1ba0154b0a8c │ │ │ ├── 2a7da9157e1527a2190bce26d0a1303d7f239f9f │ │ │ ├── 2aa0596f17f2698bdfd51894a7dc1e1241cd3ae9 │ │ │ ├── 2aa48f72c81f73267919baef97d2c186ffc36882 │ │ │ ├── 2aa72eaeb2dee91742e3412f9e1ec464ecc22161 │ │ │ ├── 2ab67ca0e8401c63810a011ea1b9b40ef8573922 │ │ │ ├── 2ae84cabbb3a18b00167af69886696809a07a86a │ │ │ ├── 2aef8c06dd7c0aa09e6494194a3b812e4b7b2221 │ │ │ ├── 2b1075a4c09b4d3aa3be48cb1ce2571ab06a86a7 │ │ │ ├── 2b168b93f7f916976567d85cf8e7ca0d6dbbf32e │ │ │ ├── 2b229e9febea1749971fa08007b52b574b3046fb │ │ │ ├── 2b4be33fed42ff17f8c6910629b0e2183d109eb9 │ │ │ ├── 2b609a197a87b5e2d1507c9acbaf2e2ab79ce53a │ │ │ ├── 2b9f2b2856d6b4e70d3b3d8e2d4ffcc6048847d9 │ │ │ ├── 2ba9b396adf10109648ab2f9856ca66b6fc5b688 │ │ │ ├── 2baded8ac492d5bbd1dcece9f3d4a2f0458c778d │ │ │ ├── 2bde7ad09804a986048db6aa7983bf552f327e9d │ │ │ ├── 2be1d596003c42e91c2a03626c93ce8259dc64ad │ │ │ ├── 2bed09f85647ccc7b26bbdedb9cbf18167240799 │ │ │ ├── 2c2132ba18413a6ac05a486fd72669aa4293e784 │ │ │ ├── 2c24b83fa75f9fc91269d9be43a5c14f9a0c8adb │ │ │ ├── 2c2615f5ff25527bb1609bacc940eda0c32b8d28 │ │ │ ├── 2c2686017a35729961e5b4064e6ea9b58c073505 │ │ │ ├── 2c28303252e327e51e1e99036e9c4fcc97b10d8e │ │ │ ├── 2c3a119d1d9da7d4fe68883d95e8f11060a9def5 │ │ │ ├── 2c3a775a5deae4555f3af3537c8a4195c6e5354f │ │ │ ├── 2c62f7a3d90b30d6f1b1804f6bf0a916d3305efc │ │ │ ├── 2c67e0be52a7389f103f44944fe8d8913c973b48 │ │ │ ├── 2c7c5497a7e7f81979773204f099b9f23323698e │ │ │ ├── 2cc2506d179d284634729bf9fbd8c05239f90ca9 │ │ │ ├── 2ccd61243d6bba96a68b774617b9d76c97662ff0 │ │ │ ├── 2cd0311c121154bc8385767e5893c92ee5aa2c05 │ │ │ ├── 2d240420d7f8e429cb31120c7bf532805423084e │ │ │ ├── 2d2a878308fd10775f477107b478ca6993799763 │ │ │ ├── 2d50c7d765d0137b5bc9bd78ac8e39437d22fc0f │ │ │ ├── 2d562228e60c1a1e62b21379cc97a7cf96852b48 │ │ │ ├── 2dafca8d1802bbb6ce3ae1196aa647ee3c9e418e │ │ │ ├── 2db945824c150b91aa78265f9e3701bd991fcf10 │ │ │ ├── 2dc10a9c76952430b8601993c330b88bd0e19cb0 │ │ │ ├── 2dc5b1536be7b443c27e763739595c42dc34998e │ │ │ ├── 2dc9f8f8cf217ccac41228917cb739aee23f3b55 │ │ │ ├── 2dcae1af8317442bc492bd0899984f32bf30396d │ │ │ ├── 2dd9b9584d97aeda14030c0cb94034e5a64e1e33 │ │ │ ├── 2de7782cb97bcd10b69053268684420a0022efd6 │ │ │ ├── 2df7793cf7520895ea4121850c34c16bd1874c22 │ │ │ ├── 2e15993224f1d73378824cbd1780f6d25e85740a │ │ │ ├── 2e2b8acfc93c65c04508d0730229d6beb1760346 │ │ │ ├── 2e4630df1ac360494322a4300b3a916bf4a7aa42 │ │ │ ├── 2e9a37abf29713e5bf564831df0206b134ed9e23 │ │ │ ├── 2ecab25cfb72ae137a881589719a53343a030263 │ │ │ ├── 2eccff6ea763376046948b3876b0d9b3e8b28c87 │ │ │ ├── 2ef7e082ae22ffb03fec01772b442b4b8d19cf06 │ │ │ ├── 2f1b30aed18276568d11bfeb997aac3246d57017 │ │ │ ├── 2f63727a65eb7f7437ab5c39d3f16671518719e6 │ │ │ ├── 2f6a3e29b8be29ea5949fb1b5a71679b5cadc8d8 │ │ │ ├── 2f718ebe5d9460ba98f7815e59bfffe1cd1f3bc6 │ │ │ ├── 2f92c5daf5b1fc8c65563916bd77ad58dc8ffdab │ │ │ ├── 2fc6756b64916b520df4a5d7eed9bc7c1ee85753 │ │ │ ├── 2fe9ee314e024619b228c81cae27f4bd50141a36 │ │ │ ├── 30060e7ffc388552b8bae73eb28705b637f7685a │ │ │ ├── 3012845a3aa7dc757cc4778e5334769c9239ab60 │ │ │ ├── 3015e994a3e16567397bea00a92ff97eb53971e6 │ │ │ ├── 3031aef9ccb0cb566246e72e7f976a7cf00b9898 │ │ │ ├── 305b7d52e8b2e5b62f366d1fe9aca1b4c31a2e51 │ │ │ ├── 30733f314d77a04fcfb55b009f72a5a1a94cc1e5 │ │ │ ├── 312a2eaf5a3bbccf69b97e292f665b53846038f5 │ │ │ ├── 3177278ccbc91f49567f80c0b575882edaf4556b │ │ │ ├── 31a7241822ef819833b51d86a78d83bbb4d58136 │ │ │ ├── 31b4933ee39bc4133c6a36b1e309775c87a96c23 │ │ │ ├── 31bf684d25c7125e85ce524a607eb2a52cb7bdca │ │ │ ├── 31c15818563bf9247178dcf6aa28b033af2bb447 │ │ │ ├── 31c6f3973f706c7761a06718934fbee33a007e9d │ │ │ ├── 31c88595514658ef1b8ff73277244b8f007c505d │ │ │ ├── 31d4c861644fc9edae1f7e2e4f31aa06c7517889 │ │ │ ├── 31f076334b0a05c6d42d3ee64880af4288a1a071 │ │ │ ├── 31f2c4c02978ae42e16425ad8313162bbbba6fc1 │ │ │ ├── 322e55f03866ad2580881660af953e8169abf66a │ │ │ ├── 32465695f8a85d30402f9b194bdf25dd6e21729d │ │ │ ├── 3296dbebd697c68468c1215ff252b1da046d3d4c │ │ │ ├── 32aba46093e0c1405d3a8229f68cefd6de6d9767 │ │ │ ├── 32abfd2efb454436ddc75cd07a406d88aabceb2a │ │ │ ├── 32ba176293211377a9ca30f7b1742a3102758b7a │ │ │ ├── 32bcf37b6b3d15680600c81db467e1dfff6ce375 │ │ │ ├── 333dafc1d96971e2ccab51c8ee0d9e479decf78b │ │ │ ├── 334e3a237339fce576119749a9aa81f3d65211cd │ │ │ ├── 3352986afb9bc33fc67eaf72f47be64e3c6ccba3 │ │ │ ├── 335b7a860725ca4f2c467a8b034060d0ce6b3bb4 │ │ │ ├── 33848da9a02cc62be9f5a84c5ce6e33bb6aa8a29 │ │ │ ├── 33aa1588445e9cbbedd1d4a629780bcc8b4a8e9d │ │ │ ├── 33aa91e75b0cc39daae8eb7a1f0889075a667617 │ │ │ ├── 33d0d39d6ce6ced2a0a8dc5d8c47e5f5098d7aaf │ │ │ ├── 33efade4e6970da9cea78a726935e5443e0d1ba3 │ │ │ ├── 33fe1028443f16cce6d9858c8501dfb0a7ae5816 │ │ │ ├── 33ff2ff9d9aabf2865009fc3701058f954184c4a │ │ │ ├── 3400d35bd94547fb613f1aa5cd2073fdca146533 │ │ │ ├── 34038f296d87d228ac46a39bb072cc03e4e585bb │ │ │ ├── 34264b99b16c56793e013d7d2ac3dc83c0c07da6 │ │ │ ├── 342a92cea02c320154d0894d36811870581b660e │ │ │ ├── 346b40c03454e4740323b5b0422908722f9a4ed8 │ │ │ ├── 348d5c1f7c9f5084425a506f649c65b2f31946a0 │ │ │ ├── 349341420dbe9b22120760aa5b91a9099c7cdcea │ │ │ ├── 349bf68e15d8f14b4a471b7ab402784c1077db21 │ │ │ ├── 349dc9e7f879b45a530ea9ac4a5ee92a83b80b64 │ │ │ ├── 34dee51305402e7e6b502025f00f29abbde3cb18 │ │ │ ├── 34e0f433a921b809a71c9924e9c0956dc34bc220 │ │ │ ├── 34ebf584d708a418710a1466a3dbc67b82146196 │ │ │ ├── 34ed3c4ed5af89953d2e81d21f7c1e45d2c7dc87 │ │ │ ├── 34fe51570c93ab7b56e8955a00795a7af3eb88c3 │ │ │ ├── 350219ab2d9d1993c2e0ad903f92eaaf6318f133 │ │ │ ├── 351979da8be9a1fded3861db5068a083d50516e7 │ │ │ ├── 35210e4f9eb6f063e680746037b199244fe0997c │ │ │ ├── 3569acb6b68f7aed0054e44b1fa854e2ef33b96d │ │ │ ├── 3572c1cebe263656185dea9403422e9884954499 │ │ │ ├── 3574aa7865915325c364ab1364ae532d35ec2952 │ │ │ ├── 357c3aca3897a104f6b209ff00a90eb8f93c11e9 │ │ │ ├── 357f1e298d27372ed2fdb360e6ecf4b4f93bf38f │ │ │ ├── 3585f3da19dc73f07d513f4d5e06b3af35381aab │ │ │ ├── 35995d78575bb81724c123126ae84f04c1ef1324 │ │ │ ├── 36107f7e7692414cd4ae5e7ee06a1e46821b107a │ │ │ ├── 361314e0baab060ff8fb2888efad4f841ee2e65d │ │ │ ├── 361c2bf607441dd9ae1d9e592d08aff1c4423aec │ │ │ ├── 361e67ace54dd8058e82517e87d5a294ff0e2430 │ │ │ ├── 36225523764ce0fcf4a54ecc157c7a9ee0ca5e1c │ │ │ ├── 363516e81c7327e6e8535e74da1cf78a4a939bf2 │ │ │ ├── 363d3439b183bb0f2c6a0d1238057e9beb398f18 │ │ │ ├── 36415fab25c89139e82b030657b2f8d9f5d9bfc4 │ │ │ ├── 36608fb81d55d07d46c2f7849cd926ee3b2544c0 │ │ │ ├── 367c9b1f3074839cbe7794421f5a5a30b5392887 │ │ │ ├── 368c81b84650d4644c983e3209d93ebe140d375a │ │ │ ├── 36918d3941b615417b367e0dda84482198335469 │ │ │ ├── 36a94d7bc5dc9af664df029d9cacb70d1662178f │ │ │ ├── 36bc60267ff97612610797a43fa5e7b371687229 │ │ │ ├── 36bd6cf68074e03b5642284ce7d493af28e048a2 │ │ │ ├── 36c7fd31d411d45f3d03143f9a36158791a29660 │ │ │ ├── 36cefffcad6493e933315f78db381ff7ecc43bfd │ │ │ ├── 36db1eaf5e186f36042dd8afeeebfabe675c620a │ │ │ ├── 36e7b1c9920f0e9a7c1c52c380c61f6b44246ce8 │ │ │ ├── 370f93aec0042473af8eda625b8e55afa266cf0a │ │ │ ├── 3711e5aa1c94f1b0f835504e4dc9cfac933f247d │ │ │ ├── 37178f03fde09a06a32ec4e778874ec6ff11c8c3 │ │ │ ├── 3722cdc62a8920daf88999d381d42a7424417843 │ │ │ ├── 3745a800a4b496404473a26dd593f84588194471 │ │ │ ├── 374e3814357798251b0430dc4cfb9f212c1dddd3 │ │ │ ├── 375599a0689231a316462d64f42ec6b33ccca33e │ │ │ ├── 3771c3d9e542f846b3c206c6719246bde5cb472d │ │ │ ├── 3774905200290499adbbac9b674c43b82c3af04d │ │ │ ├── 379b89135a99972794096065de8e1072473b7cdf │ │ │ ├── 37a26cf98e0cb201f2e241d6a41e267821078fc2 │ │ │ ├── 37cfd491e753f20291c4606a4bb007cf1aa69eaa │ │ │ ├── 37fdd34d221df947a4dc6a40f91fe044f88c8ca2 │ │ │ ├── 381cf7c5a9c44f989bb97ebca54137b24a0c5102 │ │ │ ├── 381d7b2c554124f48f833d5bb44cb65d6a4e69ae │ │ │ ├── 3849d609dcd2299e85caef8d7aaf0dc4cbda60ea │ │ │ ├── 385fb0d2eeda5f4790eeab09a29ec612150cd115 │ │ │ ├── 3862864a68546884d4ae2ef7644d75b814fd279e │ │ │ ├── 38633120561625bae7ecb1c951acd585717ee56e │ │ │ ├── 387db60867784e48a23882557f34fd3e8df5fe60 │ │ │ ├── 38a77bbe28f3ce750b32c16df488eb5970d28d51 │ │ │ ├── 38b2b86e0814487d32eb0a49aaa091c527c67a39 │ │ │ ├── 38b7d993272a54c03a7adb7a046e8485546ebd0a │ │ │ ├── 38bce0395152e8d2a60a95b4642bf3700934e4e9 │ │ │ ├── 38cd5b3045252d1ad4ff3cad40d838874891506c │ │ │ ├── 38cf290b09eac905ac4bdc5ffd7fbeb55b28d0b1 │ │ │ ├── 38fa5cb2147069b9e33e21d621935d45486c5345 │ │ │ ├── 39016f47ee6449811c8a18548ba14d36d60f1a15 │ │ │ ├── 39095ad3e086951d38e9de71ed6390bf4a910ada │ │ │ ├── 391ae71a3b29dc703963bfe3a4d96555cac94848 │ │ │ ├── 391b89f7a6069cedebf4da40cbd2e894c4e4e161 │ │ │ ├── 39261d0b29bcefd21020cd2c24c872c070c66ae7 │ │ │ ├── 39427d9b3326e6d242f88c30c5337e28e60ba2cc │ │ │ ├── 395284f8211e771929c6abd17a1e39b471bad2ac │ │ │ ├── 39702f9a29cc5985ccdbae18da3583e3a98271be │ │ │ ├── 39a530e81b2ae6640a22eade59df3f302ebb0806 │ │ │ ├── 39c2d78974b78a945ee5325ec03d2a9842678371 │ │ │ ├── 39c6fd26ec7474a9addfe549df2cb8ee610ecb51 │ │ │ ├── 3a48de373b5922e0287dcbaa10361aa1464b3eff │ │ │ ├── 3a4b7a4a72ab611ede23f7e04e2c7e0300d1c7b6 │ │ │ ├── 3a5d1711382ce031d27b85c9d0db96a8d322c0a5 │ │ │ ├── 3a8258d488d60df9cd2d2e0f3fbfda5aa2916b1a │ │ │ ├── 3ad5eb51c8c2ea66907d5c7b40ef6cccaee711ce │ │ │ ├── 3b055324162a840bb031e742e417383a3c2b9fff │ │ │ ├── 3b6174c02c9421bd7512cb0b507ee81cbe621e8f │ │ │ ├── 3b756b29419004b37c85b3e93c13d3f231e1eb67 │ │ │ ├── 3b7aa5f0f9d0fc31f7be3558e9eae22f13652d33 │ │ │ ├── 3b964cb9d3464c3949a2e8a0f9edb54a4a9ce6c7 │ │ │ ├── 3ba14a20059a5c8f8e184fb6d08736296adf21fd │ │ │ ├── 3ba4a606e430170b23a098c2ac6ee7213be618ca │ │ │ ├── 3baa61730ba406d7fad296d7df24a9629ae0240c │ │ │ ├── 3bacefe15c3e633f44d830137c6fe22c074b155d │ │ │ ├── 3bc46b0f49e132b39a7468c0eeae4f18c15a9e46 │ │ │ ├── 3bd1e196feb0c029ad908a2c989b46a4c75e87e4 │ │ │ ├── 3c0a722d83c61bffb4712e8bdb67f68d6757d30e │ │ │ ├── 3c11357c518486213b14a41e23ce85acfc7225b9 │ │ │ ├── 3c20247465b4757bf0758627c8b5e4839dd819cc │ │ │ ├── 3c4f81b3cab5b54ca2ec122fa809fca650b47db6 │ │ │ ├── 3c695558731a219357e99fced06f0c24b38b6c11 │ │ │ ├── 3c6b79f35456c42d2578553948e940b494865ac5 │ │ │ ├── 3c78b5bf3e8a594974afba095afac84660219f6c │ │ │ ├── 3c986463576a17cc12996a738a2cc479d1198df8 │ │ │ ├── 3cb4479d7f4d2911b165d8e388cda3c7da36bd62 │ │ │ ├── 3cb7605604a629153b71183c4083311f53f6fee1 │ │ │ ├── 3cd91b4c3a1d21d1c90b1e6542ae78fd35091778 │ │ │ ├── 3d4082e12a369fee00a97f5ee6a3b72ea6f15238 │ │ │ ├── 3d4137ffad2b1c85003d032d19a2150f4b6517c9 │ │ │ ├── 3d65682b1f434030f11d6815360c3d269d231474 │ │ │ ├── 3d6fb8e46d4f9e03d6de0e295ec2e0e50df1aa5f │ │ │ ├── 3d75756c8dd79c4efe056dd5435cfb6a2457207c │ │ │ ├── 3da479f176b53c08e1248502a5bc75aed6c71746 │ │ │ ├── 3db85c10d9886a1d664d6d3db26ae7961d66a4be │ │ │ ├── 3dc41a3a65eecfb088cf236466ab9fb737a19b57 │ │ │ ├── 3dcd87542c1fe27ba922187001739130ac6c6c5c │ │ │ ├── 3dd2c473cd54ea601b15cc9840f01e6cec72fbd3 │ │ │ ├── 3e0593c1054f6598bbf8297623874e58ed4f2f9e │ │ │ ├── 3e1e6aa2f96548cfbcb05311c5d24990bb96a8ef │ │ │ ├── 3e2370ff2103895a7c13f394468b1d7588a525a0 │ │ │ ├── 3e30536558f547b9ad4f09f367634b969078f719 │ │ │ ├── 3ea9b3574203d1cc954fbb5b93f7588b765a4d0f │ │ │ ├── 3eabc6ab34a7c9a974850c1dd22c428aa05b1b1a │ │ │ ├── 3eb9a6cfe1aa2c1c02424702999504c5b096248f │ │ │ ├── 3ebde48f5439e084e28144fd489296408e0dac44 │ │ │ ├── 3ef5bed9863d50fbfa4dee5c776d36177e888adb │ │ │ ├── 3efcb90f4a83944731d1cbf69fcde8147549f8ff │ │ │ ├── 3f08853267dab46c6370068cbb68b228923ff0b3 │ │ │ ├── 3f1549e9384322e64380cd38621193a46900a116 │ │ │ ├── 3f1d506b154892f06d439bb90ba5202e723507eb │ │ │ ├── 3f512330103073dbd4f58e82fee2f316a4b0c171 │ │ │ ├── 3f513698f389965cd3f800cde5d06d6742166c96 │ │ │ ├── 3f6985d5b0c8658ee84900aef20ad6b450f6f3e9 │ │ │ ├── 3f6a1b44037f9a0ecf95cd3d23ce8bde0b02ff8e │ │ │ ├── 3f6da0ebdeff4ba77b33c2c2d3b962e7dc353570 │ │ │ ├── 3f7737e152b00480f6b1e13136938142db63c3bb │ │ │ ├── 3f7dd25efaad7cb28967f110fe74e5e38a763ca8 │ │ │ ├── 3f827b95772a69cca7924e0a2e6ed2cef8755536 │ │ │ ├── 3f86932b9bd5a8f673b4dd4243ebb78bef50c888 │ │ │ ├── 3f8e06a01cdada6071275fb451a2ba624eecf6b8 │ │ │ ├── 3f9e6c510733a54871b5b12db956530901898fe5 │ │ │ ├── 3faa53c6eda1becad9cec3442b7069bc2083f057 │ │ │ ├── 3fed18356adbd733c605b538f4fbe6434ecad6df │ │ │ ├── 4017ac5f35612181926802d0cfd9e7f6a5aed8a7 │ │ │ ├── 40198d56b45470dd3064ec201e05ca4e3cdca930 │ │ │ ├── 405cc03a69b95e49ca66bdd71055159a13f437eb │ │ │ ├── 405ecda072acc56c38f0eae072ad858ec1097d36 │ │ │ ├── 40637530cf642a13aaddd88b9e805ab9eed711f1 │ │ │ ├── 40815dacf70ec14f7b8a062c9faaf258058731fe │ │ │ ├── 4088fa75fe995a05522f18f9b0e6945552611611 │ │ │ ├── 40c7820188392556b1df313d7fe8ad00eac4965f │ │ │ ├── 40cdd6d34a71ec60c962c3ce8c6408731acebed3 │ │ │ ├── 410f4c522606d7e3dd362eafa5a5ab9d9811a338 │ │ │ ├── 41114b51cf4fbb2b1beee4e0cc3047fcddd88c2e │ │ │ ├── 416cc4828a6c9b5f1667ac7ad0d2684eb23cac38 │ │ │ ├── 4184d22015b6c9b7656f411782a4484efd87060b │ │ │ ├── 4186f82b0ef77212271ae59a07d75a5f370f8add │ │ │ ├── 4194caf8692db4d7109076c5dece284d07e06cbf │ │ │ ├── 41a24f98a0882fe70484f5006c4b6b9a37bc85f0 │ │ │ ├── 41bb837acd47aa639c62f7986ff46af86a6c36d1 │ │ │ ├── 420a24fcbd56a2a2791e7238666b8aa34e2ccf16 │ │ │ ├── 42c6d3a78f584cc355a0bac6f309e105089332b8 │ │ │ ├── 42da32b7dda49d356987402249a3bb67a0b53529 │ │ │ ├── 42e412a1e895536ef1264d7ee08902b8e37a53a0 │ │ │ ├── 42eddccf89cbef79a5adffb7eb5ea1523de5b3b7 │ │ │ ├── 42f1cfaa89e0e558cc339a4adfc253b4108d5843 │ │ │ ├── 43532b914ad45faf56c91ef34b9b696012326b2d │ │ │ ├── 43a09bc93d6d45b6cef903b1341a287624b825ca │ │ │ ├── 43a12820d4dfa937dfdbaa0843372e901ec73944 │ │ │ ├── 43b19c13ed8e58e70071e063750e8fca7a9f05e0 │ │ │ ├── 43bfb11c19ea9173f4b0185fbc6a622fd0787c68 │ │ │ ├── 43d1fadc7620820efcc941a68f7696480649c13d │ │ │ ├── 43dae97b688afba43b6d88389a78b979f1181c34 │ │ │ ├── 43eea0f55cf11052527d14c3cf0f96e55882c4d5 │ │ │ ├── 43f8e70fd6ed448f6cd62609f6e4a9d03a0e083a │ │ │ ├── 4407ad4a37ac5667b725ef07db2b1b0ebbe6db1e │ │ │ ├── 4422ccfb3a652df26350f5fd43cab32b4a6db9bc │ │ │ ├── 443de93ae646f545525c4a8177964caee78a499e │ │ │ ├── 444bdbc8e2a3f36427b9ee3bb33b639f3d06010d │ │ │ ├── 44513b5ccd5d2993d98b0f606e24c3363080118d │ │ │ ├── 447e0a4f2c9391201bd7abdb3935d959277ac93d │ │ │ ├── 4493e5053e8c93d7133c12033db30ab0fad02eea │ │ │ ├── 44b2a5681330965efa5dadccd65e4296cb9bb54c │ │ │ ├── 44bf61ffe86491dc47531baea9f4722fed205885 │ │ │ ├── 44c41d5a9ee6d3836c4cd959feb9946950a93097 │ │ │ ├── 44d03ac572cc57f5a15470cd97f15bcb5b9aae1e │ │ │ ├── 44d081e51884f8d702e4373433bcf56a8a7ad583 │ │ │ ├── 44d277dff113e85feb1b0da733079ba007e9ce3c │ │ │ ├── 44f204855343e69fdcf5529e0a6cb7ea5dee9741 │ │ │ ├── 452689d60be7f0c8bbd02b65a8c9841ac076b913 │ │ │ ├── 456d04cce86b68e35302afe4c3345e7531aa7304 │ │ │ ├── 457a9522f60a63cad613ce6f45ab52147b5a1871 │ │ │ ├── 45afd60d642320c756621d0d193cd27de023f243 │ │ │ ├── 45b86557bbe4fb210901de818886b7536f396562 │ │ │ ├── 45babb1803fdc9834a37bce496e989425e2fe9b9 │ │ │ ├── 45c14cf9149717468bed37e1e419020555c5f927 │ │ │ ├── 45c97ab53324162e66ed1d4c64371055d966b691 │ │ │ ├── 461af17d337077781b7e49d203e17cf7cdd7781b │ │ │ ├── 464a9d31b63ef5f4fe0f193acff3f7a8251adb7f │ │ │ ├── 4656d9b9e1003224e094622d9723247d8e53ca72 │ │ │ ├── 467ac05fa481edab9bf207738a0fdf308bb097c5 │ │ │ ├── 469213f3d0a4e2171977ef67184aa5af2a7d259a │ │ │ ├── 46a14a2d2ab594d5d1917b16120cf28258bcd02b │ │ │ ├── 46b30a46669909d38ddfd379180d9b9e4b032d30 │ │ │ ├── 46bf3a742f868512007f33d6092b25ad9851abc5 │ │ │ ├── 46faed608cd8553355e705736f5883a865bdd1c0 │ │ │ ├── 476140a4869c363ff59de15ca0b3dddb33ee16ea │ │ │ ├── 47678ed5dae9d91220f82b512192c03161458d96 │ │ │ ├── 476e1eb3a45bcd3c87728f4a5f152341fc41c6d6 │ │ │ ├── 4775847b1966e3acdf5bf21407d223d54512c0aa │ │ │ ├── 477812c3aa633968c3f508ea4a64f6240b7c1282 │ │ │ ├── 4786bab5e3fdd53811fa094d64658a869323943d │ │ │ ├── 47975b43d53b5ddfe8aebbb719cb70af90f9ca56 │ │ │ ├── 479ddb4cda1c95a66132ba2891f8deed16e1e31a │ │ │ ├── 47c96a95d6bd928e3390068b3c94db28d219e9c7 │ │ │ ├── 47d2125494edd0e8f737339160fc2c2bbff13239 │ │ │ ├── 47d754aabbae7b0b019240479e872ec641a71606 │ │ │ ├── 47f82c71674923da07b7c082409faecaa9d932d1 │ │ │ ├── 4849670c7437aabe38ac365b533b2cae10e1c316 │ │ │ ├── 4877a47b68dcd97455dcb8cd52e27309ec642b93 │ │ │ ├── 487deb88a57dc3cabdf497fe30220136e593d23d │ │ │ ├── 48a74bc4e405cef7fd774039eb79bdfaeafeea6b │ │ │ ├── 48aba9a0a8d38583f02db4ffbfe46b11affd2459 │ │ │ ├── 48ba4204d31335006c77c0a0c393c5424c5c89fd │ │ │ ├── 48bb02ef59af281b015aba26344a918d3e949c98 │ │ │ ├── 4907d4a7edab4d2d57ded00e95a654d47f9d823b │ │ │ ├── 491492c2f48c07bca9ef88c9fd36bbd272563b73 │ │ │ ├── 494a7c765d815e6adc6d4e66a57225322bccde6b │ │ │ ├── 496ed2b73e932787fe91d418b240c466ab6a4075 │ │ │ ├── 496f687a93323cea34ef1249059c862f9397c645 │ │ │ ├── 499184ec78a677697ab3ce5b0a87dfbb5ecce65e │ │ │ ├── 499f8c99044f5a7eb9940853f276e5ed7a9894f3 │ │ │ ├── 4a015d179a6415548a65aa75d68b1927fe2b0738 │ │ │ ├── 4a46cdc5c3a288a4eead1245fd3b0bfea974ea21 │ │ │ ├── 4a729815cf7a0f3947cdf502e425da1b2392d6b8 │ │ │ ├── 4a7e2f54a225b7edfc7761d52940b39a3702b9d8 │ │ │ ├── 4a8d82dfb1750aa99deb48b58f8c91a30cc703b0 │ │ │ ├── 4ab1d0f5d83d7343f225dc40c2a3a9940dbe3f7c │ │ │ ├── 4ab5fb6756c937560dc91ad579231800bcb605f0 │ │ │ ├── 4ab75e6d0cbfec5617026ca0e5622cb4be8d69ea │ │ │ ├── 4aef881f37b09a5f41876628452dac08c70a5c3e │ │ │ ├── 4af1e59e48ecbb8bcf5f8c2a739ffe2d47054b4a │ │ │ ├── 4b22e5ee8f595d1440ed41006d8e611da06d0c13 │ │ │ ├── 4b537d79f1a6255185126b99325e3917dfdc7885 │ │ │ ├── 4b57985dbb3b797fd0788cfb9513abc07ddad003 │ │ │ ├── 4b72ce01f999a32aedc950dd1804a8795ff98723 │ │ │ ├── 4b7e7a47d519d00fb5bb9332b6fb49586a4134f8 │ │ │ ├── 4b8ea927af2611b4cf7fbab90c9f8ffb8bea3ab2 │ │ │ ├── 4ba2921581f7a3560b6ec87297653fb165ccf969 │ │ │ ├── 4ba8a95b0f39aae1daf6e664542420657da72fa0 │ │ │ ├── 4be8d76134fd3aa72fd3ecc702e88a4530fcab53 │ │ │ ├── 4c0186fb62257335535a95ddfc34807b1f836154 │ │ │ ├── 4c0a1b11b6e6b7691c115aa09cd92e8ee09a5076 │ │ │ ├── 4c117e356638d628e5b841bc413e67c8bbf10384 │ │ │ ├── 4c2d2d7bdc708a582093d11d189f7addae41c5b4 │ │ │ ├── 4c66ad58c30b6404b73490df6a7aabdb4eb995b2 │ │ │ ├── 4c749139f91d4268578b998b4fc4742cfa968495 │ │ │ ├── 4c9126df811790be522891686bd1fcd0a7fae560 │ │ │ ├── 4cafaf85ab316a592878f9e83a2be01cfcdf738f │ │ │ ├── 4cb7d23ad1e01a5e42d3c8d927936db03801ab95 │ │ │ ├── 4cff2a8e93a415e0cd8f16313427db2dceea582a │ │ │ ├── 4d21f89d57587583f18ad029ffd268e08c6deaed │ │ │ ├── 4d2c30084bbdec620ff06379849a52ea2e10b97f │ │ │ ├── 4d72ed31959a5c8b48c6c9de682cb5364bf0cafe │ │ │ ├── 4d9a093d9de04fcd9c74eeb3fb252b4f762f048e │ │ │ ├── 4db56aa4ef26d2fbb9c74967c01012f86fb5c60e │ │ │ ├── 4dd64e2309c3e9efee2d5404d847b644329d1f7f │ │ │ ├── 4df3d74d147d4bb7144799be7f96196f44def06d │ │ │ ├── 4e1c650230dc5d5f622303dbdb697b39acc5953d │ │ │ ├── 4e27213b2fb3cbd2c324c9d967eb6837151c512b │ │ │ ├── 4e442bf704b5166ed40da217a4f0a6103e117487 │ │ │ ├── 4e6bb871c5b2e524530d3675221cf34b2e598538 │ │ │ ├── 4e7f6d1d5ff623f2b978feb61b0905320a14cea2 │ │ │ ├── 4e8673f1a272e7a4846b2b13fd4d6d699de0dd4d │ │ │ ├── 4e8dce29e5e8dce89954f8535e95a66c4dec52d0 │ │ │ ├── 4e98f79b12c1bcc786816c990038e187b1881a2b │ │ │ ├── 4ebc10c30a1a1250dc40fd49051eb8cadd3eb677 │ │ │ ├── 4ed19b212daaac7d9ddf8fbed04bd645b3540c87 │ │ │ ├── 4ed948d6df09636962a55dc16fa8141b57caf0a8 │ │ │ ├── 4f01eb0e5c5b453e93d7259acca78110e06e0cdc │ │ │ ├── 4f043f492b006187a12d4a27a2fb711e089c21cb │ │ │ ├── 4f31274445bc35aaf35c1fc3838142b83f4e4dbb │ │ │ ├── 4f3b0d3de5e5a892c662d05f7df9b836b5083f4e │ │ │ ├── 4f3eb1205832e452025bc7463ab84f005ccd56a6 │ │ │ ├── 4f444cefd89a49cf66c69836b968e18c893e6243 │ │ │ ├── 4f4de778bdec3be4e7cc1f875680330eb9edda65 │ │ │ ├── 4f54816eeaa1958560b3411df01fd36e2cc3cf78 │ │ │ ├── 4f5d2d6eb42d852d85a2d40419830ff372017208 │ │ │ ├── 4f692f08e2284094269303792599c3ca996925a1 │ │ │ ├── 4f967edf0f22d51ce89c007d5351844488bfc1d4 │ │ │ ├── 4f9df26c7948631ce06cb7292bcc481337bff811 │ │ │ ├── 4faee5238fb7a4ab5d716bcfb441ef4b0ab3f888 │ │ │ ├── 4fc70db2882c50f92cbf554605f20aa8afdc9e7b │ │ │ ├── 4fd09ff1c3fd39676f5029f8a82082c4a788cbe7 │ │ │ ├── 4fd67112498e9041d549dca8902b4b18f4151e0a │ │ │ ├── 4fdbb01ee1c89fea2c908ade5230cbf49b493184 │ │ │ ├── 4fe78456cf82ee1f4f6bf880baf672a53376c62d │ │ │ ├── 4fe9d51c1a4a51db63ace4b7593bf4d0179da70e │ │ │ ├── 5008a5b791ae73ec29ac0e451b2193e921d7d91e │ │ │ ├── 50197b1f963b6c70cf02494a68b83252169b58f8 │ │ │ ├── 501c6aa901d9b79489250b1e7c008dad90b998ba │ │ │ ├── 501cdfc8b8bfd47787c30328084cb44010d48a2a │ │ │ ├── 5020bfad68bbf3d62a9901f11d582b9367ff01a8 │ │ │ ├── 5027b63206364f920f33ae41d244998d60e6d000 │ │ │ ├── 502ba5490df10d7b64842c917be0cc8dce168153 │ │ │ ├── 5040561743c74062906a64802db725e7cb87b572 │ │ │ ├── 5047a7a4c5f22dc492d73a6de284a0603fc06171 │ │ │ ├── 50701ea0af2da8b084ea4a3566db2cedf8dcc2b9 │ │ │ ├── 50765c36b2c5b67d14ed6d3f1006bcac492b9d7e │ │ │ ├── 50ade4cb2bfd78d63959c0c196702463020ec1a7 │ │ │ ├── 50e97f4dc4e78ccd7491b23a05fec77e705d6d17 │ │ │ ├── 512819dc5f866c4c52a96393d1dc161a298b58cf │ │ │ ├── 5134a98d252e038c84c184e2a60b3ab15541c32f │ │ │ ├── 513b5b1cd7ae4a18b0684e98b8bea2445f0f267c │ │ │ ├── 5145a2f823d50829addf9a923816226e49b73772 │ │ │ ├── 51585e660838f7655a9d3f8e62673ed896abc1b1 │ │ │ ├── 5159ef1765261a6a8967fe22b91be23bc4f7c672 │ │ │ ├── 516e8f247c632cc97a34b088b9b9c5522f6b4b7b │ │ │ ├── 51902d7c0dc3e60282faf7c3bed70ad3588b79cc │ │ │ ├── 51cb6bd8e208996ef5816ab2e4a5f0a4392acd9f │ │ │ ├── 51d22c9e318035b292b06c7e92cff7a7dcd2ef46 │ │ │ ├── 51df77e1f5047cc73d62f6a82b06c76b2f2dfcf2 │ │ │ ├── 51f4a12afbc5c09d84488a09c1ec4fad2f8ad55b │ │ │ ├── 5201220ebf5a752ed230ba1c4660d6768ea0ab37 │ │ │ ├── 52406f743dd8cf468c8739e0e49a5e8c2abe890d │ │ │ ├── 524a8fbae511284a4b3feffd7e69391eebfe5fe3 │ │ │ ├── 525afb4266fbfcb9a9457044ffa429e6345aca74 │ │ │ ├── 526b41de4d7b2b6cca5b8cca2aff4e05e1edd180 │ │ │ ├── 528808e08755d1c4badf200ea1e46b471e697367 │ │ │ ├── 5292dd4bbfc4ed134ecca359a50042487bdab8de │ │ │ ├── 529e15d7495022b3928ad252f217ff7066f4a8c4 │ │ │ ├── 529e417f9521111e7e2b214bbe3a009fb241e0e3 │ │ │ ├── 52a46ce5d115709464d927bd868cb66e64d5d890 │ │ │ ├── 52b71f15e64724663db04868b953a0dd6f8ab01a │ │ │ ├── 52c7e56d194272214280372b7dbacf979b86a714 │ │ │ ├── 52da571031bbcc150454dd6be63a21c6a2dca5e5 │ │ │ ├── 53045f62216e6dd1d7b2d1c05dbda813f59f4d38 │ │ │ ├── 53090ff0e10b029e37a0eab690a757a5f4c346ea │ │ │ ├── 530e0b9098674994a45495cf1eb8c3fd36b04ef3 │ │ │ ├── 53123aee1da68a8b9619edd5140ab5c6aae10886 │ │ │ ├── 53234e0beefd772757294c48658a6fb1b632e5f3 │ │ │ ├── 5349c13d7b8dd8f692718b4ef221a21825fb04f3 │ │ │ ├── 5366b2cab843c6f4979214e27b561d35321bd2a6 │ │ │ ├── 5379718fd6733c3194547aea3041303f46159862 │ │ │ ├── 5394689c5e237d677fa75daa48d897e73a858ecf │ │ │ ├── 539798847b99eee00985bc1951275a98b55dd7fd │ │ │ ├── 53a808e42f754a6b97d63d9648f1e9a70ef36421 │ │ │ ├── 53c007e4c811059c16e10ba22c2b8c0f4ce3d99d │ │ │ ├── 53c3edf3601218d001c1e5074a2e608ca903fa25 │ │ │ ├── 53c8c5901bf8077df2161336a0fc9a5f774e1a5d │ │ │ ├── 53d0cafdef4e74e058c9073bbd755b723f71207d │ │ │ ├── 53dc16200f550b0ebabb6c5c132ae4191e1a1482 │ │ │ ├── 53f7ba7985ea8688080ed30b57d08c4ab91d4a7c │ │ │ ├── 53fd1406ce1667cf7d7de3b444b90660d76871fb │ │ │ ├── 540c6dd899720dbbc04e0f316f56549b4c1ea925 │ │ │ ├── 542c02db48e5517905eab16fd96de2d76702fe3a │ │ │ ├── 54305f14909100e1757674ae16a759d855c4a647 │ │ │ ├── 5445a326ed6ffd6f95dc9cb3c9514a0e53f4868a │ │ │ ├── 545537c377201418fedef933281d2dcbea90a159 │ │ │ ├── 547539d40d65ab39026f065bc9152d96c7c4ad43 │ │ │ ├── 54ab5c42625d4869197c04f218c443750527c92e │ │ │ ├── 54b4f9842dadbaeb2ac90b0f6d8177f76ce3f9a1 │ │ │ ├── 54b9966d625700d7ab8b6fb6e1c3e019b5a09f6c │ │ │ ├── 54bb653bb1662d8b2730bde1e4a255606fea193d │ │ │ ├── 54c4a1f796d9ff3acf74d30faba1654e46cb8e87 │ │ │ ├── 54db865605c4886df424d455f6674d7c9f904922 │ │ │ ├── 54eef01ce1e7ec1e6b58bb1a7e192b0e5d3a98e8 │ │ │ ├── 54fe044e4c6d4dfed594e15518f9550df3910bc9 │ │ │ ├── 55222bbf499234ced0243f0c54a06a8e01ee78e8 │ │ │ ├── 55296a40c4a4eec0b8b959e6e4af29fbf647774b │ │ │ ├── 554254ae450e17abd46d3c290600e3620f888246 │ │ │ ├── 554ee85d50ac67df97fb01a2eb533f4a62a41c9f │ │ │ ├── 555fcf75ef7ac731ace1cd81886b6cc1b013e911 │ │ │ ├── 555fe6827560beb47e96016c2aae78850a4e345c │ │ │ ├── 556a65730f4092db6fd77c12b631d10117d47033 │ │ │ ├── 556db9cb87763f9c127e87edfb88a8e8443c00d6 │ │ │ ├── 5581fa4307ec84b987cdfaee72db964e4a304876 │ │ │ ├── 55944a2b94a2ca58cff331e3ef254a2869f5fb50 │ │ │ ├── 55b0896604f6a6b38c17cf95f8c053e19d26090c │ │ │ ├── 55c61e7a6bf6a7b27176d90e85c792e38fa47d95 │ │ │ ├── 55c9ce0b7ccbe8ff676abebe7761bee66f38e3bc │ │ │ ├── 55cabf94b48b77fc7b0a87efd62377c6a44cfd3d │ │ │ ├── 55db8d546fc7e337dd899c328c82a60b6102a7b5 │ │ │ ├── 55f99e2d68ee85b75133f78cb948a5b7466cb4ea │ │ │ ├── 55faab0c69903138a86beca8e6ebc3e7a2010e0b │ │ │ ├── 55fc38b7d593fc118d407fcbd2ed49e3ea890734 │ │ │ ├── 56397a2ccd392deb6d3ed52e0a065fdde579e9d6 │ │ │ ├── 56567e4be5618770bb97f61b1487c7d47cf8192c │ │ │ ├── 5658a8d8fb388e7c7e5f7c7fc8630d3de961b676 │ │ │ ├── 5687a5e9c47486c4d2f24f74e09c95a9b9139145 │ │ │ ├── 56c988fc520dc9a5bafa28ad83eb0e972fd70567 │ │ │ ├── 56cc448ba82bed7220a831c4b05eabed0406386b │ │ │ ├── 56ed4007baeecebd4a8905063055ace47704a0dc │ │ │ ├── 56ff467c9c6b5e3079baa559955ba107d89d77fc │ │ │ ├── 570fb69de8afa341b54dd79455b6d21085c0334f │ │ │ ├── 570fc65b0c81c1473fc82b8545f5ae6efeb839ff │ │ │ ├── 57267f8aca1eeab5fdc28ec5f2cdbd6ce0d150ae │ │ │ ├── 572c410d27df3156ea85e726a966af51c9cadf8f │ │ │ ├── 576476370370b5501ea6a61ac033110ea83ed7c6 │ │ │ ├── 57731bef67046b96aa1a3f92ffbb41851e7b3353 │ │ │ ├── 5777068b6f7170fa6a505e9144aa3f6fc8625b74 │ │ │ ├── 578701a27b2e9321384f3e516f48fe5d2ebfad6d │ │ │ ├── 57ba07044f687929674d01d0c501e408072f02f8 │ │ │ ├── 57e2edb6bce9815f7e92a1cacf2c42a1d8a5ed21 │ │ │ ├── 580742d9b18b0603cb29360f8e7cbfef479c00c6 │ │ │ ├── 5876822a1e4504b3dcd7a3ddd10ca0dafc4c9ce7 │ │ │ ├── 58d98ae03e7b63b61749dae272899a7f41a89c30 │ │ │ ├── 58dd5844bf68fb5f47e929bf24c7d8dc2cab5791 │ │ │ ├── 58e9cc8b18e2ee0f4ef6cfa6222d9ba9c4e6999e │ │ │ ├── 58f607b447f90cc1f1f8626ebec53c5173658a3b │ │ │ ├── 58fb9dddb99befb27e93f61cc7346e2e320d4124 │ │ │ ├── 5901e4b94bc2da63a3099505728106aad680aaf1 │ │ │ ├── 59170b1799ffe9d1e085f2b8c38cf655ca14f1bb │ │ │ ├── 592e17797674340048f2ec49023bde0febe810f4 │ │ │ ├── 5930d2e1ddc70c728b1f219bfa14e4053fe56dbc │ │ │ ├── 59357c2c93a40183682393a898e6b58d6e81cb14 │ │ │ ├── 5951e8f0a0cafab1db40426b854148481b762ce2 │ │ │ ├── 595901e13730319ffed24982bd4ea8c12e89bc96 │ │ │ ├── 597a6a03965d41f1179d6a45268ac32531a9c209 │ │ │ ├── 5981777edd562076958d2a1e4c80225a425eb08e │ │ │ ├── 598b73c14cf25c235e0cc5c5a3bf6a5add3b0b66 │ │ │ ├── 5991f803b4df614fde19c2f5742b860c1a14d33c │ │ │ ├── 59a01c32eca07dea482bf25537b7d52b7bc5aaca │ │ │ ├── 59aa7a8b1146af0061b9b9478ffb499b5e7f3229 │ │ │ ├── 59b9a0e1dfe394504f08eae69abd47bfab092572 │ │ │ ├── 5a198317abb136510b17c59de5eaa7c880152f8b │ │ │ ├── 5a53b6c3fb03892958b022df8a6e0a4cd3d8e51c │ │ │ ├── 5a5abab97631cffda0f11fd3ecd87d86dc325f8f │ │ │ ├── 5a5d03ff40bbb94cac9b06c3d47e693d8db5af67 │ │ │ ├── 5a5efe209bb7d1e1b0085b1515836fcb2144c5f7 │ │ │ ├── 5a81cfc3ec9bfa6d49dcb19b411b6a4b6043df15 │ │ │ ├── 5a9d9ae70e2df49baefc66227ea1c1604902038d │ │ │ ├── 5a9f746ca2d826a621e61152c995893027ae3dff │ │ │ ├── 5b000b738705bfd4a6198d22129f7e9f2ccf1708 │ │ │ ├── 5b08bfcfc4f7317c5e45fbc3a683064ae85a3794 │ │ │ ├── 5b33a7895ef81de11965a513bcadc8ee53993d21 │ │ │ ├── 5b718764a0b56ae1705be7dcf35a2c639fbee6f4 │ │ │ ├── 5b72a3d1797578b12f235ecdfb8305d928514960 │ │ │ ├── 5b831888d2299bcbbe9bb60f6812a461f2da8720 │ │ │ ├── 5b89dad22b6b9ad7d97be2de400eaaa8ab2a03e9 │ │ │ ├── 5b9296392fbbb89f20c46a8276795c3b237a921b │ │ │ ├── 5b9476567b263e9cd4c8455b1383c48f559cdd5c │ │ │ ├── 5b95416a6aeb72fb134a6149c2103c7b4b8af54a │ │ │ ├── 5bc0284515461bcb5e3ebafccc633649bb1ec2fd │ │ │ ├── 5bdb30e6f918889383a02c0269f0e346fb129035 │ │ │ ├── 5be7de136c7e263729c299d1617ae86dd468f91d │ │ │ ├── 5c2aec0e280cc6dccb0aa9c3d4c5354a71c3d8e8 │ │ │ ├── 5c2cccde1ba71ca24440e1be3fe94d8b2abc9ba0 │ │ │ ├── 5c414ad191f1a4f17701285f026d3be386795f46 │ │ │ ├── 5c4b2bd5199eaae65eb1b50ff2282715f285525d │ │ │ ├── 5c4e02eac5ec6bfd2aacdf25eb5606e7f1f8d245 │ │ │ ├── 5c58efa0b606fd3a9f5c4149f78312e37884f070 │ │ │ ├── 5c7526188d4edba67f479317b2da9ebd815e25d8 │ │ │ ├── 5c82173fb5f60e67f6c570773d0e7ca501b2ef2a │ │ │ ├── 5cb8c6d32062773a2963b39820bf5c9c9d4d14f4 │ │ │ ├── 5ccd74670aa8f9270b7b6d1ec35f26366e24af92 │ │ │ ├── 5ccf6b63be9a26dc12ed0d8d9fcf8f9bd4d32aae │ │ │ ├── 5cd441bea952394300fbb2b175630e939f70734a │ │ │ ├── 5cd9d11e72f21213a0cd5e3b000d85ffc71a267a │ │ │ ├── 5cf79ca7fb6c27351843e8929c62c99f6d116b3e │ │ │ ├── 5d460d2d593010e8b116c549316144cec213da3d │ │ │ ├── 5d547488bdc33c4ba9f4eb64d9e510fe10c43b64 │ │ │ ├── 5d5955b5c12cb917cf3b4b20cef145f61555cebb │ │ │ ├── 5d5d395b7d0d39e7e061299a0ac6d887b277e7f6 │ │ │ ├── 5d67205500c9fd9a4b6a49b76f5ba2c4bc80f718 │ │ │ ├── 5d979fc0c97f4b30b22b3b449446ef2dad2f94fd │ │ │ ├── 5da06db4c347f603cf5309c3456c26cc7ff974ad │ │ │ ├── 5dccc42ff618aec2747273439401c4901ac182b8 │ │ │ ├── 5e1b24b8be80cb985494cc5e6aad6e0169f302a9 │ │ │ ├── 5e29c824e31a38432a78e51cb6163effbc1b7632 │ │ │ ├── 5e5cf1d19425ce321d71cf332626bab6bf9e5c44 │ │ │ ├── 5e7998196110af78479912905025c638163deb00 │ │ │ ├── 5ec7eb46ae8e0891018b9848bc2341e3ef6ee62c │ │ │ ├── 5ef0bcd2fc8dc128e8583e90e1d3848ad698670d │ │ │ ├── 5f065a6b9d7bf300aef6fc736b6256c582fa075b │ │ │ ├── 5f06fb75a8156e71669ca65d0d928c7effc223ff │ │ │ ├── 5f148693c5a6505500494101603fb4754464594f │ │ │ ├── 5f1c481f15b7e89e16871d58cd5784dc2fbfc8f0 │ │ │ ├── 5f33c80c85ea079ca0e803f9157053bb5cc26ce9 │ │ │ ├── 5f49d9e42303e9fd5d3b3beb8b4f91d1d295e920 │ │ │ ├── 5f617801a71e54b50b37fa8715f4acb9c710bc1d │ │ │ ├── 5fae0f3d4ccf63a68fa6fc6ed2f605c153bc568e │ │ │ ├── 5fd0ea816791d944d140a7f5a132e628c4df41cf │ │ │ ├── 5fd72300746767ed3942898b20e747b5e468bf3f │ │ │ ├── 600a49efd1ef275dd0d15886970d34f50ceb2cb5 │ │ │ ├── 600aee354a6065175892343ec14dc1eced5c33d7 │ │ │ ├── 60157ba4a7cd240aad985554d23dafcb6b99be47 │ │ │ ├── 601bf2a7aa8b6c3a9adef4933fc515d494f4a95c │ │ │ ├── 6030146df9ff31d1d977c2672cfc3792ad81865d │ │ │ ├── 60350336430acbd30d2f4a7afd671e1a676249b8 │ │ │ ├── 604aa389e1cdb7844558781a66e69bb80e5f7ed4 │ │ │ ├── 6070c8050e46e845c5170ec25daefa937dbbdd11 │ │ │ ├── 608151513d665821b3914810e70e9c1f957da187 │ │ │ ├── 60a40b71e2980d806f6e3f1f604e1c25d8d684a9 │ │ │ ├── 60c433ddebf0bd6ec3f44d608946aed9e843587f │ │ │ ├── 616a7fdb9927448c5c9e34f94d4f6d784f55ccf8 │ │ │ ├── 617d47ec32a898ac6e2b5bdd9b8e643408054596 │ │ │ ├── 61ac7af8ebd0ac559618d67f23d159b57dce5577 │ │ │ ├── 61ad3f5b692481700ab46b1c77ecf7e1590f4f72 │ │ │ ├── 61ad53ecbb9e93b9d193624ee3222dd39af8c8a4 │ │ │ ├── 61af1bfa70f27db871da9994cee2a1fa6dbfe915 │ │ │ ├── 61cb3c37ef29bf5abdbf60157dd9334ea8578716 │ │ │ ├── 61cca434775b13627deda2ffc7b421cc834c16ee │ │ │ ├── 61cd2f257a7e5a750b8f03f5aac0ffb2badc3aef │ │ │ ├── 61dfcc18f9bbed9da1c93970d11da1509777d17c │ │ │ ├── 622454dc9deabc8438f95f3e6280211c37369c04 │ │ │ ├── 626dec99c8f47a95e864b2a31b4ca6b916ee594c │ │ │ ├── 629399f535a4b780a7126fd274938c9e1bdd9b94 │ │ │ ├── 629683fa749137e2dfd6e82633d304ea6c124ce3 │ │ │ ├── 62c572a03d69a6b40d25947abae19bf6ce5eb385 │ │ │ ├── 62d04745f9fcb76848b12153a162a268f14abeca │ │ │ ├── 62f4696a4d80fd4c0dc13ef75f8bacef6743b8d7 │ │ │ ├── 62f8cb127c31b1882150c0c8effbd39c09119e5f │ │ │ ├── 630f756a29287a797ffb5586566bc1d25758573d │ │ │ ├── 63167cb8ba3874badf57f0e855e7f02478cfd49f │ │ │ ├── 6316bbbc6a41808b00262eab5f5262fcfa97066b │ │ │ ├── 63254af008fbdb6301cc07058a867abb97610c66 │ │ │ ├── 633faf2de8dd00d4d8b3bbdda4d9f2125613a89d │ │ │ ├── 63428d34338ada0748fdd95dc5f6db204de7543a │ │ │ ├── 634458fa7be2820b5e56c8ae2c193b953af0ad40 │ │ │ ├── 6360d46053a73eb3d4ae1cc875f022d5d461f571 │ │ │ ├── 636131ac174bfe63b118e739bb030a2fae2ae0ed │ │ │ ├── 6391af63a3bab91b1f963e133bbb54d1ec7814cb │ │ │ ├── 639afaf27cd09001a498697b15842c3394f9535d │ │ │ ├── 63b0cec5acbe499ece5bd821c8af36dd0de95819 │ │ │ ├── 63b754b26183ec079fd02af865aea1d5c49d93cb │ │ │ ├── 63c6cb5ef992299a9604582c39c7f956c65860b3 │ │ │ ├── 63c8bbd564a4a1648edf9f05d80a6b089c40883c │ │ │ ├── 63cc94dee9c6256ddfe004eb9fcabb932627fcce │ │ │ ├── 63e781018cd701d6d445dc7c4ea28f9a53de825f │ │ │ ├── 642e1fbd4f64d1ba035193a0100aefc8d436121a │ │ │ ├── 642f40f85c3e92c672ec038a2e238351c6c24178 │ │ │ ├── 643386ed0f556a2227416f5b32e310b70a2cf743 │ │ │ ├── 643f751fa11ea6d366ace6319feda720f2e8accd │ │ │ ├── 64537ec43a7b2b59f2b936c7247b94e44e1bb551 │ │ │ ├── 648fef1a9a568a6e98c2cb836193a18ec11b60ce │ │ │ ├── 64b6416da57fa74cb892f8728aac8bc6064ac5dc │ │ │ ├── 64c1ab90001da13422d892838a22208f71109eb2 │ │ │ ├── 64c86a5fba96a19af3d7f98cb11533d79ff4433f │ │ │ ├── 64c9c1019b362e31675420967685e3e5e1d92f06 │ │ │ ├── 64e713b456a3f23cd86eeb23d796639b7c85d2b6 │ │ │ ├── 650b0fcd68979a929ceb682e9024fb7beb57c2b1 │ │ │ ├── 652f7178db85a30195aec38e5bed56f8d492b18c │ │ │ ├── 6536f2a8bf497dc4fb07e6344571b041ddf3e9ce │ │ │ ├── 6552bfcd6579a934948b7068b4c551a0117ad0f9 │ │ │ ├── 657e868eb96e89c02af5430fd6fd6b371011ad19 │ │ │ ├── 65883b58c6b3dd90d25b39f5ccc47be52f17c9fc │ │ │ ├── 658ae5cbb0d9d2acbdf007a1d56b7a8d343343c5 │ │ │ ├── 659a2dd2fa1b9d801f3241e5ff84637ce06ccb77 │ │ │ ├── 65a933e1d1978ba3bd2f831c22458a755de9ba53 │ │ │ ├── 65b54fb91b4a1cb8c833485f4d132f6e676256e0 │ │ │ ├── 65b5fce87c9d43529bc25317899f3d88952342f0 │ │ │ ├── 65e72ac1ffd20fc948eb9fd0715334a200044fb6 │ │ │ ├── 65f7ef2d10a182c5af3e4c60b4f23f13770b1d2f │ │ │ ├── 660b8322660c10bb3072efbf02a01b028869f3ed │ │ │ ├── 660ef1c053328676703178f6c1f1a9eab0eba34d │ │ │ ├── 66252c3d296124f1a894a2bef80eb0b8d2780c58 │ │ │ ├── 6652466b4852d5b5fdaaa69e10880f1a3b76c3fa │ │ │ ├── 665eb41953197df4c60f261f2844052bbd0c48b6 │ │ │ ├── 66726b80715835e1ff8fad96f3c76a0309586a88 │ │ │ ├── 6699c94d11593280e700614b550ad835b0025476 │ │ │ ├── 669ff69c2c67c7765c32e86e0eda8fcf04bcdbdd │ │ │ ├── 66bbe506485ecc1f5f29905e93bbc326b119a9db │ │ │ ├── 66cb36473c4a75d094b0c109710f2456a52e3ac0 │ │ │ ├── 66e881b64f9e9007cc27f9ae6ea1d9c09b7ff1dd │ │ │ ├── 66fd2e2f42f7b15c03f46c8f5852fc2b2a1288d4 │ │ │ ├── 6723a627907cb1d91034b75d6a69d055a9d2a9b2 │ │ │ ├── 674c86a431b193721af73dfdf07aeef65a7ef508 │ │ │ ├── 674e2feab074ca0240a6ca55826b14e434793461 │ │ │ ├── 6766fbe9f961609fc3c2e2dbb922ddf1dc771d96 │ │ │ ├── 677c2fb0bd66dbf157aed281b05b92ad2c197c37 │ │ │ ├── 6790425ac6ab89b1bf9e69e61d0a23def2470c84 │ │ │ ├── 679748203674073239d2e5a0f7f9da26bc60feb9 │ │ │ ├── 67cfc5cf8010d9b1c152301eae06d149589112ba │ │ │ ├── 67f26334e58a0356529496d89738359b7a8dd136 │ │ │ ├── 68052b4483af39b51b45980874124e3793c72420 │ │ │ ├── 680f37fd69b7d65b2bea1f6968d0d19d60d93bb6 │ │ │ ├── 682b9ef29382e2d77b5242e0860693527c825702 │ │ │ ├── 68560332b36281ab2ef6e177361019a087666119 │ │ │ ├── 685bad2808b9ebb6dd3bebf554aba2916e169a21 │ │ │ ├── 685c94cdfdc42c71493f0fbf86f6cc75a2bfe7f5 │ │ │ ├── 6864a32b8e40345c0b76999afe5f1c070d474908 │ │ │ ├── 6864d1927bc63a92a60460a41b2a104d48d49e0a │ │ │ ├── 687590a8d9eb9f62d77022572d103d4c5adc9867 │ │ │ ├── 687648741dc59ceab592c14d35fa96ac27ef98d1 │ │ │ ├── 6890f89ae85a96d458a2e92ae84db78ff5a3d8e4 │ │ │ ├── 6893c34edde19b9be594417a3321f7522c83713a │ │ │ ├── 68ae4d6748f33706497031526da5fa76f0c923a1 │ │ │ ├── 68b62ec5b8680759a52e8934526dbf400162c104 │ │ │ ├── 68c6c0d42504385245c61282657b3afb267a068a │ │ │ ├── 68ebe4901e5b73c0d6c376b14ab93cb27b6b9b29 │ │ │ ├── 68f2022142d8ce6c1188c67a635ce455d70e8668 │ │ │ ├── 68f3ade32553e6641d33ffec7c4bbbe70c966a75 │ │ │ ├── 692178574c30ecc0fe297e53225c7fe6b7047923 │ │ │ ├── 692a5e26fd84eb7c487336a8ad5a27bbf550d3e5 │ │ │ ├── 693b4e80b442d5871a480b72fc7f154489eada7b │ │ │ ├── 693f1072f030299b192b97d19cba8ff9e045ceba │ │ │ ├── 696eb3cf37f866313a3dbf40b4af77d45f827d98 │ │ │ ├── 69763ca3d19be4c3d360ac96f990730c211450f4 │ │ │ ├── 6977dc4cb03457ddcfe3fb5e4ebd32c7a60a4f4e │ │ │ ├── 697a7f07151aad714b88aad13a439841eb1d849b │ │ │ ├── 69c1c268224ffcce5d6dc13b49962a3c8887c2ba │ │ │ ├── 69d24f5639ca8a5eaf58924722cc313b9936c330 │ │ │ ├── 69f36a1e1c567e1d5e44edc58c355abb92e23f68 │ │ │ ├── 6a35130e1e9674f6d1c241fd478fe85332fbdbb1 │ │ │ ├── 6a37620db708370995281cf6c46512cd60efeda8 │ │ │ ├── 6a8e8effd233033afabfdaf9d971d772b2bf9ecd │ │ │ ├── 6abb0ece7e16ec849987f8c8acf3aee7013ec5de │ │ │ ├── 6addba1d7123769bf9727a6a4106110126f36086 │ │ │ ├── 6aff050ffc62f58100aca0e5b1839f097fe65155 │ │ │ ├── 6aff0519662314531494b8b3319e2768ebd40a35 │ │ │ ├── 6b14353e2b7d7788062623a8ab274c36f8e8bf3b │ │ │ ├── 6b611309b991acee95b55b4b19539f65ceccf76b │ │ │ ├── 6b861044122a6b081803e3a99f47b40277743d06 │ │ │ ├── 6b8790739dcd1f8d3ef41a03c6508717d78feb52 │ │ │ ├── 6ba407f0a422507bed18c1d5b52f1f550c278fcb │ │ │ ├── 6bc93c9d2144506aeb9dbbe41a5b4a095f8fe9cb │ │ │ ├── 6bde125fedeb05208eb8991bab6ad0713a60d9e4 │ │ │ ├── 6be0d8042ea3f474de849bc8205c65b017a3d587 │ │ │ ├── 6c1bef32f6ca0cfaee1705746902336e4fd67e96 │ │ │ ├── 6c3db2c6ab0b6b80838387b923869561f9e1cf11 │ │ │ ├── 6c7e6cdda9913347f0ba8eed8f914941cec5b2c1 │ │ │ ├── 6c8a1b2ea553e6dfa5f653afeeb135465732aa6e │ │ │ ├── 6c8acc451d0c73e74ad6918585d0c8776498affd │ │ │ ├── 6ca4ca112dc6f3b82a4ee1dcb539f5412b61802e │ │ │ ├── 6ca7072324326a43f42b641dd4cc2d785bfbb7d6 │ │ │ ├── 6cbefe4b22649c02c818e52d3142c768ae99b9eb │ │ │ ├── 6cdb87bebca9057c621affd2eddfbe726630b1c6 │ │ │ ├── 6ceffd0098b1fadf6f95341e39b6b1486b6e2dab │ │ │ ├── 6d1ad01f9d4765e28554608aaaaf7f86d7fee48a │ │ │ ├── 6d2c53b612c9e3931c251808123e215918c34b60 │ │ │ ├── 6d6cb592531f25b7c0a1a607342e2c3dcf35ac1f │ │ │ ├── 6d776b8dcea06b627feb06e8e07e6455f48086d2 │ │ │ ├── 6d807824d43b2e677fee210fcdda1e52cabbbbc5 │ │ │ ├── 6d874714ddd3706018c9051c55abbcf1210b4643 │ │ │ ├── 6d9b8efdf33eb396820e03892263d3b784e5dcf5 │ │ │ ├── 6de00eee762e4ed839eb40fe1f0e25de0071e584 │ │ │ ├── 6e0058983c03e5e6a363e64deb28a252b20617c1 │ │ │ ├── 6e20107c698b7f36b9163a7db7382e068caca218 │ │ │ ├── 6e41239fdb2bae4970f0a9787e683e94dcfb1760 │ │ │ ├── 6e59dc43f59b064311d89a689dd58f9a905d10e3 │ │ │ ├── 6e85ec4ec7f9980d8de6d6892d1415072155eb5f │ │ │ ├── 6e99af85369d8643f1c91d6e46c038af402d368c │ │ │ ├── 6eb985be69c6686dbcfaa0cfeba04cbc68dd5298 │ │ │ ├── 6f3e92cd7c0bd1c759a5d1ec589fa593028c2f27 │ │ │ ├── 6f52449eba2cea1fa19799e7de8f931e69c70cdb │ │ │ ├── 6f56fca6cc1c01fee921e3ebec30d918b7e84af1 │ │ │ ├── 6f6d754696a56d367c058bd6cef710ac92a36c4d │ │ │ ├── 6f7390dad86b309a8464acc781b7a22cdc6164de │ │ │ ├── 6f775290762b949c8416b8db72a80fd4f625aeeb │ │ │ ├── 6f8393bbb9d02857705efc61028b43ee819ae6ef │ │ │ ├── 6f8e2a9cd5725921d637323d42b65faaa53b2d0c │ │ │ ├── 6f9c6ccc8504bc417cff64152e5d55f2da6384f6 │ │ │ ├── 6fae620fa980b4c2193b8d1ca489fecb771da643 │ │ │ ├── 6fd7c011c1e087678c2fc502f6049d5a1610b285 │ │ │ ├── 6fda74aa278e18be569d89d76d2b7d189719fc9b │ │ │ ├── 6fe4cc6bb00f0db22fe4cf7e68170752bf9e1f7d │ │ │ ├── 6ff3146da9ac0acb6f0c208976dc39290b684b16 │ │ │ ├── 6ffb4a945d04f8b031049d6b6fa49f15f19568e5 │ │ │ ├── 70103c6bfa6033fc750d73a791d50375a1b86fea │ │ │ ├── 70294d4a0a0438dea998f982369933dacc66aacd │ │ │ ├── 708f0996354e7df20b2aef4b10bc9586dcaa5db0 │ │ │ ├── 70c7802de56e11939701cba269f74c5c54434e61 │ │ │ ├── 70cd3f4760a280eac2806e6373034a5e750cb013 │ │ │ ├── 70e123fe2099ae69883a84234ee7d2c67ffae902 │ │ │ ├── 70f98e7683065de833f78e968b12a17560c6d145 │ │ │ ├── 7125c24e3079aa7ecd8a075096657aa41cbf32aa │ │ │ ├── 712c593d655c49212ff38704eff4d5d68d14506d │ │ │ ├── 713565a78c4f0eefe92a042e831427511dd4f5b9 │ │ │ ├── 715cf3f1edec8508d34687cba9eb9735c4113fc8 │ │ │ ├── 716e9a2309a2d14f0b54d759df166270321962ca │ │ │ ├── 71807ffa82a2c8190651c69c857cb71bcb08e301 │ │ │ ├── 71a2de6544779c774612b1f87277375ae9792a62 │ │ │ ├── 71d2976410e52b3891d47b0bf5daf36223655072 │ │ │ ├── 71d3d5be815413f81a15e1f21d82fa46ce4eeab9 │ │ │ ├── 71ea7e6e573f89e2a23138bfbd547d888bdb7c55 │ │ │ ├── 71f13e97734a6166d08d71982621f3785ea5ae3d │ │ │ ├── 7217d80b5053a43d6fb6822470d12e76b42b2764 │ │ │ ├── 7222bfdff7231c2aa5afe88a9b8860e057c947b7 │ │ │ ├── 722914ef8c3dfacc1243877cf6bc0be5cc3eb6c2 │ │ │ ├── 7275e47aff6a2c0f8bacb56d065aaba591e02a30 │ │ │ ├── 72790cb9d6895411ac13e44b9be62c5cb05584e7 │ │ │ ├── 7282e73fa9d18fc99fa2f10c51211fe1079693fe │ │ │ ├── 72893e972bd42b8697f75e7ac80c8885bf7c3a45 │ │ │ ├── 728c6175ed68889cfe3f359471f509fd1da1623a │ │ │ ├── 729abe2b4cc9df53668a78ea8236ae421f3b5173 │ │ │ ├── 729bc90d92d1235d6d3bc4c56bfc5a7cb1532e39 │ │ │ ├── 72a19edf12311bc49d7e72f4ce0d25f68b5ba472 │ │ │ ├── 72b351e21f164a536ef913cda1b95716c0de23ce │ │ │ ├── 72b831f893332ad3733b0af04ea0e76cac65b5dc │ │ │ ├── 72bd024e4b285894458f234b460fcaf90e8445cb │ │ │ ├── 72de723051c80828a6318b2251cdaf29db2600f1 │ │ │ ├── 72e0280dc174679a75da3799cbb41ffe349f9f46 │ │ │ ├── 72f423c06f55b024fcd60e3acd20f596205615ab │ │ │ ├── 73319dedec7db18100aca1acbdf582d38ed80c64 │ │ │ ├── 733a381bc9e56cec2e4a856413e56d0bb7972662 │ │ │ ├── 734891576e6360feb0a79e5f6326f4a0f3310853 │ │ │ ├── 73617507f1dbe680e93caaef1d078ac92ad846ba │ │ │ ├── 739b15f40bb87a9e4f1a8399ce654d068bd0d30b │ │ │ ├── 739c724fbc1d946d981066a3f82cfb09a034ba1f │ │ │ ├── 73a2aaa511c3c79634f98183fed1aa515112c30c │ │ │ ├── 73ee1a7d0acd1f7e6a29e2cc9de52adf757c34f3 │ │ │ ├── 74033d1959e62921897648eae99b7576a518dcbb │ │ │ ├── 74068e2edea30ca07fc3d6536b7beb1e73610c5e │ │ │ ├── 74077dff1318da9fbe3c8ecbcf570fa2b161a310 │ │ │ ├── 742166e63d37f163f9bfa53c3d1ca1c432028519 │ │ │ ├── 742c9cda5fd595f2f4acc988670128b67aa2cce0 │ │ │ ├── 743bd395e890e120441210e9d92579d0c7fd94d9 │ │ │ ├── 74433925d2da6bb3c3edcc954a98eca9eeb57abd │ │ │ ├── 746569f919dd66a45ca13b1e18824a0afdb22d9e │ │ │ ├── 74685cb831119333da8b5a7c83e055eedbef944e │ │ │ ├── 7482f850ee397dd25bd1687e64b7eea626e9c608 │ │ │ ├── 748b5f0d6e2f9fa4665f7445654524ae50ffc8ad │ │ │ ├── 748ece6f6568749de6856f4e101f00d04a22d979 │ │ │ ├── 74965c4ae1074a7c5d80f0889dda62db64f0d7d3 │ │ │ ├── 74b0040c6bed65b152921df24d1d78125695306f │ │ │ ├── 74ba2f22626f43b6a2563b0cb35c620433682d40 │ │ │ ├── 74dba0abfcd70931e9e189f44c9fe76cb1cdbb0a │ │ │ ├── 74e0dd99e051486e796a28c6482f0b52f0af67a1 │ │ │ ├── 75255d425818aa4e45fa7a8ce30896b30e5f57bf │ │ │ ├── 75362838d1ed152f60dc3cb74924d167c1b0fd2b │ │ │ ├── 7559c841c04c474bc9ff45fe8504abb5d4e8f57d │ │ │ ├── 757adad4f7dd459070f4f1b1f4f4f2374a57ec6c │ │ │ ├── 75ed237efa308c478c8ee1faa516c94e45f17495 │ │ │ ├── 75f1856401af3c6957b627bba156ed076e49ef5a │ │ │ ├── 762487d62765bf58b6c712ce69edfc2a9d91f23c │ │ │ ├── 767dc9730435e95ff0446a5e08a10843c28b5e4d │ │ │ ├── 76967f9679742d07c45801b75cdb5ec88f3ea2e6 │ │ │ ├── 7697ccd8a0cbc267875cf87e7ce982f8dbffa82b │ │ │ ├── 769cf64713d5676b0d7823f406502b750f29f48a │ │ │ ├── 76adb95f40dd46b0cd442f82b7eb70ed237f1676 │ │ │ ├── 76ba7be2b975f49a68b47d255757883a4fe65358 │ │ │ ├── 76bc86d13bce32da92769372e37076c675520959 │ │ │ ├── 76c17c551bd5e5ae2efbb26f2e05d12c9c8181b3 │ │ │ ├── 76c565f5646ff08d8c740ffe4cf133d9c8a3fe65 │ │ │ ├── 76f5c55837a53eb0781baf11e0de07184a6d08ee │ │ │ ├── 76f83799d26fbfe8607158f4718d6f5cfdc8621b │ │ │ ├── 7705fd1f70110abbefb84b8bb3679338dc85008b │ │ │ ├── 7722142222386c62ee3cf0d244202e77b759f34b │ │ │ ├── 77258dc253bbfcab9ac3a990bda4f20592f9c651 │ │ │ ├── 7726ec0c41e3e97e7d617065e6504efb8f024cd4 │ │ │ ├── 773d0e073333f130bcff75d37d1111faaebee058 │ │ │ ├── 774784914f2077e1681344cb01340a934be26ba4 │ │ │ ├── 77907cfa0df9ad35b28a28dc974519599031d5b7 │ │ │ ├── 77a416c6802644089ebc937712578c64cd114e2e │ │ │ ├── 77b1d215fef8b044b5354a64c3541f96a5eed3ef │ │ │ ├── 77bc35d370a04908ca4a6126a011623e2b09442d │ │ │ ├── 77d0cc6e1223f82ea66b45b7eefc97601034b9bb │ │ │ ├── 77faf5783504d2bd51c625bcecb48b8f87e8e165 │ │ │ ├── 78251c5d9b329e36203639010c03798c0e1dcf20 │ │ │ ├── 78536c856a97d639ec3c9e87656c03a486180cb2 │ │ │ ├── 78a8516593c8bad79e4092b1b3fc0a850a266c4e │ │ │ ├── 78a85c295a5f5c62f56d7eba74225f31406a0b51 │ │ │ ├── 78aa0f27c839d5f0b6120545131237373c9ae941 │ │ │ ├── 78bb53d71409ce127d2a0ea2bb3fe8ab857c3db0 │ │ │ ├── 78f579fb1bbed4948a321bcad1a70116b995076e │ │ │ ├── 7929ee70089306f9173670db39ef247d71e6d01c │ │ │ ├── 79348dfc973141bd7bee5f470ac28ffd56e6591c │ │ │ ├── 794d2929ccd4a9f38151fa274b7bba0a898aa30c │ │ │ ├── 79693f140367ae963c396d7952f2b07e3e603755 │ │ │ ├── 7988534604fb11aa559428f200cd7631d266dcdc │ │ │ ├── 7993ab06fc93824943100f468b83a388dc8396fc │ │ │ ├── 79a78205700940deac5a3af06b37f7a837ba5d0c │ │ │ ├── 79dcbe312ec0cae55271acea3fbcad77eb51a258 │ │ │ ├── 79ed5f67b23082b621f1d3d307cbb3833df70b36 │ │ │ ├── 79ee5f66d93ee0d29f8b42ccf65fc760525867d6 │ │ │ ├── 7a043102c33d83ed36e9879386a6e618668535d9 │ │ │ ├── 7a111af866866f2de4ef478fd546fb1c0fc25d0a │ │ │ ├── 7a1820d857c8a49a2db73ca33ae771ff2942dccf │ │ │ ├── 7a490995df2d5f17d023de70297a3ccd20b7e9f0 │ │ │ ├── 7a4a6b8236fc89f7d9e11728eab5f34c87b831ca │ │ │ ├── 7a59b37e047189062f0abaf0d629290ecfb35f75 │ │ │ ├── 7a69a216cc5a6c99a19546872d16973b864b8ec6 │ │ │ ├── 7a6afdaaff4560a33eba5ebd9df662b110b72dc2 │ │ │ ├── 7a87119e2369843226572e9e9603e14022ad565d │ │ │ ├── 7aa3606e89e98945870fd6072bc248da2ac00194 │ │ │ ├── 7ab6a9ca3af298309556e392c5a2145121ecad20 │ │ │ ├── 7ac66a26b371216e55464bd620f00f9b3cabf539 │ │ │ ├── 7adcfb6ec993d4f55872e19410191727163f6958 │ │ │ ├── 7ae9dff22041f4c1fe093655030d83341a775789 │ │ │ ├── 7b1eb9664a41baa7f5e742f91eba9581bd509407 │ │ │ ├── 7b242c6392ed925c411f5a03c01a5b224498873d │ │ │ ├── 7b302c63a0c095634d5b99d885e31d50d348915f │ │ │ ├── 7b385bf3549519df825d01ede2e8d9864af0d4f1 │ │ │ ├── 7b8328e1cf64ee86aed185c42ef2d58842a86505 │ │ │ ├── 7b9f95b7241f7c9902e959452e13b67e26806ad6 │ │ │ ├── 7ba72ec40b0c475f5d75c1845b6a75ce8fa2c003 │ │ │ ├── 7bcb414301b9d095183f9b852a0c948309483542 │ │ │ ├── 7bd191b72e7ea5e8407c5a81557fb3489574834c │ │ │ ├── 7c0066094d3af7d6ae9649b1e0d8c4f65d29d5b7 │ │ │ ├── 7c3defc5ef17cddbacd31b76689e0f6d0737ac57 │ │ │ ├── 7c7017c2b46f27580791e590ff2536195830225d │ │ │ ├── 7c7b7ccbaea2f13ad6524f8a286a5a8e5de67e21 │ │ │ ├── 7c81f44f5bced662dae488456a190a2b5b68c852 │ │ │ ├── 7cc6f39aa5cdd7a9af8b06f6627638b3bb770f40 │ │ │ ├── 7cfcff79af9057d0133f2b5da206b608722bd025 │ │ │ ├── 7d568d459cf98a02f42d26cf7a40def28f45c07c │ │ │ ├── 7d77c20b635f8d363cafef80ce333359495fddeb │ │ │ ├── 7dbdb91634696f23cadac0af049ca2841cbf75df │ │ │ ├── 7dca132115921f6d0134e317bc0c5b2e5b97934d │ │ │ ├── 7dd14622cf7fe1695e710f01b45d90250043dea6 │ │ │ ├── 7ddf0e4fc007dcceddccc60c7634ce32af1c1782 │ │ │ ├── 7de80c1c4a6415b28404560b4e476f7ff798b292 │ │ │ ├── 7e165223d7af3c0a9b55423a23a84315b3549c34 │ │ │ ├── 7e2b8b5d88ab86a02660c9f930b1dc7bc915500f │ │ │ ├── 7e2f0de68af4544f103e74bd384b74b2e2f85241 │ │ │ ├── 7e4029c06ed03535d5f51420d860c7da16cc155e │ │ │ ├── 7e70e8a2a78ad2b7e350dc4a07651a5bf027cb57 │ │ │ ├── 7e874b33beab6c09e8cdbcdcf34c226d959f53a7 │ │ │ ├── 7e926dc258ef73747c6dee6961a01976f75e194f │ │ │ ├── 7e952aa0d4d919ea11291440bf1f5548858938d6 │ │ │ ├── 7e95b122591089fda778a2dbd434c55672c92346 │ │ │ ├── 7eaf9980118567289bdc91759abbffb031b64227 │ │ │ ├── 7eca413996ccecf266e5bf306d63db50903b1ec0 │ │ │ ├── 7eeec8eac2847cfc829b4f04a7732871fa5b33bb │ │ │ ├── 7f31dda7857641eb43ac8f245109af960b934c86 │ │ │ ├── 7f36ff093686c198384796967779e512b39b0067 │ │ │ ├── 7f37fc6f46dfd2056c23dce7388e996b2e007166 │ │ │ ├── 7f5fb097a29a27b116140b9366006e578d1139ce │ │ │ ├── 7f6b5c7e454d101b3d586c7653b251e1aaa8404d │ │ │ ├── 7f76a08aef5329137e1c80a8f4fc7245375849d9 │ │ │ ├── 7f7be6c8663be7951320cb6c651781e5583ed65e │ │ │ ├── 7f8f81d1bf5547aca3adaba322cccf59977c80b0 │ │ │ ├── 7f9d1a52ba029c7f6e88ff84575df1fcb1075619 │ │ │ ├── 7fc1bf414713fa9f80c252358021f9f97b15c792 │ │ │ ├── 7fdcc6c41ae23f27834e5e1303ac7e3a7a01c43f │ │ │ ├── 801315c10fe0fcc26c0c57bc8f631cd93596168d │ │ │ ├── 80333b40950b8f22b44ba7c383dc625b1b094df3 │ │ │ ├── 80376b2b822b9baaef72428ca022d2e8ad5fab95 │ │ │ ├── 803cd5f12d095d218780ad627b0b82b0bab86370 │ │ │ ├── 8046cd7645e89a0fda7d8f8378e8425fefabb6e8 │ │ │ ├── 804b90af698434a3596956677aba5a5f73dbaed0 │ │ │ ├── 808bb1522f5aa5de2dee150c5fe9b2240c76f14e │ │ │ ├── 809f182745ce2d04f2ed1126bbd41c71d290955e │ │ │ ├── 80b5c3a4f3efc732cfad5a798289e246619f8977 │ │ │ ├── 80b9b953d5d211827d5046ddef05778d9e6fe889 │ │ │ ├── 80ce5e7fb2b5a1cf0cf9bb4b9a786e4bf6735056 │ │ │ ├── 80d98df3c15079be160fd7897dc74ef9a9b4774b │ │ │ ├── 80dfc8a9fc0fe40ea7577dfd42a34b367905756e │ │ │ ├── 80ed8061d1dc94f53f2e897f7421f7e7109037ef │ │ │ ├── 8114bd4cff1787b06e5836915e62486478f693d1 │ │ │ ├── 8114ee0d2c07fd933798fcf7febf9e08b6cf1043 │ │ │ ├── 813b01314937089f22d1d64ac7030c5da92ac36d │ │ │ ├── 814755d13f451119bbd6e341778fcca05d023f99 │ │ │ ├── 8152fa388ef907459fca58c6382e7cf481e8b03f │ │ │ ├── 816316a3b73af9b70141fff8b2deda8269d38d34 │ │ │ ├── 81639ecf4a65a0d2972d186cbca46aa48c408a2b │ │ │ ├── 817d2dc89f753f1b403cbbdd6c078eeee50563d1 │ │ │ ├── 81873f88c2fbdb0a58e15e3492b63cb1eeebd61d │ │ │ ├── 818a1e4250991ce3f414e0f7215308cf2f23f7fd │ │ │ ├── 82050e725b7ee8e6090dcb98775499dc19017c4d │ │ │ ├── 826b8362320fe6f06ab5a2f4b4fbf5c94448170f │ │ │ ├── 8283d17b50ed5619f147c5b35a8f94626b7d5b26 │ │ │ ├── 829c3ad6c8ab04d87634c91b6fcd79faa92656fb │ │ │ ├── 82a84993b98a8fb62799914dc21be4be700e7b5d │ │ │ ├── 82e6db8a76fd387b0eb64cb1d7bf968ef761fb96 │ │ │ ├── 82ec131b824b4c3f3757e1edd238735d0656fc37 │ │ │ ├── 8336cc9fb782ee91ec2fca64631271cf0078de20 │ │ │ ├── 833a14196d27bc959251f1d19b9e4e6829d267d5 │ │ │ ├── 8366f34c8cc56c4971befa8d4905f0f436bf6cda │ │ │ ├── 8393e8cc899fa71d1c638c5cb8eea55c40342700 │ │ │ ├── 83945bfa970aa433de420b7ac4f4efcc297ec972 │ │ │ ├── 83970d72a6907256d4feab8e061182642c3d4b24 │ │ │ ├── 83b00e365af084f70ba64981a783c5ec81c0e650 │ │ │ ├── 8434ef7375003e0e049d9248cca04a7d89a51736 │ │ │ ├── 8442ffd276255dd9c5995c977f30f700234f866f │ │ │ ├── 8462f1863bdba9f38df24dbeb39d9be31a8b3d93 │ │ │ ├── 8478b1cc13202df27bd080e55410e541629423e8 │ │ │ ├── 847ca904186295e8fd47a4e29885615907cb992e │ │ │ ├── 847d38e6322523b12583cde1ac03aa9cb6c11494 │ │ │ ├── 8485b7daa7b9582b7257e4ad6aa767ad9b2c7173 │ │ │ ├── 848ef68b2028c2d1d2c774427baef8811e6973c6 │ │ │ ├── 84b78b9ad073a948405f0b7ab62f9f69118ba8f0 │ │ │ ├── 84c54f3da6a5e6fab8e1f0e9e437a602b838b808 │ │ │ ├── 84d1cf1063766590aee538d2b55b7bd3698c0de7 │ │ │ ├── 84dce9fa92c533d455e0c1f97179960220f0a855 │ │ │ ├── 84f74ecd7dcd980cbe8f5c5df3e9de9eb9e2198b │ │ │ ├── 855137df77e723cfc86499f4fdb99f284ce7dfb2 │ │ │ ├── 857a099c2b46ccc02b866b3d0c0eb37858af7f6b │ │ │ ├── 857c4d2b4cbe976e614059e4d9eeb613c69a523b │ │ │ ├── 858fcb46fd11dfff505511ab32c43de93cb923ab │ │ │ ├── 8592c80000cf304bf52753ab309ceb04e2652ec5 │ │ │ ├── 859bf525139277f5088a3ce814f120ba25928ba7 │ │ │ ├── 85c3b1c5bc8469eb9f51ee2b19c514d2dcc9d4e5 │ │ │ ├── 85c9ddc38fbb85bd175bf3ac00a626752b964461 │ │ │ ├── 85cd37fe2c7301fdbdedfe4eee2559a27232c9e1 │ │ │ ├── 85db7ff2b922cfebbf367553f67005a39f7c7481 │ │ │ ├── 85f392952d2f71a976ea2c35e174e534ade34805 │ │ │ ├── 863c74afe345aa2460edf06abd9aa101ade521bf │ │ │ ├── 8641c37d6051843e6ca2af00b13ec220650722d5 │ │ │ ├── 86808a5b2f495881fed3418379a96faec86f72a3 │ │ │ ├── 869a1712bd79edfc9d95461a25217f1b4b203e29 │ │ │ ├── 869e9e9fd462fca683f8b432da94616198c8eb41 │ │ │ ├── 86e9313b4a88cc4785b502796f36bd97f1174856 │ │ │ ├── 871647145b6c79309648164fe2e9294d7ba23b0b │ │ │ ├── 871b6052e7f9a98779e47518bd5f8bf607a0e268 │ │ │ ├── 87360adcbd85bcb0816fa5f993fc9a5e14182074 │ │ │ ├── 874116a3fba0e5b88378c9825e5b2cd8fe9707c6 │ │ │ ├── 874498dbd2d21fb6b01edf60814088feb89dc02e │ │ │ ├── 874b8f129a3df7a4c057a29c6d71bfa99137ed88 │ │ │ ├── 874c302461e364f71a8f6570728f98611a5c96ce │ │ │ ├── 8753f414b84b9ccd0c62553961f88f7c0264c379 │ │ │ ├── 8768655b2d8b6e0cca092c104735354aee0c9b0a │ │ │ ├── 87d794de1dead52b89760fa5e136596c5b59bc40 │ │ │ ├── 87dcc971a3beea2e91a4d7e9643a5539ff94d52f │ │ │ ├── 87e1e382d129600c7e7f842f983fa6e87de06c9c │ │ │ ├── 87f0c2e540270b3692ef13bc2b91234c893bea37 │ │ │ ├── 87f8602bd7dcfb5af1052f424e7403550ff631de │ │ │ ├── 87ffa0846cd9a6bebb41a9d3d719ba376c69285f │ │ │ ├── 880f03671efb6dcc3f3fdaae9491625f46f6e4ac │ │ │ ├── 8829fdc647553393e0d223a098067bdf44dd2c3e │ │ │ ├── 882c32949367f4f504b543399fa13b4f4118344d │ │ │ ├── 884b9c73958e305260b7aa5b9969660166f550c3 │ │ │ ├── 885db56c9eb82324c5a0f7e7aebd3d215505a5d3 │ │ │ ├── 88684adb319365b522f644e785033cac77380e06 │ │ │ ├── 88797c1357072ec5f6d7a77f8f554fdf14935742 │ │ │ ├── 88d3c033edc04d341651610ce654caab89f0c589 │ │ │ ├── 88e2041ce84c5a5fd2b056669856844691b520a5 │ │ │ ├── 88e2266275388545e1f8f54b8fdbe89bbac43274 │ │ │ ├── 88ec99f421c2381e497fe2fc13b4f6dd8e8786d1 │ │ │ ├── 88f24d3d0ee361f07b6a968b39726f1326ec9166 │ │ │ ├── 89063488083093835287b1f9c18b2a7944664176 │ │ │ ├── 892cc3023c1245c75dd88475a0e49fe4d5063dd9 │ │ │ ├── 8951f7b39335a2e501908ed76548372ea5979b19 │ │ │ ├── 895da8e67657010ab55eddf2b5e50156498f59c1 │ │ │ ├── 89843a3d7b0d8895dac3541e10e30e0400dc0f5e │ │ │ ├── 899da8e446fd56d043e8d9fbd5821c09500c8654 │ │ │ ├── 89c130024a3230c8800c10efba7110244146ea67 │ │ │ ├── 89d3b93983fbc2ea121d1407d7944b74f44c67ae │ │ │ ├── 89db7a1ad6220b1635de9734c32a76ab69bb70e3 │ │ │ ├── 89df1562d15e81161f4c47827c0802d44a116dcd │ │ │ ├── 89e008ea516ef46108ee4b85055e4cba034e75c2 │ │ │ ├── 89fa19afc7b932f3749a095009d1bf1c6162c607 │ │ │ ├── 8a0a41ec1bffbaf105b7b5b3784d680d00446960 │ │ │ ├── 8a0ad7fc3cf79a721233622b6ae7a4bfc52c228a │ │ │ ├── 8a2775fc1b4fdf627698087dbc89fc1a3b0943be │ │ │ ├── 8a289fe11f09a8013015d4bdd383c4d26de1f483 │ │ │ ├── 8a29d68c4034560207bd08a36c47e26953bebe3f │ │ │ ├── 8a3477e0575b2a93269f750c0395201cd0f19a37 │ │ │ ├── 8a3c9306c70ceb610d6f1f738df6679eabff4238 │ │ │ ├── 8a52da0771f3d868955501e901d2540538f4d521 │ │ │ ├── 8a7bd56f4854fd39ca2b9dac03cf4e4f92a1b93d │ │ │ ├── 8a8928f98f7dd800744cfcdbefeff96b97543b76 │ │ │ ├── 8a95cc474b746e69625f0fe8c262c07a37a82a7d │ │ │ ├── 8ab6f611cd721ca128cb8f5ea3078c1b431d5704 │ │ │ ├── 8abdd04f7c724f0a762d03fb6fb80e698280ae9c │ │ │ ├── 8b08333db48411d829619458a66585a39efcbb11 │ │ │ ├── 8b2cadafb5c90652623fe20f1da4fa65454b1764 │ │ │ ├── 8b379a5db43a90e8d77da62355f3ac86f95b1422 │ │ │ ├── 8b436810adfe76e9f0a84f1a2382284cefc4128a │ │ │ ├── 8b4a8862bbb6306cc7b4473bba476bcaf6383aee │ │ │ ├── 8b5c3d67f71726b53372b58a37b41fce4a30a5ac │ │ │ ├── 8b5c7dbd04ac3065bf6c8164f3068ebc910ddc30 │ │ │ ├── 8b714927de7515d6467407861bea2d1b6816f769 │ │ │ ├── 8b7781da37cae546b0800cc96db74dfb1988fa5d │ │ │ ├── 8b8235aeb63d5111ff81b6406893e2c114f3d163 │ │ │ ├── 8b926866858180ba6c9e1a87ace930fdf129b59b │ │ │ ├── 8b9de640b20beae0f41a3d88dacf8e7c8c00e4a9 │ │ │ ├── 8babec8da5a26469095793b097811d07f256a5e9 │ │ │ ├── 8c4cbb21d02e5d466fb2539022255760626149f2 │ │ │ ├── 8c504464b5b4239a47fd8d4b185c3e0e1b6c1af0 │ │ │ ├── 8c716ab740c917b4df170efbc22b4e47873d8e3d │ │ │ ├── 8c7dc16b0e4c9ef242cc7ca7264ea3a4cb62a9bd │ │ │ ├── 8c87d28e9f82d8cb2da362853cbfd7f6ed73becd │ │ │ ├── 8cac7b8d77d23a0085a03a673ee2021520fbabea │ │ │ ├── 8cd544fbd46d49e76648955888fc3047bf5e24bc │ │ │ ├── 8cde25f4590bc7a0cb88896228ad8d28ecb9641a │ │ │ ├── 8cf7c389a03e6d9d8cdd4dc0ee8615f54cccd395 │ │ │ ├── 8cfbcd30e59e458884ca65687215ef8a39fa420b │ │ │ ├── 8d2e1d4e20c8a37b8483b0636a53106414b2e098 │ │ │ ├── 8d84c17e2d2a5f1b483ec417d4084cff8a83bd8b │ │ │ ├── 8dad5eca9780e98722de60bdf4209e99730b7ce0 │ │ │ ├── 8db878b9f4d8758552ba375e70b1c319d8ca0248 │ │ │ ├── 8dceab2924460f1a418835afa3ff5d4bde00914a │ │ │ ├── 8dd1413b2a30d480170c4918b00b9b7abe7ae2c6 │ │ │ ├── 8de4d54ede6f78c61866173f8b1096d7f5e3f478 │ │ │ ├── 8e0a71d16611cdac906bb4dece9fbf87d1a0fc8b │ │ │ ├── 8e1a1f4379046e33058d6b3df5184a181b98a2b5 │ │ │ ├── 8e38afa0e7c920bbb4aec155f70d1940028204ee │ │ │ ├── 8ea1e2b4445b668065a333641c17f3c6038f2f27 │ │ │ ├── 8eb143cfc057b1ffa8e90069a1d1ff91a90ac794 │ │ │ ├── 8ebc6173196e2c3ad4ea6d665b4893fd67690d70 │ │ │ ├── 8ee6b6a7957bf8ed03aa4b95dbc232e5ba56ead5 │ │ │ ├── 8ef96afc00349b4248ec31f4755d1020b7fdda03 │ │ │ ├── 8f07475a5f9d43a948b3b96452aea50918e4b9b7 │ │ │ ├── 8f0862b153c849b8d035fa189f7ec654f8b3e862 │ │ │ ├── 8f0aa9d861c14d5c32d60092ba04c2253666c4c5 │ │ │ ├── 8f4ba01ca74a466747b89a116a26047e58536ef9 │ │ │ ├── 8f56d7ddb9c736b9c89113453c379ec0a21341f9 │ │ │ ├── 8f7ed4f89eb5a042d9a19a78e61c47e5c984a9fa │ │ │ ├── 8f94c8c6a37bcc91d7a39416023f9d78ff08129a │ │ │ ├── 8fc0dcb82f3f88e6c20e123adddbce9afa79dd7e │ │ │ ├── 901261518c53841cdeb55041f748183f25fbdb6f │ │ │ ├── 9014cd1a175ea66532264c818ac4692ed805357f │ │ │ ├── 902fc67f6a0dd7c17809ac0002972da218f32b8c │ │ │ ├── 90439abb1bce7df95926ac69fbe35e9a75849704 │ │ │ ├── 906de10a0641d6cd4c0dd422fe885c2f9691128a │ │ │ ├── 9076f59736d1a417df0e4e53465ba7f80da49859 │ │ │ ├── 909f04b9af20cf2cb275ec1cf722f9a40b234fdf │ │ │ ├── 90b75e22907115340a987929a776f6f3bea1d9b5 │ │ │ ├── 90cddd59c8cf3bcac6b2fb6df29c9362c3a69855 │ │ │ ├── 90e012902ea03831fe652fb98c2f284c57217115 │ │ │ ├── 910480b0cfba5cfd886687f687f8a73d081c0b15 │ │ │ ├── 9143eec00e7c0dcba52a44c54c7fea4ca90ac9db │ │ │ ├── 914d626c074a269b3a9d1451d77761c9b6e8db28 │ │ │ ├── 91b3598a2ceedd0e45722fd9287672a13bf221e1 │ │ │ ├── 91deadec3dc6c425ddc903b195066184526341bb │ │ │ ├── 91eb11de4a9b1c364da7e342da879d0915930da6 │ │ │ ├── 91ed8c8f6952e9dfd27a3d45454432bd4886c8d1 │ │ │ ├── 91f11c0a3851e5a1b473cfd412ff28fcd7903c39 │ │ │ ├── 91f5456cb58ea9371b0fc9864e05767c7a8ee7e4 │ │ │ ├── 921d11cbd9a6ba01c1bbfcc40c1205f6ef275acb │ │ │ ├── 9238fc472251c9a3c817ab6cc5ea4e97c3d05410 │ │ │ ├── 9250a8a685e1f24b96edf202f1204a332bcb0ba3 │ │ │ ├── 9266cfa0d3adb02eaa15bc09db296fa853d6deed │ │ │ ├── 92848420c5779bd1c6d954bfc933383296c73c07 │ │ │ ├── 92886f1a44cabcf2e2c4dcef68ee37caa458c47b │ │ │ ├── 9289711f9cf1406a577387a27b8bd4930e29fd38 │ │ │ ├── 92bddaa4b62dfceaf980ba7a89bb0cc57e8fc52c │ │ │ ├── 92c132ca1fe8044c1317c18feaca645a54713ffb │ │ │ ├── 92e0a98f523af81899be75f9371608fd9948b337 │ │ │ ├── 9309be25161f4e02117ef32870ded9650d0e4f7a │ │ │ ├── 930d453e2c53ce2b64bd0f4b950552f988bdbc20 │ │ │ ├── 934c8ad33d4e9c5c13372bc93bf26cf3107839a5 │ │ │ ├── 935a6ed5b994d0bfdaf42bf6dd6fef4ccdbfee4a │ │ │ ├── 935dfd118a575d599a75b00db37955c92ef6471b │ │ │ ├── 936af0357943e249bd7e428753fc79b7870c4f96 │ │ │ ├── 937fe4be2d5689c59d7c617e65996d41cfafdef5 │ │ │ ├── 938f94084baf3b93faae268cc5e094df56f01f7a │ │ │ ├── 939a2a924292c7f549cc8f8be939826a3de6b820 │ │ │ ├── 93aa13626c3895c12d82d3763e8e916a16a4fd52 │ │ │ ├── 93c0123f1118e26a15aba5739d9f8db784f21efa │ │ │ ├── 93c6f793e89f2bbe200dcd083729e8e2af40c2f2 │ │ │ ├── 93c799f74d4e3a3b8dafa975cb2453af687a8872 │ │ │ ├── 93cedb385de6371ec85a3086d53c93ba0e1c6926 │ │ │ ├── 93d43e9d7f08eba5daa4d394a95703498c7e2139 │ │ │ ├── 93db6d7b5e262a03c9f6ccf71ef4e8de7acf6fb6 │ │ │ ├── 940254cd6f8f945bc5f1edcef83ba2afc7edfdef │ │ │ ├── 94136714739c4978945621f669ecaf025dff07f8 │ │ │ ├── 942302c74767926cf73be9bc6753fc422157855d │ │ │ ├── 94232b6796277453192019999be8b0fce849e3c3 │ │ │ ├── 944304c86610b738afbff55026632249b735f401 │ │ │ ├── 9447c6b9ffec17e55cc04961dec9cc9affec21dc │ │ │ ├── 94862fb03e48c18301c8d883c0b89da06351e369 │ │ │ ├── 948c81d5b83d1cdb3423d9e81a61becd8bf2a7bf │ │ │ ├── 9499a40681e896adc4c45047502a358ed7cf1237 │ │ │ ├── 94a9f7a609640945c820b281c9b05d992b0ac4c2 │ │ │ ├── 94f8b89ee92aa4c7d64eb59fa7c8811ee71c5de1 │ │ │ ├── 9506e2eb82ae6c5a245403a82c8c36c49e7dd19a │ │ │ ├── 9512c13d6e0d292adb68e6b0ed8f466ba396e30a │ │ │ ├── 95285e78757c883cf8644bfcd7749e4b08cb59c4 │ │ │ ├── 9528c094e6823258fc43686ee4fdc5d619021a94 │ │ │ ├── 95418ddbd4a17ea011fd39c57c1e4389b711dd7e │ │ │ ├── 954e0aead2f1448d168416547f795dc8baa7eb10 │ │ │ ├── 958966b97201943c2831502b3f5bbcccc2d1b2f3 │ │ │ ├── 95957430f0fd0b98963bf7080efffaa2efc45563 │ │ │ ├── 959b1c7bccd9efde5105f9deaa24262e6171f127 │ │ │ ├── 959ef5c1dfba6621fcd8365261b27885ba0eedfb │ │ │ ├── 95a04b0c50967b773d91751126d1ffe273287347 │ │ │ ├── 95afe9b1e8db35a5924aabbffc0a617e6862a1d3 │ │ │ ├── 95b65f78191ad63ba2149f216ad4b1f3a404ee82 │ │ │ ├── 95bc7b2db1ac665317576e24031e551189f4efe7 │ │ │ ├── 95da825d4132e9de80a280c89ba82724643b74f2 │ │ │ ├── 95e7d15b24fad0c2e4780004a45b735813a6d457 │ │ │ ├── 96089d3e37c85cc3e1727b58cbcd209157529a71 │ │ │ ├── 96197c6b417cdc946b9a34b57ac7c50feea0ada4 │ │ │ ├── 962bb09ab095bcd35f7f34055ed0fa8ae434af02 │ │ │ ├── 962d79802cab79d4bd0c5d840a5f94281465c290 │ │ │ ├── 966f41ea0609c64925ecaee5ba1af166ae43fdda │ │ │ ├── 96735cbde31cd1fbca452de029d3f77a7072dd87 │ │ │ ├── 967784fbda80e2586d2566b1d20422c209de8e3a │ │ │ ├── 968b512c074558ddde3b21c60e2886fd579c950b │ │ │ ├── 96a0422936b6ca5c4077e1e8fceea23c5dd146fe │ │ │ ├── 96aac36c65d79125e3ee07ec601f71c0c09b0cb2 │ │ │ ├── 96c1bbeb23affbc8ce9c5703062a448e21a42eeb │ │ │ ├── 96f5f4a5b64b8e8462a72eb1d259066fce9fbe2f │ │ │ ├── 9700352a9f17c39165256df2f2f7e4fa2ec9de61 │ │ │ ├── 9749e874bbbae2a0dce118ef7501ad135ea6cddc │ │ │ ├── 975509735c405d7f26b8bd4c00a32158c4f2911b │ │ │ ├── 976fab0e9af7ab44ebc738f13b377d23ab763465 │ │ │ ├── 97703896dfbc748c76753b9dc807252baa7d17ab │ │ │ ├── 978c3a312999502111000de7dfe47b35516164f4 │ │ │ ├── 97aba204ef02b37a3627221d61d8e55c8a4e1c89 │ │ │ ├── 97cc85297ae928c35b606a80f058ab18ea5187d1 │ │ │ ├── 97f61b6d98c9ffe5ca701f864969608db86c81fe │ │ │ ├── 982a43466eb400711eaa92486fd3a9b22d4ed22c │ │ │ ├── 984d407c9a0781d661b22c64ad915a555d3bf64d │ │ │ ├── 98500d46f789f6e67f2c3e2f6af290db2fc124cd │ │ │ ├── 9886f8415dd6095f89ff7e519af7516c9b7dc352 │ │ │ ├── 98bd202ec6667081b4a70e2f6b929af634ac6d68 │ │ │ ├── 98c6e09cd9cdc3967e01f4842102de38d4cda1a9 │ │ │ ├── 98c83bcdb5956bb94639dc29099871c76564d6bf │ │ │ ├── 98d122b2f88e6c5326c77b7a643d054909d0e33a │ │ │ ├── 98d39d50572a07ce2b34b997b11f0801efe034d0 │ │ │ ├── 98e6557609649d2edfa5303dc85da6929b3e46cb │ │ │ ├── 990480b357aeb905cfea6ff646718d101978e980 │ │ │ ├── 990924cc189ea41b110bc4dd575460c49374f23d │ │ │ ├── 99621f82461534b8907da50ed4c7020620244c46 │ │ │ ├── 996fd99ab96f9643d5e5713a831995b17e7a3d6a │ │ │ ├── 99d1d11e7c7797862b2f093aecd2482708213a46 │ │ │ ├── 99dec7b1a061c754594c315d70173856ee38ca53 │ │ │ ├── 99e6e3dc68bf0e9973d9cda82f1300e98c4d58a0 │ │ │ ├── 99e8319b516c140aa7badd1e9ef03d1ff1c3bee0 │ │ │ ├── 9a11c2fda7b9c43e2b7720bd72c00e2503c9dd88 │ │ │ ├── 9a309f12e7243094d23099f5433d19602252797b │ │ │ ├── 9a89b6f3139174829b27ab6ead21acbf001ee2be │ │ │ ├── 9abdf13e2635797e12d342e2dfb31a9c80d0edd9 │ │ │ ├── 9adf5a63b8158c84d6bc327d0b1ac1b5964a3ac4 │ │ │ ├── 9ae58507a65058e0fe31de871c7a34bab5415ae9 │ │ │ ├── 9aece0f0260af3664b7ed391226bcf127e9fd163 │ │ │ ├── 9af8af68c2f18bca7d94dd8b48ce8692c89ffb04 │ │ │ ├── 9afe6dae1af7cdc07ef615de0c3d2ebdd4f68c15 │ │ │ ├── 9b42d222b18945ea05823e8a6dbcb0d54a364700 │ │ │ ├── 9b4d35c34d31ab2b9e6a0becef710c9b00ec976c │ │ │ ├── 9b51c6d0b56ce78a3dd7924a0c74626beea4b529 │ │ │ ├── 9b62911307d4c57e65b67719613737ad5d45433f │ │ │ ├── 9ba6a6cf62c5826ffc6fcd084371c29d51f194c7 │ │ │ ├── 9baed9539fb0ad3446fb36b9804e562244aec18f │ │ │ ├── 9bb0ba96392a718e713162631e2036c2a0708ce2 │ │ │ ├── 9bb98651acde18815c952146548c472023a22072 │ │ │ ├── 9bbe3f1ede4caaf74b619e6e82cb6b6f779f366d │ │ │ ├── 9beb9170ecc8bc4e97002efea295cafc58d55688 │ │ │ ├── 9c1a6591aef6efd4346aa9f750f87940a9783107 │ │ │ ├── 9c3a7896381a924c326a82a884be65e632a9f190 │ │ │ ├── 9ce105ac118fb5187b993ba8e83d9b199dc86fe9 │ │ │ ├── 9ce973c4df052f54b32f61eb27b74cff377e6752 │ │ │ ├── 9cf29382585d7d87b68e19e5244cd47ddedf35c0 │ │ │ ├── 9cffb02f79fc72e41c0ac0b800b862fb39b0a7fd │ │ │ ├── 9d13b7a6b273e9242c1092d047290e60291087da │ │ │ ├── 9d2325335a737991316f3231a676fb415c357be8 │ │ │ ├── 9d3dab224014b620dde2b56cee3fec23463cb909 │ │ │ ├── 9d6211da7d3f0bda14d5067af27a1abd46dd187d │ │ │ ├── 9d6647e7af1e10de1b3c608d829400e5663b3d7e │ │ │ ├── 9d86f6cf43b5947de7d50f80fec0483a9072ee0a │ │ │ ├── 9d8bf71616bca5ac31e24117c80dad52352d5c2a │ │ │ ├── 9da24604599fa08b01181b48265429ebf1cb213a │ │ │ ├── 9db297bad5b8a7a06f76713a5b05cdf2148f3b19 │ │ │ ├── 9dc1141da1d44addec511e26f89d5046f97da2c6 │ │ │ ├── 9de0c2afad49fa532a8fea5e4dad68a5f1ab8a22 │ │ │ ├── 9de4c3db0a099c27c523988b4b750ce3ee2c0ffc │ │ │ ├── 9e080c9060b0017ebfc6f81bd854014a8fc88ee8 │ │ │ ├── 9e0885e261051e23c61d7b6859e9c25f16f9aa73 │ │ │ ├── 9e533595a0cd03757f4ce00ca1a54a38453f6274 │ │ │ ├── 9e7cd3ed8c99ea2f99c6c55da41e1a2e4c56fb9b │ │ │ ├── 9e94137b564120169fc22f85678cc20df3a1128c │ │ │ ├── 9ea50ae0758462d0e77fe1397a5af6f83ad15f39 │ │ │ ├── 9eafe1e70dda380dee958b8ae1138ab758f76857 │ │ │ ├── 9ee645ca92c85ae4515e7e01d35579bbc6cb046f │ │ │ ├── 9efceb8b8d6841f20ca0f194b19427087f5a97ea │ │ │ ├── 9f0427c58e85128c73cd97a9ba41519871d70331 │ │ │ ├── 9f07a530e3bc65a6d0a8da0a8ad697b5dc9ab202 │ │ │ ├── 9f0aaa42e73656b0fce8443aea84266d564470e9 │ │ │ ├── 9f1fe443098130f838ce7d5c1460cdc0f13bb12e │ │ │ ├── 9f282d2e013696b3d63d9269bf869f906bd8cef4 │ │ │ ├── 9f78e819952e56d7b1961320d611fdc489b34e51 │ │ │ ├── 9f9bfc59905231b990a2d55faaa21a4cf26c8781 │ │ │ ├── 9fd2c2accbc395448a7b5d7d8bcafd190ce329a7 │ │ │ ├── 9fda11dcb9654da892e82b6566c4aeab962c8278 │ │ │ ├── 9fe5d577717a9a11e4740f29f231fa15b9f4d01c │ │ │ ├── a01b0232919914b0a33ff87262f8ba59543b0ab6 │ │ │ ├── a027f0c1c564bf78407eed47f2a9f03c60eadc02 │ │ │ ├── a0482c5ebc234aebacf836bed890b373827b5958 │ │ │ ├── a04e38678141417445359665f17e2c444cc55835 │ │ │ ├── a05131b921bd9d6b4ea47f249e51ee98efc05f54 │ │ │ ├── a080874cf108744cedfbb712de9629eed229ec49 │ │ │ ├── a086f46eaeca09d3649d592dc5a55044d8de1f41 │ │ │ ├── a0951cc6042b25d64914d945c4e3758a0407ea87 │ │ │ ├── a0c092d70e81d7131ac1cb03d9ac8db9d2c0709b │ │ │ ├── a0d64b88f7e1a35f28c08292725d25214520f7a6 │ │ │ ├── a1258cbda9cc624bb9f238882cc84253a1dc87c2 │ │ │ ├── a1430a0798548b8c620d89157e6f2a54d9f94f2e │ │ │ ├── a16835f468084695f51026fc26ce3f842fc97714 │ │ │ ├── a17272e8d29e6c955e3b27761ff0e3908e202ff1 │ │ │ ├── a175484c1508738494b7c85ab928bb65c4a07f42 │ │ │ ├── a17a5140033f84e309aac8415b2a580b4050203c │ │ │ ├── a1b572d1fe5a9c9111033297ae5ff70014c256ce │ │ │ ├── a1e666afd74df95cb5c06318730dff9116d6a22f │ │ │ ├── a1e97b7bd972796aecfd4b83180776a015f64a8e │ │ │ ├── a2124d0d2b17ee1f1e0998338eea25cffadf437c │ │ │ ├── a2135bcd7d491b07a72fbd501a3b0be1b9f3bdc2 │ │ │ ├── a21f2d7b6393cda8bcff8df7034062e8925f6377 │ │ │ ├── a2452fe77f45ef6a612ce676a6ad9d9002b9331e │ │ │ ├── a25b4431040ecd4aca97dad2844cf0080a40800b │ │ │ ├── a26f67d81684b9007a2109269de4afe49d23f938 │ │ │ ├── a293d31bc0cff7b14f873a325579ef283c8e2068 │ │ │ ├── a2a3d1e6a386b04424a390d174bdd394f0b88602 │ │ │ ├── a2ad73830bfcdf027adbf16721e9d3b54303b060 │ │ │ ├── a2c43c8aa3d41b7eab2ae20fb1f9e973802d902e │ │ │ ├── a2c7ad1b00fd60ced001c83967d4fb945e86a28a │ │ │ ├── a2ccb0337cf44bc0b3562bbf7dcdd792989d5faa │ │ │ ├── a2f70a0c20b111ca1ab34de6f2319109527a564e │ │ │ ├── a32041608e8afe0ca18b503f0e9c30cd1480f6e2 │ │ │ ├── a32cec9ef7fd885815ad4d76f8a45026473405b3 │ │ │ ├── a34ff67c5e9162f46fa22c082d21a7ac7a23c3a9 │ │ │ ├── a3770de2569e6bc576e5a3947ac08e8bbe24cb5b │ │ │ ├── a3823af6285ec27ac5824bddb591a1f209bc4018 │ │ │ ├── a38819d7d0147d7cfd3e537fe3756def5a12274d │ │ │ ├── a3ad36fa2c2c376afbf409d8fb83e076d6d87bac │ │ │ ├── a3af8000afdeacd1c3d6137959029e3b260c72ad │ │ │ ├── a3b21dcd0e4adb6a0ef920d74555d2f699917d39 │ │ │ ├── a3ce74eabac11a8d8a11955afa3ad09d86b22961 │ │ │ ├── a3d08eda208b96260cb5b47c1478e155264ff8c1 │ │ │ ├── a3e5f143cabf7cdb1f6111fd744b4230796b6064 │ │ │ ├── a42eb9002c5144273a55bdd736db4fde19aee488 │ │ │ ├── a446bc4e40187735edce2ecd8fcd0e7ed43952ee │ │ │ ├── a45d7d60a1eef620afd536f4d69cd4196a0fa6e8 │ │ │ ├── a460475c32082067af4eb3aca7203a69381aec6f │ │ │ ├── a47eeeeb9c724e0247b882207d4598df2b1f9db0 │ │ │ ├── a4b22b3869f32433a3caeafcc3e2dd92c010757d │ │ │ ├── a4b538f21947ef1c76087aab101911f7a2cd4ab0 │ │ │ ├── a4bb5997e547796263c8fda8ffb4c87967e2ea43 │ │ │ ├── a4c0daa47b25c77cdc37c485b2ddaf4db6edaac6 │ │ │ ├── a4d7bdb95ff0421ff9f027700815f81ebac50d03 │ │ │ ├── a4e49ce4052c6a3e72232ff2f764b972159ce65e │ │ │ ├── a4e87c35b253e9246a0bd98cbe936ecccbf2d89a │ │ │ ├── a4e89f79f42904ee1b600ddd79f2d3e27c855da0 │ │ │ ├── a4f449044130b59be750db18b3dd9cfd3bae5588 │ │ │ ├── a4f68b87043e04396cfebc9287c9d7280448eacb │ │ │ ├── a4faeb187eb7094b39e0f0699026cacbbb9d2ea7 │ │ │ ├── a4fb1b9f52700ffd6bf24f06e73666810b0e3260 │ │ │ ├── a506dd32985fc68730bdda9ec17bd68456455ba2 │ │ │ ├── a51dfad994645830ec06457aa99a3680c881234f │ │ │ ├── a52cb7e463be1bd639929b2d3988c313fb4189b5 │ │ │ ├── a545cc27e2d474a7a7b7ae974d6c61935d3bdfb6 │ │ │ ├── a547e004e80194fef36be8b3932bb2a42502c7b9 │ │ │ ├── a54e57e8c7e474bf56e54f46813916ef373a9d88 │ │ │ ├── a56763f3af3e1d367ff0097d69c129ed4bae7f00 │ │ │ ├── a5706ef86f9f5e79c7eb3a0ed8168f28bdc25f87 │ │ │ ├── a574eeebf64538810c2a45c5864f3209361e1c96 │ │ │ ├── a59cd78a997d502a498c2b597cda9c8cb9b435e4 │ │ │ ├── a5aaae5e5cc3955871ba97a7c41d307fef2b72eb │ │ │ ├── a5ace5adf4a44f04399e15b18f44e6a83e13b549 │ │ │ ├── a5b907c867904b2e2631128c5f637988bef1282b │ │ │ ├── a5c7d3a86b0f7fd48476aea167e188ad2e930dac │ │ │ ├── a5ccdd516198da910321185e29de6f20d9be2985 │ │ │ ├── a5d4903bde9105b510f48ef3783702f402c38289 │ │ │ ├── a5f0f80d6202449807c3c23b59496812943f4d12 │ │ │ ├── a610da0c9997c31b63719e6fe71e9b82d48595ec │ │ │ ├── a63c8dad9a5b7049824ad507266f11ef32fef7c3 │ │ │ ├── a65e2a892ee1771cf4861f2c1bc2d5f505645c14 │ │ │ ├── a66d01f6351976b51603542719f7e00648878dc0 │ │ │ ├── a686f07063eda38bb50a12b8bff95eb203e492e2 │ │ │ ├── a6932b59aafceeb75607a7b5c0b5d93b3f2e17dc │ │ │ ├── a6b7a9259b013c7a8613e1a5291dff6a4c46e85d │ │ │ ├── a6ba23753e57cd1a1f2d7e37472e4679a0f113a7 │ │ │ ├── a6c5d8b49fda54f8534027bba1269af6af46da1f │ │ │ ├── a6ccf2fabae7c6419459beefef87fd1e78fb2d4f │ │ │ ├── a6f23c5bb6dad507a24fea1ceecc0df2a026481c │ │ │ ├── a708a2f8ec818a38ec29e17b587179a32b43d704 │ │ │ ├── a70da8709e12ffb27292ce7290967a40c89cf126 │ │ │ ├── a72f0993c4460fa269fecd7c19909f1a8f319d4a │ │ │ ├── a732f61f7a104110a42397e2f2bcff054f17f50d │ │ │ ├── a736014c5e879818948ab14c8851770efe5d5fbb │ │ │ ├── a73a44e1dbbda1a5482aab336034e0f3b2631b86 │ │ │ ├── a742d0a1cc22ae97a4d67dae7649bce1710b89db │ │ │ ├── a758aa7b471d865a094148a124f948d84c1137bd │ │ │ ├── a76b07ca76b8129996817bda9c15cfe6c801c496 │ │ │ ├── a777b3aa2b4eb6ca1a87d04550c620145fe1fd1d │ │ │ ├── a78c1ce484d2b06f18054390abe8ba3738befc47 │ │ │ ├── a7ca771886a4f3f8ef1274e272ed3b75f1c52957 │ │ │ ├── a7d8752018d8cded7995daa9e4cd387a0f75eafc │ │ │ ├── a7edc21f3d053cf490a4f0032887dd77602ce962 │ │ │ ├── a80117d2623452c4c4d047ad5ffdcd2cfd707957 │ │ │ ├── a814c0230632e5c08f097102f2033615293348b7 │ │ │ ├── a83603464a89b1ff53b86c47af7c54b0f8a72405 │ │ │ ├── a858130542274ac050eecd7df40f62a22f2af3e5 │ │ │ ├── a87851edeb5a5db0f65fd04d5730500bf77c3e76 │ │ │ ├── a8a3b52078ade562edb5a7dc6ab61ce4b3cca2ab │ │ │ ├── a8b03c8e24ef968616c561f18edd3944caccbc5f │ │ │ ├── a8b6c76ee96d3aab811609a8979cfcc67cff79c6 │ │ │ ├── a8cd8ebe1c92a5ce01cb9d553c32988d450e82c9 │ │ │ ├── a8f6f74ddb0e0e8e8361ea297e0abac830cc1dfd │ │ │ ├── a912b73ec5ce6f1628bcb8d8e2dca4f96fb71c5a │ │ │ ├── a91984528078da07c39af230d966ecfa33124d9d │ │ │ ├── a98e2c1c0077687fbc9166f61a386e4a7023ae4f │ │ │ ├── a99032acc713604176f8d95263865e2c6dd015fe │ │ │ ├── a9b04af95ae95e9a60941ab351fb387c007938a2 │ │ │ ├── a9b58c8a3ebf4f2c3c8af6242b20c43aa733d6c5 │ │ │ ├── a9b81c4e5e52ddeed6c3bb9ecb2f67d7e056eb1f │ │ │ ├── aa0024897deb20273f4fad0f856967621953d402 │ │ │ ├── aa0d4dde043c88d76ca0b51949f90e102187198f │ │ │ ├── aa17922f64ff7cd6d4aeb56bfab8af47218a86d1 │ │ │ ├── aa376ce844fe5f3d69f1047c99cbef99e732dbdd │ │ │ ├── aa471973e1dc517ae959d5706167622da05bab46 │ │ │ ├── aa56f625476b200e65ada22557c871b0993ff86e │ │ │ ├── aa76c2e6c5a061d0580802966b8efb8804164d68 │ │ │ ├── aa8eac8fb7ebd4e613d8bdbce660665b3f45fa66 │ │ │ ├── aaa6693d92f9027513267fd416bd6201171873ac │ │ │ ├── aab859864bc25e0a7b430273941b291f2b765ba7 │ │ │ ├── ab1a9283d7a85a42aff52d1937193ca27a794187 │ │ │ ├── ab3899ee5c2ed560ae6beb77e71e4950fc17aab3 │ │ │ ├── ab3bd8d93632f274ea33e6bac92fec9215c4f20f │ │ │ ├── ab3f300e2417c10f0eedeee88f719e82892e53a2 │ │ │ ├── ab5267db0c03e93e08f51b597821900db93ae75c │ │ │ ├── ab8bd300852ee0d05f0c8d476f4205347466c6e3 │ │ │ ├── ab8ffe370320d075a8c7b9daefaf545d29b7ac1b │ │ │ ├── ab9b4c72f3a16b2e16d40652ec33ca2a8ee4d3ef │ │ │ ├── ab9c711cf8bbafb6cdfd30f945bfcb03cf0272b6 │ │ │ ├── ac0b35cbd93f63ed7452d6acebde72ca9fcc3d81 │ │ │ ├── ac2088d883a0a84ac9d499824adcbd32f90b53c8 │ │ │ ├── ac3cd67c26d777875eeebe2e90c716e8bd592ff4 │ │ │ ├── ac93b3ca2d9c1ec6e07725af461ea07bb19c4dee │ │ │ ├── acef576be556d6720814253fa450ffd2684c3c7b │ │ │ ├── acf314897698e9e208634f10df880184d9a7754d │ │ │ ├── ad1589197b44cb0c659b26869de6c66b103e9682 │ │ │ ├── ad16650f9e472fb459eb487a9f883c894760b565 │ │ │ ├── ad382a856cee976ed155aa5fae9828cd059ccb26 │ │ │ ├── ad4069abc0712cf1f3c8508b699379282bbf556a │ │ │ ├── ad58a3216af0b6f002972233963f6be39c7aee60 │ │ │ ├── ad67e4cfbdacd913d6561d8fe08f456a4341a88b │ │ │ ├── ad705acdd20e8da3a2171681cbf04df9fa98a3f7 │ │ │ ├── ad8af6e7441c7a1e3628b69f1ca22b74068a2278 │ │ │ ├── ad9cdf2ad4d35e3f1e5279c581d0394ae2aa6972 │ │ │ ├── ada6178e8321efd51626a855bc6e5557d68ca3fa │ │ │ ├── add98ecf3dbbc875a84ca24db0f18c054af38335 │ │ │ ├── ade2c248d7512985cd0840191f643e986e49db2e │ │ │ ├── aded7ddfdd7ffa25f49bad4502033ca4a8591786 │ │ │ ├── adf617416382c5deb595144ff94dce09117c3181 │ │ │ ├── adfe9ae4df4e249a66eb91fd2f8b26ee063e6f76 │ │ │ ├── ae32aa63248b35fca6503c67fb4fd2acf15a98ad │ │ │ ├── ae87ecd86f7053ab8d71a8f1fc84c2d2c62b472b │ │ │ ├── ae887143b966f102e6e5967f76ea3c041af92e65 │ │ │ ├── aea2776fad1a4341ceaff3aa6cf21d9c37587a96 │ │ │ ├── aeabf0753dee7e4de87a4ffe6e1414931333b32a │ │ │ ├── aeaf78544ff09661df34acf0ab140ca8f6834d93 │ │ │ ├── aeb2510aa3d77a9c6dcf533982e3925d74a03591 │ │ │ ├── af3246dfb5ebe1bed3d537e239a99af7422239e7 │ │ │ ├── af39e152ec29cf6ef9124bc09c621887cea05402 │ │ │ ├── af4d15714a467c338537aaa00108e2bee33e8426 │ │ │ ├── af58cb52355f4201682a37056445b679070634b3 │ │ │ ├── af5fe2e1f2c809eb47dbe26c8a45e6a55718cce6 │ │ │ ├── af7648fbe02efa3d9188b9b61ce6422012612477 │ │ │ ├── afa5c3718b0a518cee419488c60f2f2741ba28ff │ │ │ ├── afb161887b4215368f593a2d8d8b6bc32170698d │ │ │ ├── afb93dea86c318802ea31536847bc3786c8bb47c │ │ │ ├── afcc94478400491055613ccd42f75d4fa9c1ceab │ │ │ ├── afea0adf1a155b6acd7f6a1aac9dcfd781f953f1 │ │ │ ├── b0225ebc20fa76a5b5efb83881756503681565fa │ │ │ ├── b02921b398ef06202f6f3b3f652c3c8f10888607 │ │ │ ├── b068dde987664207f704c5b73a6444bd16d46da8 │ │ │ ├── b06a48e5c2bc5a6b1fc1fec7273e5642a15c8c13 │ │ │ ├── b075dfb300337efeb5bdabad39fff800ee516fa3 │ │ │ ├── b085cb29b4ab162f71d870e1b8f890fd0cf23cd6 │ │ │ ├── b08ac583665d8a49691a3a09c1d5cc1ee3b8a416 │ │ │ ├── b0a4831326c413d2804c49788050b9f91a6403f7 │ │ │ ├── b0ad1929e6a50924bb0dc2de48e23ed645f857f7 │ │ │ ├── b0c00b0f653fb7d6d9c6d10a355b006e90bfdefd │ │ │ ├── b0c6d5f594246c874ab683269116303a280482fe │ │ │ ├── b0c73ceab30b62cfa56f40cdfd49c1ce58f55a01 │ │ │ ├── b0d9006bd4700ed6403142773e914c7bb257d345 │ │ │ ├── b0e3df60a56490ae4dccf3851d020b40b21b8b7b │ │ │ ├── b0ec063bde9113e41cd5590763cc5a80a27e57df │ │ │ ├── b105a50748888b6356015fc47a88bc2be5715d6d │ │ │ ├── b14851f777181f4d6991a19eb5faf986f6c5d922 │ │ │ ├── b16c3acf4e0fdb0086f5e645c0abf5248401f236 │ │ │ ├── b1776090f6173a9a430ec315e3ed5aabd24b1b72 │ │ │ ├── b1a7636cf60adfde2e1358221f019b1e6b4155d6 │ │ │ ├── b1ad5a93a73ac48400168c0d0d6867c722e2ee94 │ │ │ ├── b1b4eed63248ce097e83d9f1723c6762b7de9c27 │ │ │ ├── b1bf9f8b4545db1b4c96961e0e20f15216c0e8b5 │ │ │ ├── b1c08a839cd0acb873c5f79044f09ba166bfa26d │ │ │ ├── b1d288dfd536ad13a01041e19c9c11fead33ff91 │ │ │ ├── b1e426a1d9ca218fe8dfbd94e4f84deb69cf3add │ │ │ ├── b21f2a634774a50314c4e0ef19018373cfff5761 │ │ │ ├── b25b243c1918bd286e71165a606917ad6566dcb9 │ │ │ ├── b279bf9258b4c48220f05e2e891b91c7b13e0572 │ │ │ ├── b2bf386739903299a1cce995ba58544747eee3f9 │ │ │ ├── b34497bedf19b0567d48c3bb9d3c6c6b7285bf56 │ │ │ ├── b354cb571d5964e5709107acf8b69b7a52691648 │ │ │ ├── b3621ec700f1905ab8a89bd0dc990c56dc5b2619 │ │ │ ├── b36fa07023f7e2c301fca71c92d63d4b9d3dbfe8 │ │ │ ├── b3acffc7854d876acec4be4e8f02c5785c9786cc │ │ │ ├── b3b35af21b57765c4439d83505e2c122bcd9d159 │ │ │ ├── b3e2b23acbebfcbc2e5f4e54d4fd7005740cae7f │ │ │ ├── b3f7745d61088bde2d2244a961085a6e8ca22a22 │ │ │ ├── b3fb8896212c7278ddd055ebe8806a9aadfbdbf4 │ │ │ ├── b42a78220d5bf6c02b4d64f379b4963da854ecf8 │ │ │ ├── b471b7933c10f89f075ebd244fc7dce18cc064ec │ │ │ ├── b4881b1ab0b628b8e08950b8799b2a7b2f90f6bb │ │ │ ├── b4b0e6e8de840a729657842fc3f326a51926695a │ │ │ ├── b4c0e993f516711b0d2941c1993f065eee0512a5 │ │ │ ├── b4d27baa0c7f4d587689db8a9529b71fa55341ec │ │ │ ├── b535e18acfb42d8eca463e3d005649eeec97a029 │ │ │ ├── b537477b73545075fe86dcab51eee08a1eff1f93 │ │ │ ├── b545791a846adc504218666c3218bfaa83bc90d2 │ │ │ ├── b56d0867bbc5b009c7f592e99f5d598f728cda80 │ │ │ ├── b571a84a7a61d25a217f263add5e84836c981aad │ │ │ ├── b592aa01c9d16fda0673296c91e16d85378ef308 │ │ │ ├── b594302e03843a9f9c9551e5065d334f5788b18f │ │ │ ├── b5c23ef36f914bfe6734a376e3ff23afa4056cdf │ │ │ ├── b5f858c267b5596e80a4ca9e1d9d9fc97493a161 │ │ │ ├── b5f894878cea25475b042e2e6dccf49267130d0f │ │ │ ├── b605240fb46dc5b5a62d8e4fe44362074c17cd79 │ │ │ ├── b62a40520073f939f2c0c9f173f5df055dbcfe5e │ │ │ ├── b646f8b3b9e38907889dca9d182ffcb148c5eb86 │ │ │ ├── b64c6d5ba93dfc04d7a168f3316abb231668ca1a │ │ │ ├── b66c4be98c84d4c925dd2af48a775cc657d0344d │ │ │ ├── b6737bb08c29b827385850c321cf5d8413acfef6 │ │ │ ├── b67e4f02f0ff506105dfa4a0171d89ceb6d26cfa │ │ │ ├── b68b738158b1aed99780946dcf5925a67eb68cca │ │ │ ├── b6df4711f8c031a1f3fc609594a2746d2d4e3d62 │ │ │ ├── b6e1970eedbfd9c6a474d94f15274687adf86c2e │ │ │ ├── b71c95db43c402381d9a9673ab063f0735eb1d31 │ │ │ ├── b71ebb4f48a1c213c17c8b1e9166cc38b072dc9d │ │ │ ├── b72daece9e0661e0bd4c8a41d26c73ba8eef4882 │ │ │ ├── b795709244b876a1f75a1d801c74732832748ebb │ │ │ ├── b7a501079daff65d0e768364b11ab44c69980aa7 │ │ │ ├── b7b1691a7efc0fca08ac5b931ccb3dbf5aa891d8 │ │ │ ├── b7cc907a8b0d3c3e1994be68a40873b4e99a5f78 │ │ │ ├── b8079c5bdcff63a0f477e2f79dd8aaf4928abda7 │ │ │ ├── b809617c671f07711eb77d11353900df3a1020b0 │ │ │ ├── b83c1c0b8c3121745e8e5a5de023dfb379736329 │ │ │ ├── b83df399d9754f536f1c099dfad005119a65be7a │ │ │ ├── b83ffefda146d967a06f51678c18eff540980695 │ │ │ ├── b84cd36f16a07a3e7153b397d87779a08b904316 │ │ │ ├── b8500830a3e73890fbb7f1b5e546f8dd9a851acb │ │ │ ├── b8684e0746d02b30dd7444f365d9552810403e85 │ │ │ ├── b8a16da4c5a5e56d3c75e8933ac8d444b9d06ecc │ │ │ ├── b8a400a5412cc152b17a2cda851c5874dd5ead2d │ │ │ ├── b8a97f2ecce17499487b6afbfd74dcdb69711ff3 │ │ │ ├── b8b534195cd5db1dd0cc83d99d7face7ebae029d │ │ │ ├── b8ba77481215495fefc3d9c89e8e4251b1514f9b │ │ │ ├── b8c25103015cf79375d6f576186c9bf014842e27 │ │ │ ├── b8c863f970b2f3c39e353171b5902be0355002ed │ │ │ ├── b8daa1c785e390cba67ca10da7ee578c00efb805 │ │ │ ├── b90034052330d016cb6261caaff33ff9b2007d1d │ │ │ ├── b953ae08ca074cfcfeda2be630b7eabb0a0feef0 │ │ │ ├── b95d3cec25b96ed5bf972cb98ca8c6476eac7630 │ │ │ ├── b95e31c70d4e1c7f52eb020450f422dc69f2b3f1 │ │ │ ├── b960c57badc5a9291e8064176397f05700f998c2 │ │ │ ├── b98b3ae70f7b3075d295829a4a779d63ac54efc1 │ │ │ ├── b9c4f033e767c62469be7d0c9837ff7976269c03 │ │ │ ├── ba1c9764d8c0c80309b24333c675854c1e92edf6 │ │ │ ├── ba1e6bbaa2a233a2a9e108339e2a03d15db6c21a │ │ │ ├── ba213f9e83bc18ee5d889ce921f71786661cdb49 │ │ │ ├── ba60320519e241dc303d027571c1b6b6677274ef │ │ │ ├── ba66a56ebc2679a2d9e33cd52effe2bf5657ba63 │ │ │ ├── ba71d7ae4697eea6a410b7c4d7d542ded867b329 │ │ │ ├── ba830627ab470b34e7d889cad07110a91669d64b │ │ │ ├── ba88104330b37c0458b14c5d53739d04527f803a │ │ │ ├── baa4d60cb12ba51a47909ac8227ee6df6d0dc0b2 │ │ │ ├── baa96c5298845a9d61eb221acb395d2256d66ee5 │ │ │ ├── baa9d2ad62a330c543ec07ad2137ad8de21565a1 │ │ │ ├── bab370c81fa011cfbd5f4933e8e203b69b4613b9 │ │ │ ├── bae295c693b97cb9ce1c49550985444f7083bf7d │ │ │ ├── baf106403ddec9a4e35d93e4d7e9c8858a1db975 │ │ │ ├── baf7af0bebc3219aa43e93f239abf44c3c75cc84 │ │ │ ├── bb00878c7c40b024bd20fd9e026f76cc0f01bda7 │ │ │ ├── bb06616585d2cf60ef82187fc0334f6ddea3aafc │ │ │ ├── bb0848b612e67f32638209d33374606f9f878516 │ │ │ ├── bb213f4cc6adea71bcd254acd7a66de7a21a8fb5 │ │ │ ├── bb4c46289dbd303f6704b3a08d9e02f4c48b84e6 │ │ │ ├── bb4cc97eb2c8303964e3730c003f85cb88a0211d │ │ │ ├── bb7141b532ed1aa0b98bd58bc84ec2e08f2e47c0 │ │ │ ├── bb7fc95bb6e35ae77514934a3e4ffa53a6516e13 │ │ │ ├── bb85f9b909ffd0ec974d57b8e96a0afe8031c95f │ │ │ ├── bbb302be328567aed2f8a9548699284ede429dc6 │ │ │ ├── bbc60e9c8fe20335286b1b4c11f2554bf44bde1c │ │ │ ├── bbd6a4aa19b13347c78851a8c39dc87ba2c6cc26 │ │ │ ├── bc18a41aa534670b3eb06ea552eeaa43a8bf670b │ │ │ ├── bc44929f9083ce895cef6e68e78c51d907624850 │ │ │ ├── bc61d16fcfe7499f1dda3e1aebd61701783f32bb │ │ │ ├── bc63fef6a6e1da11f5ad9cdc8c82557d301f7f93 │ │ │ ├── bc94c09d187af83d11bc158ffad91041ae1cccf5 │ │ │ ├── bcd93267863bf6c12c490fdca519c9a6fb257676 │ │ │ ├── bcdee1bf1b6f002a01bcb15b07e1ceef6be9c962 │ │ │ ├── bcfbb863f9751dbc9e52565fa18f52d7cfc28dc0 │ │ │ ├── bd06f79eb234682d1b026c5b614cea268261d69b │ │ │ ├── bd10e29dccdef5c1bc2693b295ca9c3ee1a5e9fb │ │ │ ├── bd4570befca425281b554426e78e723b29b91aeb │ │ │ ├── bd4b0d5ede1b9b28ba821e22b21d2e67eb35fb46 │ │ │ ├── bd5b6bd1cba3b3c9511abe6e7ba85869cc7271a8 │ │ │ ├── bd647eceba7eb445528903854da69225eb46a33b │ │ │ ├── bd806dc6dd950acd2fb4799772f9284b52b3eefd │ │ │ ├── bd90aa727c6f46c0b214029c4cc55665db207ed4 │ │ │ ├── bdb75495237a21c1632a1d8002a2de43c75cbece │ │ │ ├── be342f285479f59388d4ad299b262298ea0a194a │ │ │ ├── be4056e6d4621f67f649cc023b36d0616763fb74 │ │ │ ├── be5fa21ede21c3ae07d18916186307eb0dbd0b20 │ │ │ ├── be6dd32445672ad01a41728099573f056d19f11b │ │ │ ├── beaac08761cf0537284bd2fb73e52c21bf944e0e │ │ │ ├── bebcb9f288f4fe614ba1fcc940d72dd3a2e9182c │ │ │ ├── bf0031c6d9edfce82c4f7c49f277cbf11c628084 │ │ │ ├── bf1ad139661581e23e01c40061ebbcbdbce507e7 │ │ │ ├── bf2b441671494bdd813cbde459c3f201b5dc132d │ │ │ ├── bf34c8983707b06356e258d949ea5d5b386f793c │ │ │ ├── bf699d29a3431d6314083edeeb34fd0d30d0e88a │ │ │ ├── bf79de65a5198ccae719f56cd87e06ebfa963388 │ │ │ ├── bf8f7dfface9a3a19ae105b018ef9c8464a7766a │ │ │ ├── bff5be66a4aacf336f6a1a8aabdf35a37bd49c75 │ │ │ ├── c0039aba73061b1e9d1b5673c11d9a6fec6c2d2b │ │ │ ├── c0201387de1a365edea3ae462c8e87757ac56e21 │ │ │ ├── c0264fc040cf13b7e91a6413eb4b7c76c194b45c │ │ │ ├── c02fa738eb666819f177a296b855df242f3744a5 │ │ │ ├── c04290c4f9037a6b82b7d2392c6c80c1ae11f80c │ │ │ ├── c066693ba1a2191967ded9338dab201a79f31370 │ │ │ ├── c06e8cd4278bfe18806835f29e8892fe38588b77 │ │ │ ├── c09fc10086b95973815a1c9f85b9e89af0b68a27 │ │ │ ├── c0c65b781da778eab58a96c85067f90b2d4d1f4c │ │ │ ├── c0d2b1edf6f56cba1a8e2d0b100cb918fd7f803d │ │ │ ├── c0d30a73338909cf56a6d97fed0221e78bb7731d │ │ │ ├── c0ea13628224c7cfa08a24dfe6cac5360c02d61f │ │ │ ├── c0f5b91a651c2d181d2e204758d6556b2d362c11 │ │ │ ├── c128857e0f643e229c430eb8ef7d3f5aaad861fb │ │ │ ├── c12b71a60e309ebef55284d493cfd3665116ac35 │ │ │ ├── c146489c520399688a56c27fa5210f00c10e9e5b │ │ │ ├── c180a8fea16357ccb1c9e9a5b1fcde5e0137ba39 │ │ │ ├── c195e2cf967dde5160c0de3b6a514dbb2ff8485c │ │ │ ├── c19c13729ac0ec5c7e396da5494a3f513d31d8e8 │ │ │ ├── c1b84b02f4cf106428923ebb095dd6888ae0ac50 │ │ │ ├── c1bff9e88ae4e9b8bfd1976fa22c1802e6db3962 │ │ │ ├── c1e5922d5f60798c78f4d0d669795bdad1a0801b │ │ │ ├── c1eeed88c600ab669ef89bb18d5ef6a6830d4f0e │ │ │ ├── c21065afa4b19740633e3c552a080169d12b4afb │ │ │ ├── c2268af10452034a5d5f9268c6f6797ab805a459 │ │ │ ├── c22963b5f52cca482bd79213fd1c9fd9819b85dc │ │ │ ├── c23bb15b95f0283493b5e9660535131e08c4b442 │ │ │ ├── c23dc3dee1bab058e9dda39e357268464aff6993 │ │ │ ├── c259be6e071636a46f638dc71fbf337480a65d62 │ │ │ ├── c2606a81031cc7d45d665ff29e83009cdaeb09b4 │ │ │ ├── c2615fefcd8c48ae15d7cdf715cb7cbe15365bb4 │ │ │ ├── c274fc041bc18ec36b6fc361335ee8c903ba6539 │ │ │ ├── c2b521f99f9142ffd0f06f35fdbf0a1e6db3b411 │ │ │ ├── c2bc316e1620048c72dc6375bd6c4de0d175594b │ │ │ ├── c2ccbe9e06e6c7ce6e43c0b381322fc7dc10a2c2 │ │ │ ├── c2cdbf0cad554855e5a2c77ade2426042fd077d0 │ │ │ ├── c2fc3139b18939587fa9376d426b5ed6e5a7d384 │ │ │ ├── c30440e2e36842767c6880d3419ffd67d8fc65e5 │ │ │ ├── c30828b92e910f121013ae0e7e80f112ff29c40a │ │ │ ├── c30e1db5cebdf16c793ac3774df5940ba0cbd27f │ │ │ ├── c34e8364c057d48255c31d4626eee97cb90971f7 │ │ │ ├── c34ea38700b3874b1fc56b98fba764e26e442bbf │ │ │ ├── c36f9ecac75a1f8369062bd659d7be8116d9426f │ │ │ ├── c3759872dcc57d4041c64cfe3164f0beae9647dd │ │ │ ├── c37b0f05074e165869fb4e36093d5d05e7f5cd58 │ │ │ ├── c38df517f192e8ee8b749587f2286408e1add7af │ │ │ ├── c3a855f0999c9f0c734c21ec479b4a2de052c197 │ │ │ ├── c3ca44e765c59aef19ebc14444cb23801ff338d4 │ │ │ ├── c3f3469ae6022ba9a824d15d3e5c6966ecd2729f │ │ │ ├── c42ba6332f5103b6c07a6d7b7c7a96e1345fcad3 │ │ │ ├── c4499beb83fe2bbc215490890a252106247a0d03 │ │ │ ├── c46f7002e386e4c4fd5c63195b15a2720dc604c6 │ │ │ ├── c4b2c2074e18699523a8e60939dabe323e8cfcc8 │ │ │ ├── c4c19d4cee5d79334aa9c0ff61f19d321cc3941e │ │ │ ├── c4e28343af816c29311d37b8559a05b14d797dd9 │ │ │ ├── c5c550da4ca7e932cdd65a9656f2f7c611148d24 │ │ │ ├── c62a6dec1ec0c7508b82a35dfbcc1d66455eb241 │ │ │ ├── c62d08fa40199eb68353dc3045f6c961f21f080c │ │ │ ├── c63b3815a0dae098fa0dce37acfd79f213436d49 │ │ │ ├── c63fa7c5e9f3cfa3be54296de8fcb8c5bae42ab6 │ │ │ ├── c66c43a4b77a41b0bcafd8714216e0e515ea32c1 │ │ │ ├── c671d0d61110d22335aeeff604afc7a78832a1f0 │ │ │ ├── c684723b339ed9a247b5fe843d2111fcb009cbf2 │ │ │ ├── c6911c815fc4eb1fdd0b9ab9cd09d3f6af2c6188 │ │ │ ├── c69155ad942486c3313ec96fba99eb4b629b0b7e │ │ │ ├── c694a3b9670b92c47faef2482e1c373a96c84b7b │ │ │ ├── c6a2dc24e570bc2a810731231121944aa2c4a595 │ │ │ ├── c6fa56d9a3cfa039c883bb5289ea577b65e788ce │ │ │ ├── c709197b022538558c64745e06cce6340703a73d │ │ │ ├── c70d23ebccdc1ea73e6448b1df58f62d71582adf │ │ │ ├── c71d9516b42225f3514b4d1df627c022e4817ee0 │ │ │ ├── c7252d6f48851dc47f8c3177537e12abe69a084c │ │ │ ├── c75d0a897f9c6981d81da8b49be331ba03439313 │ │ │ ├── c761e8c4c51ea45aa6c56b949fdc22e5d4c60cf1 │ │ │ ├── c763c8080d8e8e78651eaf9140b7aa3fef1d52d4 │ │ │ ├── c77f06b7f82e62ac50865f5ee4163ae369969020 │ │ │ ├── c785d388c9a15886ab980f88b666d4945c7ee4a6 │ │ │ ├── c79333ec6723390b7f1563f388c7a50d86f860b2 │ │ │ ├── c7946ca286a4c1e04861f5fe7ff7982618728e8f │ │ │ ├── c7a2d84c0203fa2c48f932ed3cdb57e9bc3d4cd3 │ │ │ ├── c7aa7f6d958c6e29a221a767f1d7b3c103fe86b2 │ │ │ ├── c7b48c2518d6d2a2a5acd628f2fb397cad2ac0ea │ │ │ ├── c814f8c932eb8ff0b1b54d8a85929406a22a72f6 │ │ │ ├── c8172ac90dca46ddecfcb6abf992c70d492bdaf0 │ │ │ ├── c8203a41b6f45793c2150ed5554ab5bf5c7eae94 │ │ │ ├── c82943e824916226a82dbcda450c1cf3f21df1da │ │ │ ├── c83f86babe52fc934414d829d4969407bdaa8de9 │ │ │ ├── c85880f71216bacfb5f45a917040c76a5b933f5e │ │ │ ├── c85ec330c8ffb17623ec929fd4a198c3b768811a │ │ │ ├── c86c77b200bac67eba1a81988b36e0764528deef │ │ │ ├── c8e586d3f61c1ad22568794bbfcb69f57cb8b000 │ │ │ ├── c8ef39151618f6cc8716604cb9c29f93559b5a3d │ │ │ ├── c908a5304c6a71d150881ee923df19a58e37c8e9 │ │ │ ├── c91a0b63271792838de6f8620c116c19028be7d3 │ │ │ ├── c92d0b7830a59c91b7478b9bc6537abc9104ab24 │ │ │ ├── c94bf93a205b5120777d3d7dedacadaf6c732df5 │ │ │ ├── c95a348b7638eb340903fe3cc3532859ffe5403f │ │ │ ├── c965920ad9808bd3f6a009ce5335213895163c4a │ │ │ ├── c968d693525b4f56eb70b070dbf41555841fa170 │ │ │ ├── c97c22cac658b5a97d90aab28ef2a0126a80ce6e │ │ │ ├── c9810cb06137edb22aba29ce495e0f5e87073b06 │ │ │ ├── c9888f4ae613d1778de5399e9c17e6e517df9292 │ │ │ ├── c9a84f25b1d55cfc33df56ee356e86772a479352 │ │ │ ├── c9addf4f9fd1a956c97c9babd5981d0c8295e152 │ │ │ ├── c9b398e28803f0f2e675448f50d7f4d8c39e8991 │ │ │ ├── c9d4c34b8cbf8c16d5b1e01af0f0541cdd36456b │ │ │ ├── c9dd51e291d1902fcc5389ef9f70290ea166e35b │ │ │ ├── c9ed258ea27321037ce42d665a00191863c1ddce │ │ │ ├── c9f4f38c06357e5794c082ee3a691a02193ff1e2 │ │ │ ├── c9ff164d902f41698dc1714ef130057761a13f8c │ │ │ ├── ca067c02b5a5e0209c277a0cea71db50a16d380f │ │ │ ├── ca0a2329b586ff39d07383acaecfac1982afe0df │ │ │ ├── ca10907ed5b956b8d7c600609307e951fa48d8e6 │ │ │ ├── ca10ab334b15fc1a219962a002ba20266142420e │ │ │ ├── ca3a2137d38c1e9a98dd585fbb1e5e6483a855d0 │ │ │ ├── ca4f72eced8e3ace4cb06faea7d35e7831c1e5ce │ │ │ ├── ca4f932e8cc3a4b016fedf455e955c89cd7237bf │ │ │ ├── ca67aeff72a1ca354129ea9f32b49e63219b5d98 │ │ │ ├── ca8e90d773aaf3a6cc447fa963353434f82c0e50 │ │ │ ├── ca8ead844b2d1ee6d2526ed1a548996bc943ea68 │ │ │ ├── ca9fc42da81222da6dec277f6346109bf564fefb │ │ │ ├── cab98434bc48379e0a365fff01d6b79bf577457a │ │ │ ├── cab9a4b9aa0799313bf8c71e90011d910fd2eca4 │ │ │ ├── cabd7d24e6498c820ccd2a79a03cc481607909e5 │ │ │ ├── cafd0a9a6dab6200dcb88ecbf7e265de1ad5d317 │ │ │ ├── cb181959ea829e3c8e81c95a1bbce81b35f8d2fd │ │ │ ├── cb1b57e08db865390f1b4cf22118530463b721aa │ │ │ ├── cb5cd2d881a8e8202863c29e2d692b6245167dd1 │ │ │ ├── cb7c58b77b079764dd1fdd95626fced2ad539c7c │ │ │ ├── cbdd9f9ee3d06ce2cdfe2000194d0fa14bb03cb0 │ │ │ ├── cbe16c2c588c6bc7000fbb04188632167236d008 │ │ │ ├── cbfe3b47d8728af1b60451af99e980f90dc89668 │ │ │ ├── cc06cd6c0a43860436758eaf21a715c3ecebb6f4 │ │ │ ├── cc13210738ed00cc6f24c6bdcc72bc63f13783e2 │ │ │ ├── cc3fcfad22ff1374fc57610045f054311fc92f6d │ │ │ ├── ccb6fc2bd7df140d0acaa9fa4f6c64be65339a60 │ │ │ ├── cd083f5472e5c5b1f0a2910e5400ed9fb0e38379 │ │ │ ├── cd2bb450b14d6d4aeb2383f17d0b52532a6d60bc │ │ │ ├── cd2f80cd83fdc9c096ed0c6e1e02112a0e62dd16 │ │ │ ├── cd4a620abc44efff9ec16d12232d21d35383be02 │ │ │ ├── cd536df731fdebe8bbafa86ebef1f6c819648a78 │ │ │ ├── cd553bbac6c8bd33ad432ca2077facbf41604f68 │ │ │ ├── cd8b40b4ffe13dc923550924d4133d5ac918ecc4 │ │ │ ├── cd8ca448ef6a3c3fa7536eee563579389b399c7f │ │ │ ├── cd935e81f7b958dc94cbb682f2c926e1e63fc213 │ │ │ ├── cd9562d304291faf33b2752268819af3d9fdd593 │ │ │ ├── cda64a68115a3ca8971a2747b360b387fbe1d1ec │ │ │ ├── cdaa800ed715e873d65a75ff494c085689777769 │ │ │ ├── cdae175fecf9783890ad4364fcdb7e9a26312c86 │ │ │ ├── cdbb9c9c88d727637e88c5e5f34b796e03a77c9a │ │ │ ├── cdd70dfc5c39ec02e5e48d747003dccc345d9c35 │ │ │ ├── ce08102de2f440a689645ebc57829a604424b751 │ │ │ ├── ce29a0262edb0e4c4a3905e19cb08c9a4e8318ba │ │ │ ├── ce4f3f6725a58e41e3545de8f93475f0f9402a52 │ │ │ ├── ce5a6e30faecc2d2f249b1bb1b0a21cbffc46674 │ │ │ ├── ce5c007dab411a6a225c1b09181578eaf6edf364 │ │ │ ├── cea069b190b73ea7c41e48275d6d0841d7fdd8f3 │ │ │ ├── cec62d6028ecb0885e4adbb89b0c33222ed71d55 │ │ │ ├── cedf97481d67a8a89199abfe8c15570cd253967d │ │ │ ├── cef118940d5799540be8721e2453120639fbe14e │ │ │ ├── cef395bb5063aba1aeaafde86a8bfd4c3ae80b8f │ │ │ ├── cf1726d92ba0a57e5cb508f7f38cf8c30c31572a │ │ │ ├── cf19361572439227ba12b4d90a84b45c9c77a6dd │ │ │ ├── cf1b9fbc48a705e782d90e0caefa83731663957e │ │ │ ├── cf3ddc0d11192bb67b1d1a9c46dba9cb99e1ab37 │ │ │ ├── cf87f1c7fe8d84db93cab39e5ec4fc004b0daf45 │ │ │ ├── cf99a5aabda5c420d162ea57e1d44c83b4a5f444 │ │ │ ├── d01804b3f650a230ba4caf6f35710074094ef4bc │ │ │ ├── d018c44a4a260f0faa1c368b22e6fd2da47b4279 │ │ │ ├── d023d686290f14c19a40f74a18a2c183ac38c02f │ │ │ ├── d07029fee875ecd9778957b1eb1b6ed3ba90c94a │ │ │ ├── d076c78276e47d5f2551df88390966202a644ad4 │ │ │ ├── d0a5a7631c5914f69f44abe8d926e7ec265b3853 │ │ │ ├── d0b362a6e10e2e3ca3df573c3918408d11230109 │ │ │ ├── d0c14f7b59f5b7c5e2348a842c4f17589992edef │ │ │ ├── d0d80b81785e11a47eb4778cde0392ceee57d442 │ │ │ ├── d10cc817535fbf7ed3ccccfffd59542e31fd811c │ │ │ ├── d120192543d7524d72dbae6640c1fd01b655ba8b │ │ │ ├── d13e9dcbf612e2b605c913bf461a40c14c78981c │ │ │ ├── d145e690ead8e8b91dcf655a058473fba40e05c4 │ │ │ ├── d1624ab2e4dceb28dc1e7d8f042d85271b474f44 │ │ │ ├── d17443611cb2c74ecfda516700477ecdd4ccd1e8 │ │ │ ├── d17802655b5504bb0405ee7934ae6e14c9c2f6af │ │ │ ├── d17b2da02d1d622d7b71dade71d9adc392999c5b │ │ │ ├── d17e92c55da82ddc95d75ddd15779fff2868ff46 │ │ │ ├── d209841a9bb6b9ed3a4954465f454a0d304ef888 │ │ │ ├── d263cabcd95f3dae465820283cf9b428e89c02f6 │ │ │ ├── d27d3711e16baa8c89ff9c90b6ed0622ca86ff8e │ │ │ ├── d2957d9af2c85119d0e66bf643c7eb85bda86170 │ │ │ ├── d2c7c0da2861f14114f11766107a7b8aa6efd73b │ │ │ ├── d2d896106278d4a3d97f13f67d9366baca387121 │ │ │ ├── d2e69860ee1527c081669b81f428a0dee46fe218 │ │ │ ├── d2f56cc722b3fc0ac3792e7c09a53592a22039af │ │ │ ├── d2f8f204891c46f5ba28af13b77da60a054ed30f │ │ │ ├── d33cb0c2e7c01d420f375159f3d266e71d9c3bcf │ │ │ ├── d34c8b66d9e51e1f51b9432c19d0d95ce51aa297 │ │ │ ├── d35d96943b798f0362dee33b1c9dd9f5ce520bf7 │ │ │ ├── d386337a1d0705a7cc519dc2e044e51c1831c3f8 │ │ │ ├── d3918bf85a56fd7561082f401a5ebd4a0d642f87 │ │ │ ├── d3abb997507d97ede96a2ca419dd8554e22db558 │ │ │ ├── d3ad578f5f3076aa52c4e35e8a0002582433fef9 │ │ │ ├── d3ae88e79c1801c2da2ca48244ec5455bb3abe76 │ │ │ ├── d3d3e2a151a062b9f319dd5ba2d382d38c8c95d4 │ │ │ ├── d3e5ffbc18b1ff4b1db6426ef3962f8c9cf5cdf0 │ │ │ ├── d411fdd25ef73e64648572aee57803f358cf4bb2 │ │ │ ├── d4208a5824d1318820b3784412f424db595f35ae │ │ │ ├── d42eec126dd7b1e4c2c574ddba68f4d0228c3d09 │ │ │ ├── d48d445fdf8825eb982e112320fe51da22271d30 │ │ │ ├── d49f2424f7e47981e92cdca8a120fad3b5b46351 │ │ │ ├── d4a61c1883d529642358ce1ad476eae28f347140 │ │ │ ├── d4b2d30318741bf9642c79ca255322762ff5a669 │ │ │ ├── d4bdc84c656fc906c865b5369626edd1bc0d575d │ │ │ ├── d4bfa057df6de164cf5907d1054f7b8f37dc55ca │ │ │ ├── d4d9f5cbd1cf9b75c9821d5d4746491e46efecb0 │ │ │ ├── d4eb08a9f93ac1b16665f4266fcd570b760e0b41 │ │ │ ├── d4f11edc0601915ee85baffdd4721b1d1b3b60d0 │ │ │ ├── d4f65e281be1feebd4750e113b05138a9c44f486 │ │ │ ├── d5048f880c8259302815a101c17c687a6ddbb1d7 │ │ │ ├── d52e561715cddf6ccf811873e1d9570a5b25b677 │ │ │ ├── d5466e451d61467e6bd45f66d7608457be8a656f │ │ │ ├── d54c6961bb95000149d7cffd738f1f34eaf1d825 │ │ │ ├── d54fe454199d96dd8e1ab2d0069417d2b9be7cf7 │ │ │ ├── d573fa9122441a358ecf4c86ea6af4d26e08d93a │ │ │ ├── d5892cc02088b2b7e11febc39b2d7cd9ed96fec6 │ │ │ ├── d58b0cd6e4cd0f7d08d8c5cd8f64fb89bc6c77b3 │ │ │ ├── d5ad81a47205ca9893336dfcc66e370ee84776ce │ │ │ ├── d5f073d2ccb1d4bc1f4bb2d64971cda535f3abc4 │ │ │ ├── d60ddd04ef59ce7655ce0640bb9f05a050c50572 │ │ │ ├── d6114c41966cf276af2ac91a43b0dcfdde3ff6ec │ │ │ ├── d64045b67fe7d9bbac6b1955c9709dc8f62c2574 │ │ │ ├── d65a0ff7ac01950da5c822d87cd1f1b94663c71f │ │ │ ├── d66bdc15b3bc47537708b688679685d7823933ec │ │ │ ├── d6a9e0d913d7e024afc093007237124f4a34364c │ │ │ ├── d6bb41e59dad21fc3ff2d5bb0c784b27307ee4d3 │ │ │ ├── d6e668abcd05531d83ec0bdff606bec2368882a8 │ │ │ ├── d6e9b28f9645fdf80b2547f4a875bc298680a83f │ │ │ ├── d70c950a9b6157fdddbd8eb01fed07f12638844f │ │ │ ├── d71a3d01673ec097d7272cd0fcf4fc12f19a90e8 │ │ │ ├── d72363609fde245d8d04d59c1d9e2386e97f61ec │ │ │ ├── d73e808e6fe07bbd4cac3998bbd227cb333f3860 │ │ │ ├── d7435dd29bb609d8a757deda3c46bae9522fafb0 │ │ │ ├── d747c65611d3195e76faeea3dbaca70f0255d690 │ │ │ ├── d7482427db68b72ab957e74167dbc8c28842b070 │ │ │ ├── d7491a450345ac8fd8bd2da583d6974224917a83 │ │ │ ├── d750ca1379d7933d2b0750e621fad549663516ca │ │ │ ├── d762cef9eb8735ca5282dea549336970c32f0470 │ │ │ ├── d784977d5fa21c31f0f510f5a1e2d50f7815c63e │ │ │ ├── d78a59aa9fae45d7cbfb5d42a6d57744818f4f3c │ │ │ ├── d78b2cc4912fce258a371b34976f623504f00bf5 │ │ │ ├── d796184dcd2791587af889f67ff0bd146da22bf6 │ │ │ ├── d7a0524afa7b58f919577fc272101adacde12154 │ │ │ ├── d7ae7546c73cd724ed329a7e111b1874f3fad3a3 │ │ │ ├── d7c12a570bce792607b3d5f23fc34ef6392109de │ │ │ ├── d7d1782dc0b7c5e12cccab548a33619bf58a1db8 │ │ │ ├── d7ed3928aecf2d3acbca2fb8d2ee7775f7f52ccf │ │ │ ├── d7f54f75c60667b7fd883f34d666d917d0b88809 │ │ │ ├── d80fa30ad1a0824f0da7b212e606ac5496c0715c │ │ │ ├── d86ea65d288be1fd03e9e19e503b17612c637374 │ │ │ ├── d8ac2a246d17295baa73602fa55f5ef1d6edd095 │ │ │ ├── d8d54db51b8f8299982f8136c6058c9e8063811b │ │ │ ├── d8def6ae46c2ae1d19b457603e2015ddad467ad3 │ │ │ ├── d8df811ed2f11c79fe945f4943ea3299a251ecb0 │ │ │ ├── d8e4caa314d508c3062410f0d680eb589488140f │ │ │ ├── d8f77e44fa8aab802aa9131ae9f319611a054835 │ │ │ ├── d915944728f949574638f5527cabdee757340ecc │ │ │ ├── d92c58e19437f5a57d606edb988ebe5449b4db1d │ │ │ ├── d93387aa595f09f4e40642c715176275012422f9 │ │ │ ├── d93dd1d6d2d9b39d77cd72571effaec51dad73cf │ │ │ ├── d9462d451520aea896848f14167cad63f8eb631b │ │ │ ├── d9632d4e4f8d7cc9db523291bb7442332d7c588c │ │ │ ├── d96eb1935933e5d8a16bab96d06d05f8b1ab6619 │ │ │ ├── d9721f612be2c4596ef2507879885c69a5e6e58d │ │ │ ├── d975fa857300c644b1b8b86b9e5579116325e3b6 │ │ │ ├── d97fad7ecab4d8f234efc71d9e0019d3cd6866be │ │ │ ├── d9d8525ff675d165e7bd245edb10bef8ffbabf37 │ │ │ ├── da15d30445dcabf73491b38ff9b7fd6ebf09fabb │ │ │ ├── da20174fe1299204fdf8cca351a424cf681308a2 │ │ │ ├── da3eafaf969feb19889dd744b3407db1aa866e06 │ │ │ ├── da802c4897e37a5e51f367edd23444c11faa33aa │ │ │ ├── da8a14b376513348d7ee34b10ff6883f15cc6fd5 │ │ │ ├── da91d607fd954405726ab36fa5677e8163634ff7 │ │ │ ├── daad29bf36401da76f1b83f5cd1cc0335bf5c14f │ │ │ ├── dacc869b2d12c823c9a4bb00e5edcd51d35c5978 │ │ │ ├── dacf3352a5bdd39737fb53affdf284ce61f4e97e │ │ │ ├── dadf4bbba1d78a438712afd4e84df10275987f0a │ │ │ ├── daf266d227dfb92686b3d8cb80cb4d2c4e849468 │ │ │ ├── dafea52d56a314eff0b38df4ddd35be40d4f6d24 │ │ │ ├── db01c81c34e5e86ae44bef70289a143173916fb4 │ │ │ ├── db06c61fa468b40855c83db915cf67df55dddeb9 │ │ │ ├── db191d70ebee38a520718fe3a295896a1840f111 │ │ │ ├── db2f754795e1478498a59b3071a7852a32a70b8e │ │ │ ├── db41febcaac001cb453d4a2ca2a285784d5a9cd8 │ │ │ ├── db5b9f12551bfc0e07e9c89d6d5971df6e4eea17 │ │ │ ├── db715816bbafa4a288124a98d0cb4df6a364cb3e │ │ │ ├── db81d6ad0913097959d953bb6c2e7d576f846a11 │ │ │ ├── db9eba0b2b563ba067b7fd8e8ee5ddad9b770dce │ │ │ ├── dba31a12d1adba28878c2a0b52b782a5c72d9972 │ │ │ ├── dbef858a545baf2d110f1d0e917e4ad258acf993 │ │ │ ├── dc01bbbcdac6b5bb939e4be9ca56e5b8c3d165af │ │ │ ├── dc0806f74a893b88a54642a35cd820535fde3ed1 │ │ │ ├── dc161355dcd6047181d0cf4e25b6a5525f6fe50e │ │ │ ├── dc3539d6d3a6a1eaf48ce5185a088eb43b9e383e │ │ │ ├── dc480267e0ef9ce538b42b77872f2b3532c35322 │ │ │ ├── dc57d8ffab2a6632708a04cb288629b09aa5c82e │ │ │ ├── dc593bc1e5ac44230400eae2d39c99148ad34e4b │ │ │ ├── dc6dcb26e66c42982855aa1a52a31fd33b250e19 │ │ │ ├── dc9395f17d85f800578e0d6e8bf89ad9746befb7 │ │ │ ├── dc9899ac6fe73116d5e9f16eb5d414386eaf20b6 │ │ │ ├── dc99d264d246e0de31744757d56e34f81e69221e │ │ │ ├── dca299a0e651d9aa555003ff4a5031f3fccf9743 │ │ │ ├── dcaa02212efb1b1d7b35ccd1cd382be6b3e66e71 │ │ │ ├── dcbd31842dac9e7cdaf7ca65e510582bfd1d1a9b │ │ │ ├── dccaf2fc47adc1a3b05f03d5fac2a95f989db10c │ │ │ ├── dccd7c4272928f022003ea9c7aaa12dcc004a54c │ │ │ ├── dcd041ba07357566b4ee1ed3cbca6574c6154f10 │ │ │ ├── dcf7577a80ecef6f3ca732dc2e3adaa48e682fdb │ │ │ ├── dd000d20a2f313c18520373a1f18e05ed9a150e2 │ │ │ ├── dd0b6ef4b264cf0858480a3460b856a1c8f6dc1d │ │ │ ├── dd51571565035f293d86c40ad779317f87aedf8a │ │ │ ├── dd6e129061e453f9a72be030e9baeee3e56fcf0f │ │ │ ├── dd8c174c7b3d3ef26b6db13442b39a50c7f55222 │ │ │ ├── dda325195c906944f23de872fa78b2af88631c09 │ │ │ ├── ddaf37dc11a8574b722f076f36e746bc7c60e215 │ │ │ ├── ddd4994f43b538ffca8eb9b28ca5fb499238d0b9 │ │ │ ├── dde699e331a7df59bcdada620624b5ba61dc5dd0 │ │ │ ├── ddebb704471c13ddfaf31413aae6c013515a3717 │ │ │ ├── ddedd372fed9df45da4d1a59cf4f5cb35009e49f │ │ │ ├── ddf80ae28fa37fbe9cd6a838ae2c428932ef3961 │ │ │ ├── de08cbb895403680951a2ebc90561ac53b1a1f4e │ │ │ ├── de2a5caabe3e3b0b1b01533e95ed8f482c6ba0fc │ │ │ ├── de4f89a55a6d907d16952ca4e4166a5979c39c8b │ │ │ ├── de5a7c1447572e08c6b28e753fe662ac083fd6d1 │ │ │ ├── de5adc575b18b1c34a68e95cecf166f402e523ff │ │ │ ├── de5af33427175b7548895fa5441e430afe11d1d5 │ │ │ ├── de6875a737b7c8020f44b1c99b70c4853e661ecf │ │ │ ├── de6cf2f6180404aa31b1db7d09cf2baddd601d44 │ │ │ ├── de8a035daf19e89e29ba0bbdd71dffd1f9cadc5c │ │ │ ├── dea753eea55e305608844a4f00655549302ce7dd │ │ │ ├── decd88daf9600a38bc143777492f37dad4565eaf │ │ │ ├── ded66ffb0cbf19f233f516bd3c63fe712650ef33 │ │ │ ├── ded72412b30434c168fa06e48b7e054269d006c0 │ │ │ ├── dedc75c0c2ee756e9070605ce546167cacfbcaca │ │ │ ├── dee101172e339916048ad363fb6995306d7dd142 │ │ │ ├── def37ff0a6957f0a571488b66a768f20f7079048 │ │ │ ├── def74495863bbdf9d1af666161152708f2ba582d │ │ │ ├── df029e9ebb9e83aace8f0071d2840c27c3ceda07 │ │ │ ├── df085e9114f63f74c86f24312e70f7b5318ad9fc │ │ │ ├── df12a4966bab2fafa4ffe3a2ffbbbe8d697046c2 │ │ │ ├── df16a0297efbbe308fa83a0f3e6ad417689b028b │ │ │ ├── df865486869273fb5f7adede25fcadcb18ce2221 │ │ │ ├── df8de808e45c8839831abd0deb0cabf9143753a4 │ │ │ ├── df8e03791d82b6610c2c15664032e32589ea35a8 │ │ │ ├── dfa3c5fef1b463d98f523033ec70daf8d4bf8803 │ │ │ ├── dfb36ff8904f4e8107d8ba666de3e5f94f741bfe │ │ │ ├── dfca4159ab78bba17ae0d77f088b5aaeb3144266 │ │ │ ├── dfe3a4307a38993f68b0c2518ea2e3e590b0c9d1 │ │ │ ├── e0128963856adfa8520b26e571a93610b5355887 │ │ │ ├── e03443f852b194c164bc4732fb9c5cc86effe4f6 │ │ │ ├── e0588caa737bfbd960ff3fd219ca062193aa6bf0 │ │ │ ├── e0aaba61fbc722b30669314cc389d44b8f989110 │ │ │ ├── e0bbbcbab18f481daf5b315491e268254f4983fb │ │ │ ├── e0da4e0fe645f0a953ac5735fde4706cca9e1197 │ │ │ ├── e0ebae4900e11a9672f2ae78e61178aa6247650c │ │ │ ├── e1087672834b43c44e37cba854b5b9c9f7179a84 │ │ │ ├── e10bddf4873386e1fe3f6dc0f2b20f5c151c89e1 │ │ │ ├── e11d98e0003ce918a6fad19f550ea0702a879911 │ │ │ ├── e1326c178bf8e7b80cda8ea9f9dd86938329c849 │ │ │ ├── e147111796d5b53a6bf6dc9458c50027b4d09f87 │ │ │ ├── e14960a185290ebe95ae6279b9e869e837251710 │ │ │ ├── e170c4afc7cf3aa9e0e5c2670686778994fa4f11 │ │ │ ├── e184bc711398d7c0c1fa6934192fda6c555a1cb3 │ │ │ ├── e1b11848fd01dfa0ba32bf126463d9d364ab4313 │ │ │ ├── e1ba585df080f7b1a7f8f2c7db5dd610f19174de │ │ │ ├── e1d952db862331ca79b0a9c72c162374fb1857d7 │ │ │ ├── e1e49dcfb28496b89f4ea5ce3dc0d76d880076e4 │ │ │ ├── e1f0807d7b3a4bba613963e80beb7c74850d5c28 │ │ │ ├── e22480aebb82f3343403252198ba68a247b6d046 │ │ │ ├── e24851678d123d31e1507cb51348f5b1dc101d4c │ │ │ ├── e2496a88dd988d4f3ef82308c3cca33a874d45aa │ │ │ ├── e255d1877a2010d7fcfc04ed18a7a010df14a2c0 │ │ │ ├── e25fb2f6402ada66247ba900b01f074eb85ba330 │ │ │ ├── e279990fd5d183e1d8b4f404ff9bb849d49c365a │ │ │ ├── e2d5ca40d2c53fc997406f6b09aab24c3df0d72c │ │ │ ├── e2eeef8ece1fd34ca3dc565f6c64e1e27ffe4394 │ │ │ ├── e3196566970071a5ddde94e45545b255dbb827b6 │ │ │ ├── e31f0de61f44c1cdc4d261d497cf718662ce97d4 │ │ │ ├── e3201e6cef5abb4e32884e254d83db6c48c0c98e │ │ │ ├── e3588db1c621c20dd15839f0a47a91d2b3a7c779 │ │ │ ├── e35adac42c2fa3fac81b5b56415001d9ef213aa9 │ │ │ ├── e36c31c772e822a277d29a41f45a505e97121618 │ │ │ ├── e37bd80d8483f80595f8de680651a88967e6b765 │ │ │ ├── e385046269e21e18e9615b10675db2b779814ea6 │ │ │ ├── e3cb84cf87cf0a5a0e394a62331f15e54cde54f5 │ │ │ ├── e3e431ac9b495d6b12f584909dd0891e732ef378 │ │ │ ├── e3e86951be6edc4911741f8779b8b81f8e19669e │ │ │ ├── e3ee89b296eda3cdf6b73af88989c9879d826a5c │ │ │ ├── e43e0f4dd6d04ff5cb7feb566ac7effde65eabaf │ │ │ ├── e4400ed471cfae79f01e699c1535a927cd7db111 │ │ │ ├── e4403314230ec5266c263c14b3167d0495467abb │ │ │ ├── e4476c9611f68d7aed1329b54ac787a7dc19d3c1 │ │ │ ├── e4549906b6821c9cfd2bdad13fcedc9f2ce44c8f │ │ │ ├── e46150bc653c31e407e6428aa1a6ebf50bf84aea │ │ │ ├── e4a1dbfb8711c43befec064b8fd396058b0c54af │ │ │ ├── e4ac1ef7380b8d2111b6763169a1743b27f8990e │ │ │ ├── e4be0b4404267bdc3cff4674612fa0aafae17da8 │ │ │ ├── e4ed5b23d5de1068cbbde995bd4acee64e91aa7e │ │ │ ├── e4f857e19db4cfd96f2d5054dbf40b5a9e492dff │ │ │ ├── e4f9951077eb874d4585b5156eb27d51d2efbfd3 │ │ │ ├── e50744f139df817035a18b49f300ba44cb0343d3 │ │ │ ├── e50e205a1d18fcdba7e8e5fcee9033cc4707f9c7 │ │ │ ├── e52cfe3453de9b1d75444df456949cb75040b8b6 │ │ │ ├── e531badf585946f2d8e4ca711ad08bfab23b255d │ │ │ ├── e556fbc1cbc098965abc9f19de4e699a65701b97 │ │ │ ├── e5a06372794c8a0907ebcab73767cf918aac39aa │ │ │ ├── e5c2adb3e9fbf1cd914078ec2a63b5eb9a6e3abe │ │ │ ├── e5d4d4aeaf98b811a93af7c9329c6daf9589e991 │ │ │ ├── e5d756b155e51281410e56562a664673b0c34fcd │ │ │ ├── e60ac2a186190f5f41d0f98adb9107b436491c32 │ │ │ ├── e617e275740cca2c1002733c0b62505410149814 │ │ │ ├── e62e88a5e5a9d90dbb6072f7ccea09b105b0f310 │ │ │ ├── e638e75f42344b0c3f6564246955fb5d040cf293 │ │ │ ├── e649d79b9010e5f76ed8c6e317e55e0e91802bac │ │ │ ├── e660a993ca6c73039fade4ba3407920ada89923e │ │ │ ├── e66bd9898efc98f464bdb5ece0b4f62d602dc737 │ │ │ ├── e677ad001a80f4218fcb1f38a8705f1d1caeb999 │ │ │ ├── e68c741fb9f3bd4beb774a6295165f0719b15942 │ │ │ ├── e69ec7f55ad3c08cfcb37946cda5c9e8bd2f23d4 │ │ │ ├── e69f704fabb54c278ef86ba0a840cc8b462fd273 │ │ │ ├── e6a0539a6bf9730e9f7197aac29cee83936137c2 │ │ │ ├── e6beac0076a3f98639e16833588cb1f7c3630b56 │ │ │ ├── e6c4139fc79b0036b50c35d40646356790b47698 │ │ │ ├── e6d6a1ae86f60f1e63f309397a0008e6d4943d50 │ │ │ ├── e6f3612a73d29882780cefe3d036f68100cf0c7b │ │ │ ├── e721205c821d1cfd009e603052b5cee6c677c52a │ │ │ ├── e72d5da834d577e08d8919888da3491b1cfc2395 │ │ │ ├── e73715f248773b481cfeb2552aceaf18e4b03797 │ │ │ ├── e7865be06886b6e888fd9d883d55c5faee586ef4 │ │ │ ├── e7a375809c225d5450a212abb59a2046d1b5e007 │ │ │ ├── e7c4905ac16a9774e7e810abf68b112d641b2d9e │ │ │ ├── e7c5c79c85fb153f7749dd5dcfa97ac1401ef95c │ │ │ ├── e7ccede981bb4c65fa47e7fa310a9348a7109ba3 │ │ │ ├── e7d9419f6cc1411629e9a09076e350aef3f0adbb │ │ │ ├── e7e9f1bdab686670c7fd4b590aaad6feacbbeb73 │ │ │ ├── e7fc7fe2e56e39aff52a6c1a3f3ddb20c48651d6 │ │ │ ├── e81dc94c8743dc71b11667a65c76c5ef0e8eaef8 │ │ │ ├── e81ee8a9a2165602a74cee1bdc447e2da39ab762 │ │ │ ├── e84308cd3dc05d65738bf940c73e11c1342f53dd │ │ │ ├── e8597fda210c9006c4eb35f55099dd53f0804f47 │ │ │ ├── e85ebbbabefe13b277bdb7bb290e81d48aaae843 │ │ │ ├── e87e2014a5a0695a3cdffdfe859201eb8beb9fb0 │ │ │ ├── e8ac301abd5dee5dd4ef8cb0670844bca13f0323 │ │ │ ├── e8de8be751822aa2e8bcf086b89ae6ca68052255 │ │ │ ├── e91b8692e5e50d7452d085b3580b9cdd1676e122 │ │ │ ├── e93758815f2e92fcae33eeb424961ee124cec2c7 │ │ │ ├── e9501001531cf5569b3b23daa63df0825b2e06f3 │ │ │ ├── e98353914c5de48ee650dfff9741c1285bf29368 │ │ │ ├── e9a85210b1a1018e7666d51f88430bb5d8bfdb3e │ │ │ ├── e9b76d10a6eebe9f37aaf17e3c71921c02524b86 │ │ │ ├── e9bf6e5a4cbd00e35ecd77dc39c1f9264b9f4dc1 │ │ │ ├── e9c730fdf2c5807b82dd1e4d042e404651d4c118 │ │ │ ├── e9d4196818fdc0fa92415cb4a2aff1b96c783b8b │ │ │ ├── e9dbacbd2e05c550b025911cfa3ca5803dae805e │ │ │ ├── e9ddf35ff01ae9bc71730f02a17a6079411fde98 │ │ │ ├── ea1fa2cb1864ebe376683d33d94b64f0f54a43dd │ │ │ ├── ea224ce2e986d690db2a198af3f98a8408cdb30e │ │ │ ├── ea3247c42e38f93b6d8af0e43d7f34cc4bc25070 │ │ │ ├── ea3a67eab454450f7603fe0cd98a27c731eb5d00 │ │ │ ├── ea3f5822d3ff42dc536ca2f868583167e04fcb24 │ │ │ ├── ea9383c734b03a942fd3c33b4cd6172b0c606aeb │ │ │ ├── eaa2ec29b35602bac1202162cc43997d10f21ed3 │ │ │ ├── eaa7b118760debbe1d5a3d4a62d81d966ab89097 │ │ │ ├── eab77792be235dec9f3313676498d907e560b5cc │ │ │ ├── eae489d9b326b6e764166ddf53140f5ddb3b425c │ │ │ ├── eae7770e2a494f15bf0e76460740c8d2e1cbd22e │ │ │ ├── eaee09f4a0e178165105cf2ccf81513fc80541b9 │ │ │ ├── eaee80bfbe65037b08eeecc39e40e2b8276a958d │ │ │ ├── eb0e20fe944dc77d38b2fc2582d02c80d3d9628f │ │ │ ├── eb372b84ca640e23188861d0efa04be45ee5f243 │ │ │ ├── eba9b48ee4b2ed1d213ff803ba46409241800f53 │ │ │ ├── ebaab3cbf799854c56be5ea1c8570b79e12530d3 │ │ │ ├── ec0558d3bd9826dcf5a547231702b26bb029d5b3 │ │ │ ├── ec11e48dae90b65ac226a309a6ab974cfc87474a │ │ │ ├── ec236a1ba693a15d7cd145cb072b03a9edafd25d │ │ │ ├── ec2d9171350303a508d3a35306e1da95e2d45a8c │ │ │ ├── ec3dc1b7325240192c1e37e75c29831fa68e98d4 │ │ │ ├── ec4c99541792d43b2c11d31a995e9d4e6494735e │ │ │ ├── ec5f10d715ff4121c9af8001b65d91bde62f884b │ │ │ ├── ec7ac5952f631f170c9cf5ab7afb10a2800e3be7 │ │ │ ├── ecc052cec3d69b0b941945fcfee7fcca160fee0f │ │ │ ├── ed414b2d37754fddb26883baa6399318c130524f │ │ │ ├── ed5648d424b5a21a684d02bc55bdcfab06ec276e │ │ │ ├── edb0a385324372442f7d831b7fa747c2a2ba5d40 │ │ │ ├── ede245d24c4ccbe651f556667d1de8b18984e6bf │ │ │ ├── edf48d71ea536f47f2ebae0ef4c1a54805cfd2bf │ │ │ ├── ee216fd86ba1f2f2eecc6892dba069f1fa7e2566 │ │ │ ├── ee227dd2c697b5ad500c732edea24bd9f2ec08a7 │ │ │ ├── ee39d37f93b56b4c318cb83ca60e411ee5c1abbb │ │ │ ├── ee4391649d8b6cf1ed2a18eef419b54a19d2f481 │ │ │ ├── ee4b75d279f94af5208664797cc453ca45044806 │ │ │ ├── ee537050d4b74465e99c77d79aec50879344edb4 │ │ │ ├── ee666d81fc0411dbdbf38406d49ba05685bee495 │ │ │ ├── ee92d4d96303e7296f561d5b3efe262b3993bc85 │ │ │ ├── eeb6e1a4eebe04ce7814c38efaf8b5b7e910296f │ │ │ ├── eef8d1a1e8c3a9566015b3ae089052a50d3c3ddb │ │ │ ├── ef1b9627be8307d947f73d84910a2d343187898a │ │ │ ├── ef34d2a06ed043b1d7aa5c55d07e649a98e022d0 │ │ │ ├── ef5018ccc4d868e150c22f85faea02a352f124d9 │ │ │ ├── ef588660a2f4df9f52c4f476036ae92b435dd8be │ │ │ ├── ef7b84160b7025ab4d29b8bb32de27500874c4e0 │ │ │ ├── efab9adce18cdbdd285db520ec08c755b0916a2f │ │ │ ├── efb25951d890dbd071c4a3811042fdb8e0bc4326 │ │ │ ├── efb757b9644c060f72a7441ae9f0dbb05935ddee │ │ │ ├── efbdf30300adcc55d7c50d4ec76a75496d6d7b7d │ │ │ ├── efc4b323ebe3c0b9e2f2fd7168ab4437570a54e8 │ │ │ ├── efce2a5687afc47a9a7951b0d14a86559eccd8af │ │ │ ├── f00c95582e31d9827eabb236ee8b4b776907a667 │ │ │ ├── f015ec4058e4e7ae0d1a64823882e2e3fe9f8bbd │ │ │ ├── f04d521c21ed8372ae0bcf98ee15b6ca83c85bc2 │ │ │ ├── f052250556f0a305782ffc367c106bf8213e5199 │ │ │ ├── f0b8804a6b3fa0ab08fb2e07758480377e212f0b │ │ │ ├── f0f31b265d33a5adb67af2f1fec8248f8855469e │ │ │ ├── f111543d0f442f268353dbbbf00ebe24c21f930e │ │ │ ├── f1439b2e5f242df93c3d5fd61e367f850098495b │ │ │ ├── f150268fcc20d8c1e1607d773fe9c2af148e9e8e │ │ │ ├── f1728d0e4771e35b1cb1998adc82e22eb67a65c9 │ │ │ ├── f172e0269b4ce4678ade6f0ac95a9448d2453792 │ │ │ ├── f17ba688055f4e28c6c763a1a67b55ffd27ab22b │ │ │ ├── f18786606f38657d15f1d007fa2934ea6034a605 │ │ │ ├── f1ab87a390b003a1f262909e41e5d3853c0dee70 │ │ │ ├── f1ac308d98f3a982e3c86ebf022541b3c7a53857 │ │ │ ├── f1b42b68e02cd3503158c2cedbad9f43b4a782fc │ │ │ ├── f1b9e75c583d069af4d354379ec7cbf02e95c41d │ │ │ ├── f1cfa6ecbcc68ba081804e6b531a970f6cc70cee │ │ │ ├── f1d42d84bf3c0ea75c9ac6babfdb06afac572bfa │ │ │ ├── f1e479e1e2ba063168c4201bc568c60b601c98f8 │ │ │ ├── f20f49c8c8a09c2b68a66d3640886588c1e95299 │ │ │ ├── f281cfc9b564fceae1f18905886e1a2ea6a79f8f │ │ │ ├── f29cde4e4d18f502a83e953d7e6aafc162b49fb0 │ │ │ ├── f2a7b6785e4184b100bb118d537c3e1fe7deed13 │ │ │ ├── f2aed5fc63d1322cbfa59dc10fc63c5c13905bad │ │ │ ├── f2b01b12b747c63ff84c1d178f5cd881a09d61d3 │ │ │ ├── f2cf8fc04a84276827038c4814930bd1166dcb83 │ │ │ ├── f306f010650c1ce3662a988f2d5c8848a114b742 │ │ │ ├── f311f3194f27d91bd26c7ac20214d331ade7f1c9 │ │ │ ├── f32541dee791305368453ac147924b5c2d9dfff7 │ │ │ ├── f34aa9739565ceed4d2a67fa8e24e1cffda032d0 │ │ │ ├── f36797074db1a3316cf9f79b8cedbea196a94883 │ │ │ ├── f3a1124f0e210f773fcb446a4c6325838f796dcd │ │ │ ├── f3abe34a0b2b561230223ebd55fa58c1abfa4752 │ │ │ ├── f3aefeaaf417737c9b08ddb588ac8f34f1bfd7c0 │ │ │ ├── f3b9a054bd33583afbecffad0407dcd117b60cb8 │ │ │ ├── f3c37d9c9bc7bbacd5acc05ecfa2dd6b3e4079be │ │ │ ├── f3dbd1cd81a692630c41a036e51a108069161d76 │ │ │ ├── f41b245dc4b63227dcd52bf8df204c69ef2c632d │ │ │ ├── f43a467e1ed501e4fae97b23c7ac5f51943b4a60 │ │ │ ├── f4466a6264c406cffaf61cd062c6954b8145b827 │ │ │ ├── f45bfc326aa2978cf872bbd25ac92e74c51b222c │ │ │ ├── f4604f24ef1262cff35502c140d3a3ab09e62650 │ │ │ ├── f47e1dd86121d4d47b5e315b8bc8f941d5c890ba │ │ │ ├── f49204f8e85d64be3490b7843476939194bca10c │ │ │ ├── f4cc235e3a3e0f11b34f866c952d52ba470ce96c │ │ │ ├── f4e60bca3a955a55d00e4186db841023ceef4e20 │ │ │ ├── f50995c18b1bea7d6e8f78c8db8139687517a781 │ │ │ ├── f50bbc9cda906042a1e0c756df37b20c36a36df6 │ │ │ ├── f54e6bed090f658f483733605be1def47c4a00f1 │ │ │ ├── f5584e332423dfd006828addcbd73f040328b087 │ │ │ ├── f558bde45b06e08703659c22eb17a9b25f4941d1 │ │ │ ├── f560ba3291103bb7f5cc015586c6946d5f9e8857 │ │ │ ├── f58c6d8117f18e36e7e31efdf23c18aea2a31b7c │ │ │ ├── f5a0c3cda376e7bd8f7a27caa053bef8617f451b │ │ │ ├── f5a0cbe081c8037a7f36d438e758b6bcd92abcbc │ │ │ ├── f5a7ff2dc8ee9ec1ef36b73c60de71d7978d3d27 │ │ │ ├── f5b5807a9afa7c7b8351abe9a32cdd85d696c15e │ │ │ ├── f5bbca8f5a7339d3dab2b5f758f426cdb744dd6d │ │ │ ├── f5bcbe0530388a9d1b0ddeb9fd52bbf9553589c1 │ │ │ ├── f5d29c01f03e55e2269af62ed6364a98353003af │ │ │ ├── f5d9f6f2aa6f7e44a24ecb63e2ccbe34ba6eecfe │ │ │ ├── f5f01b555c46d9d86c043b50cdf0dc05ea4c3d08 │ │ │ ├── f5f4bc663f8ff671a51d503c89c7a5659c0c37ab │ │ │ ├── f614cb3aadb14fc4cea6a3fa949cf1c4a5aa490a │ │ │ ├── f62efd7cbffa78cde24f12d7daf90b120c6b3e5f │ │ │ ├── f6389882692a6a18e427b73ca3a0a34f645e476b │ │ │ ├── f63afc3910d5b449d7d26586af8681218677fd6d │ │ │ ├── f64c19e45d11b07f585d65dd6f72bcd502d95a0a │ │ │ ├── f6514adef6dcf766ba7179320ec6c88126688614 │ │ │ ├── f6765d4b30feb17d15d4bd81601ea5788d8d26ed │ │ │ ├── f678ee4a403b466dde13be7e941db7ff7684a932 │ │ │ ├── f67b572dbad35568f4ec9ba53cafa2997991340e │ │ │ ├── f6840c641bb58cad923fc4f9c092164413ff4ce6 │ │ │ ├── f6907b785c509927b03981052c87de1c9ae5f772 │ │ │ ├── f69458974b285f9c2ac48a1bd10b3dff2d042a8d │ │ │ ├── f6a06f14f3641278ceae3733db1a7eff71fb3629 │ │ │ ├── f6c823a2b3203faddc06a15a61e6f0e3f3e7fe8e │ │ │ ├── f6d3771166a0c4e00527b2be21466030fb499521 │ │ │ ├── f6d618ef7f588f9fc237b18f4ad42a84337ec67e │ │ │ ├── f6e85bce5c033f269bbb51eb480ff58e9d814ed5 │ │ │ ├── f6f146c32b1b724af896fdd11df580e1dc8f0e35 │ │ │ ├── f70b704bb277d70481b756371e4d92b9dadb2d85 │ │ │ ├── f747e1181b2e9303715bc0aea1cfca3babf00705 │ │ │ ├── f75c71bf10464658e79f72142b2c327cd6ca3347 │ │ │ ├── f77abd655150de8bda3b775fd291d5b2bf27a1e6 │ │ │ ├── f77e7d751660a7149e80488c8245aeb9be6eeb1d │ │ │ ├── f796e5b0c5ce67017c553a21907fd6a51a1058eb │ │ │ ├── f798f952feda25e6fc4b37a429dc368f73d0d158 │ │ │ ├── f7a5375d5d273e7eda804ac9335745a3fcc568ae │ │ │ ├── f7ab44a4e73a9b24bfff6a263c608abce5696639 │ │ │ ├── f7b76430a96ffa6355eaf12167d0ef405e2669d8 │ │ │ ├── f7bc805d350c55cd8e24def5b79ca3b2fe88ae80 │ │ │ ├── f7c02de0b4f89c043a3ebcb28bcb0e1396fe0e23 │ │ │ ├── f7c0db2c2ed3c1e6f19acace4e10c0a99df88018 │ │ │ ├── f7dad92963bb917f67c0a5d9a11c7a623157603e │ │ │ ├── f7e399c76d4ec4bad55a5e054f90aaefbbefd54a │ │ │ ├── f7eb97d1c42b9d53be75b54f5a30490ace43fa77 │ │ │ ├── f7f77a67d9bea0dcf7942ed62f29985930122ff0 │ │ │ ├── f803ece8ba109526994448413d0b5389e89fec0b │ │ │ ├── f808813d157995b8d10c3cffd1f2616528fdad1f │ │ │ ├── f8136e4e492396052082b2d3eb7f45ce735b580e │ │ │ ├── f82150120ceb9a7b6d24c8144a2fc40fca6c7ded │ │ │ ├── f846835025106a0f7d7d18630b87f4321e626835 │ │ │ ├── f84d4edb22fee2109b5e00fd5ac471e49c15e25c │ │ │ ├── f86da2aa3ec8718d5308b84e38864225dfeb6819 │ │ │ ├── f880da185f238333598d20ee2e139229db739f94 │ │ │ ├── f881895a273c1bb8b76313a9f0ff65520ad27975 │ │ │ ├── f8835febdb55dca918a36795f2203f4ee4a6b841 │ │ │ ├── f8930f55c55efa927ccec4a3a273d7af679fe190 │ │ │ ├── f8d8d11d95153ea9449df09e90a108d0d46dd36a │ │ │ ├── f8e2668d6408cd99bb9b4144dccc869b5b5c3995 │ │ │ ├── f8f8928329f1f5ae3c966fb5ec2113e076eafcfe │ │ │ ├── f8f9451ddef15046ebb34b8ada8344e100e77c6b │ │ │ ├── f90c809fa2d5593e55f0033ebff4eb6de3bf7a4d │ │ │ ├── f92ae6d39d23d890f0a4bbb1700628cf97bfd5a6 │ │ │ ├── f92ff19d417dd30243bf0048d8947d33b4bf7064 │ │ │ ├── f950057a3fe68206273e224b1a0c92d75bf4cffd │ │ │ ├── f9527f53e0c01295c939d322769c4900690eac47 │ │ │ ├── f953c76798af4534303b789774638f6750bf064f │ │ │ ├── f95a0a2fc49acea853b2fa634e154189153c8e19 │ │ │ ├── f9ae968bede9072e9913f275110691863b21d704 │ │ │ ├── f9e9604adf8a8fa70a8a2d8699243ba825c4c268 │ │ │ ├── f9f75f9ba55d66c16536a85bc2406112ffaef2ff │ │ │ ├── f9fc9e2a4f2af623fc883937402f30bb39d7194c │ │ │ ├── f9fe421cb9a3952dc45c8d26a7ddd2f53b952533 │ │ │ ├── fa167d1943fe2df543ef85cf25a11984cbd5a5a2 │ │ │ ├── fa18264203439b69d71bc0bf47eb42c09a0276b5 │ │ │ ├── fa2f957cce50a9e152ca7a429346901042de9fc5 │ │ │ ├── fa49e364b5b789a639515d469e423d52b4437393 │ │ │ ├── fa4c5cdf26645ea0534a498e6eed0980cfb7a7c8 │ │ │ ├── fa597ee663f096b76cd93b293bc4d7f7aaefc262 │ │ │ ├── fa5f468e5077c7552905d4b235d938ba656a8956 │ │ │ ├── fa6ab5df5a5d808c4d736244d69510fa6e17f904 │ │ │ ├── fa7d0a81564418a5df2eae24548c51be6486a4aa │ │ │ ├── fa862d772ea0c551e8a2b2e955c3a314343a9249 │ │ │ ├── fa8814b8ee8c8c0b59933c5df3e62bc70882f43c │ │ │ ├── fa90b9f27b4ef61835f27c23a72f15ab0bc2f8d4 │ │ │ ├── fab23300d1e8e0ac77217a22517738b6de5afead │ │ │ ├── fac25d9ab05e1c85b45aa41798674daebf462237 │ │ │ ├── fad3ceab7d42e3ad2e07e8e88420e42ecf4dd0b8 │ │ │ ├── fae57409d88f4b4a8521c3bbd0560991c2a8986b │ │ │ ├── fb0c60f40b98f2127746a9a359165bc8d41dcb8c │ │ │ ├── fb18611c9ee4a416896469762bdeb28572310087 │ │ │ ├── fb193ee81245f14d9b19cacbf56cbcb01dec02be │ │ │ ├── fb3a40b01dd182dc32fd94d86be6aeec9cfda7dc │ │ │ ├── fb3feed4650211ed4fd84c29e022288219979e4a │ │ │ ├── fb47b82833fbb82a6a9844bcfa75012bfc49c9cf │ │ │ ├── fb56305966435f548db004e141dd614dcb71150d │ │ │ ├── fb6bbbb8192f592ebde7d1bb37924cade63c96c8 │ │ │ ├── fb803c7f3034af611f6dd19c6cd55245f319dd86 │ │ │ ├── fb84f0eaf5bbab71df0de66b8e502f2e52604fac │ │ │ ├── fb964d7fe5e195fa98766d8c4058c8258646e95a │ │ │ ├── fb9e6ec52fad74ca4a775818f110ba219adaadbb │ │ │ ├── fba8bb171f6333a2f8f8099ed7061ca7507012bc │ │ │ ├── fbae541afc8fd2842b660a15ba61db2dbd26dca5 │ │ │ ├── fbd1df6484bc96485135c2b29c3b125355c62848 │ │ │ ├── fbeb89304a55a7ab8a338b807ad02b8dd2ab9c28 │ │ │ ├── fc1908d2145aa6f1cf830f6aeb9bf24470454805 │ │ │ ├── fc6ad6441d0d3ba1260efa94e68b4af0576bf63f │ │ │ ├── fc6e7fbd1048ad4d4f9eadb18d79a7ddaddee244 │ │ │ ├── fc72b1ff88ff0bb9a8e7a27d860b1e727bc825b0 │ │ │ ├── fc833899bb452572fe6f3e84efd6737cca4eb786 │ │ │ ├── fc9c2ac36745e20f981008bf5f85f146b9c9dbb1 │ │ │ ├── fcc3f72c08a026d3c0f4cc50227793a26fc3efeb │ │ │ ├── fcd03d953e3452f116e4035d2029de953e62334d │ │ │ ├── fcd91aa7ad2c0011f8f2516f5687f9e91aa76b71 │ │ │ ├── fcda2ec36cb7652d368098a0c2ac64665164601f │ │ │ ├── fd03276208dbd6219a958f47d888d22fa303e89e │ │ │ ├── fd14286e8c496b3f62dea79de42d57a7b02b22fc │ │ │ ├── fd1a057fd69f2113eeeafc133d9d51c7cded9125 │ │ │ ├── fd1c6cdb67bcc23e0920c0b2724591695d7e88b1 │ │ │ ├── fd1d4fb758440d51c0db63f8a401ad4f7dd1ba6d │ │ │ ├── fd1f6bb68c1a0317e7fb3e9c65ce2b765717f38f │ │ │ ├── fd275d920066468018b3ec78708e01bbf4634f89 │ │ │ ├── fd30d1fabe3c70d63ebf6eb08fcc889f2062dd96 │ │ │ ├── fd4b486776c7fc4e964a57db37f46b6fb893446f │ │ │ ├── fde4e348195fef4158d57bce09b8132261e53404 │ │ │ ├── fe3a254545ba65877f7f12c1957e6983a9540725 │ │ │ ├── fe4991f96a4078203ed82f3dc9d57b0f5c8d7c31 │ │ │ ├── fe5a94896e814e80a5d4f0d17825ea303d136807 │ │ │ ├── fe754dfb4207b538736ac33f4d6d3a8b39ed7eb8 │ │ │ ├── fe8a403b551fce23551c1a364c5d7a9bdf4082b4 │ │ │ ├── fead4cb9efe769ed34fc79a6f7f7c301fa44b950 │ │ │ ├── fec0428a7d5b4dd2f894abbef22a4fd55b125e79 │ │ │ ├── fed7b4e8b0ffa8ba7ee920409e365993f8f23423 │ │ │ ├── ff02cab52406b52d736534063539b815a83e9ec9 │ │ │ ├── ff0c9a3fa047cac34488cf6902e39ceb0b31a1f2 │ │ │ ├── ff0ecc250f060fadb2dfbc788f027f6c46ef6c40 │ │ │ ├── ff269c4192d92ee1330ca6cb368ffaf3dec65d44 │ │ │ ├── ffba9a51f35e6cfeb9726e3eb3551989a55a2ab6 │ │ │ ├── ffbfc4371313a95615a944ca1fb473bf2569d7aa │ │ │ └── ffc6076c34629ad5d440389f97bac8efcd2db5b7 │ │ ├── tx_invalid.json │ │ └── tx_valid.json │ ├── doc.go │ ├── engine.go │ ├── engine_debug_test.go │ ├── engine_test.go │ ├── error.go │ ├── error_test.go │ ├── example_test.go │ ├── hashcache.go │ ├── hashcache_test.go │ ├── log.go │ ├── opcode.go │ ├── opcode_test.go │ ├── pkscript.go │ ├── pkscript_test.go │ ├── reference_test.go │ ├── script.go │ ├── script_test.go │ ├── scriptbuilder.go │ ├── scriptbuilder_test.go │ ├── scriptnum.go │ ├── scriptnum_test.go │ ├── sigcache.go │ ├── sigcache_test.go │ ├── sighash.go │ ├── sign.go │ ├── sign_test.go │ ├── sigvalidate.go │ ├── stack.go │ ├── stack_test.go │ ├── standard.go │ ├── standard_test.go │ ├── taproot.go │ ├── taproot_test.go │ ├── template.go │ ├── template_test.go │ ├── tokenizer.go │ └── tokenizer_test.go ├── upgrade.go ├── upnp.go ├── v2transport/ │ ├── chacha.go │ ├── go.mod │ ├── go.sum │ ├── log.go │ ├── transport.go │ └── transport_test.go ├── version.go └── wire/ ├── README.md ├── bench_test.go ├── blockheader.go ├── blockheader_test.go ├── common.go ├── common_test.go ├── doc.go ├── error.go ├── fakemessage_test.go ├── fixedIO_test.go ├── invvect.go ├── invvect_test.go ├── message.go ├── message_test.go ├── msgaddr.go ├── msgaddr_test.go ├── msgaddrv2.go ├── msgaddrv2_test.go ├── msgblock.go ├── msgblock_test.go ├── msgcfcheckpt.go ├── msgcfcheckpt_bench_test.go ├── msgcfheaders.go ├── msgcfilter.go ├── msgfeefilter.go ├── msgfeefilter_test.go ├── msgfilteradd.go ├── msgfilteradd_test.go ├── msgfilterclear.go ├── msgfilterclear_test.go ├── msgfilterload.go ├── msgfilterload_test.go ├── msggetaddr.go ├── msggetaddr_test.go ├── msggetblocks.go ├── msggetblocks_test.go ├── msggetcfcheckpt.go ├── msggetcfheaders.go ├── msggetcfilters.go ├── msggetdata.go ├── msggetdata_test.go ├── msggetheaders.go ├── msggetheaders_test.go ├── msgheaders.go ├── msgheaders_test.go ├── msginv.go ├── msginv_test.go ├── msgmempool.go ├── msgmempool_test.go ├── msgmerkleblock.go ├── msgmerkleblock_test.go ├── msgnotfound.go ├── msgnotfound_test.go ├── msgping.go ├── msgping_test.go ├── msgpong.go ├── msgpong_test.go ├── msgreject.go ├── msgreject_test.go ├── msgsendaddrv2.go ├── msgsendaddrv2_test.go ├── msgsendheaders.go ├── msgsendheaders_test.go ├── msgtx.go ├── msgtx_test.go ├── msgverack.go ├── msgverack_test.go ├── msgversion.go ├── msgversion_test.go ├── msgwtxidrelay.go ├── msgwtxidrelay_test.go ├── netaddress.go ├── netaddress_test.go ├── netaddressv2.go ├── netaddressv2_test.go ├── protocol.go ├── protocol_test.go └── testdata/ ├── block-0000000000000000001602407ac49862a7bca9d00f7f402db20b7be2f5de59d2.blk ├── block-00000000000000000021868c2cefc52a480d173c849412fe81c4e5ab806f94ab.blk └── megatx.bin.bz2 ================================================ FILE CONTENTS ================================================ ================================================ FILE: .gemini/config.yaml ================================================ # Config for the Gemini Pull Request Review Bot. # https://developers.google.com/gemini-code-assist/docs/customize-gemini-behavior-github # Enables fun features such as a poem in the initial pull request summary. # Type: boolean, default: false. have_fun: false code_review: # Disables Gemini from acting on PRs. # Type: boolean, default: false. disable: false # Minimum severity of comments to post (LOW, MEDIUM, HIGH, CRITICAL). # Type: string, default: MEDIUM. comment_severity_threshold: MEDIUM # Max number of review comments (-1 for unlimited). # Type: integer, default: -1. max_review_comments: -1 pull_request_opened: # Post helpful instructions when PR is opened. # Type: boolean, default: false. help: false # Post PR summary when opened. # Type boolean, default: true. summary: true # Post code review on PR open. # Type boolean, default: true. code_review: true # List of glob patterns to ignore (files and directories). # Type: array of string, default: []. ignore_patterns: [] ================================================ FILE: .gemini/styleguide.md ================================================ # LND Style Guide ## Code Documentation and Commenting - Always use the Golang code style described below in this document. - Readable code is the most important requirement for any commit created. - Comments must not explain the code 1:1 but instead explain the _why_ behind a certain block of code, in case it requires contextual knowledge. - Unit tests must always use the `require` library. Either table driven unit tests or tests using the `rapid` library are preferred. - The line length MUST NOT exceed 80 characters, this is very important. You must count the Golang indentation (tabulator character) as 8 spaces when determining the line length. Use creative approaches or the wrapping rules specified below to make sure the line length isn't exceeded. - Every function must be commented with its purpose and assumptions. - Function comments must begin with the function name. - Function comments should be complete sentences. - Exported functions require detailed comments for the caller. **WRONG** ```go // generates a revocation key func DeriveRevocationPubkey(commitPubKey *btcec.PublicKey, revokePreimage []byte) *btcec.PublicKey { ``` **RIGHT** ```go // DeriveRevocationPubkey derives the revocation public key given the // counterparty's commitment key, and revocation preimage derived via a // pseudo-random-function. In the event that we (for some reason) broadcast a // revoked commitment transaction, then if the other party knows the revocation // preimage, then they'll be able to derive the corresponding private key to // this private key by exploiting the homomorphism in the elliptic curve group. // // The derivation is performed as follows: // // revokeKey := commitKey + revokePoint // := G*k + G*h // := G * (k+h) // // Therefore, once we divulge the revocation preimage, the remote peer is able // to compute the proper private key for the revokeKey by computing: // revokePriv := commitPriv + revokePreimge mod N // // Where N is the order of the sub-group. func DeriveRevocationPubkey(commitPubKey *btcec.PublicKey, revokePreimage []byte) *btcec.PublicKey { ``` - In-body comments should explain the *intention* of the code. **WRONG** ```go // return err if amt is less than 546 if amt < 546 { return err } ``` **RIGHT** ```go // Treat transactions with amounts less than the amount which is considered dust // as non-standard. if amt < 546 { return err } ``` ## Code Spacing and formatting - Segment code into logical stanzas separated by newlines. **WRONG** ```go witness := make([][]byte, 4) witness[0] = nil if bytes.Compare(pubA, pubB) == -1 { witness[1] = sigB witness[2] = sigA } else { witness[1] = sigA witness[2] = sigB } witness[3] = witnessScript return witness ``` **RIGHT** ```go witness := make([][]byte, 4) // When spending a p2wsh multi-sig script, rather than an OP_0, we add // a nil stack element to eat the extra pop. witness[0] = nil // When initially generating the witnessScript, we sorted the serialized // public keys in descending order. So we do a quick comparison in order // to ensure the signatures appear on the Script Virtual Machine stack in // the correct order. if bytes.Compare(pubA, pubB) == -1 { witness[1] = sigB witness[2] = sigA } else { witness[1] = sigA witness[2] = sigB } // Finally, add the preimage as the last witness element. witness[3] = witnessScript return witness ``` - Use spacing between `case` and `select` stanzas. **WRONG** ```go switch { case a: case b: case c: case d: default: } ``` **RIGHT** ```go switch { // Brief comment detailing instances of this case (repeat below). case a: case b: case c: case d: default: } ``` ## Additional Style Constraints ### 80 character line length - Wrap columns at 80 characters. - Tabs are 8 spaces. **WRONG** ```go myKey := "0214cd678a565041d00e6cf8d62ef8add33b4af4786fb2beb87b366a2e151fcee7" ``` **RIGHT** ```go myKey := "0214cd678a565041d00e6cf8d62ef8add33b4af4786fb2beb87b366a2e1" + "51fcee7" ``` ### Wrapping long function calls - If a function call exceeds the column limit, place the closing parenthesis on its own line and start all arguments on a new line after the opening parenthesis. **WRONG** ```go value, err := bar(a, a, b, c) ``` **RIGHT** ```go value, err := bar( a, a, b, c, ) ``` - Compact form is acceptable if visual symmetry of parentheses is preserved. **ACCEPTABLE** ```go response, err := node.AddInvoice( ctx, &lnrpc.Invoice{ Memo: "invoice", ValueMsat: int64(oneUnitMilliSat - 1), }, ) ``` **PREFERRED** ```go response, err := node.AddInvoice(ctx, &lnrpc.Invoice{ Memo: "invoice", ValueMsat: int64(oneUnitMilliSat - 1), }) ``` ### Exception for log and error message formatting - Minimize lines for log and error messages, while adhering to the 80-character limit. **WRONG** ```go return fmt.Errorf( "this is a long error message with a couple (%d) place holders", len(things), ) log.Debugf( "Something happened here that we need to log: %v", longVariableNameHere, ) ``` **RIGHT** ```go return fmt.Errorf("this is a long error message with a couple (%d) place "+ "holders", len(things)) log.Debugf("Something happened here that we need to log: %v", longVariableNameHere) ``` ### Exceptions and additional styling for structured logging - **Static messages:** Use key-value pairs instead of formatted strings for the `msg` parameter. - **Key-value attributes:** Use `slog.Attr` helper functions. - **Line wrapping:** Structured log lines are an exception to the 80-character rule. Use one line per key-value pair for multiple attributes. **WRONG** ```go log.DebugS(ctx, fmt.Sprintf("User %d just spent %.8f to open a channel", userID, 0.0154)) ``` **RIGHT** ```go log.InfoS(ctx, "Channel open performed", slog.Int("user_id", userID), btclog.Fmt("amount", "%.8f", 0.00154)) ``` ### Wrapping long function definitions - If function arguments exceed the 80-character limit, maintain indentation on following lines. - Do not end a line with an open parenthesis if the function definition is not finished. **WRONG** ```go func foo(a, b, c, ) (d, error) { func bar(a, b, c) ( d, error, ) { func baz(a, b, c) ( d, error) { ``` **RIGHT** ```go func foo(a, b, c) (d, error) { func baz(a, b, c) (d, error) { func longFunctionName( a, b, c) (d, error) { ``` - If a function declaration spans multiple lines, the body should start with an empty line. **WRONG** ```go func foo(a, b, c, d, e) error { var a int } ``` **RIGHT** ```go func foo(a, b, c, d, e) error { var a int } ``` ## Use of Log Levels - Available levels: `trace`, `debug`, `info`, `warn`, `error`, `critical`. - Only use `error` for internal errors not triggered by external sources. ## Testing - To run all tests for a specific package: `make unit pkg=$pkg` - To run a specific test case within a package: `make unit pkg=$pkg case=$case` ## Git Commit Messages - **Subject Line:** - Format: `subsystem: short description of changes` - `subsystem` should be the package primarily affected (e.g., `peer`, `rpcclient`). - For multiple packages, use `+` or `,` as a delimiter (e.g., `peer+rpcclient`). - For widespread changes, use `multi:`. - Keep it under 50 characters. - Use the present tense (e.g., "Fix bug", not "Fixed bug"). - **Message Body:** - Separate from the subject with a blank line. - Explain the "what" and "why" of the change. - Wrap text to 72 characters. - Use bullet points for lists. ================================================ FILE: .github/ISSUE_TEMPLATE/bug_report.md ================================================ --- name: Bug report about: Create a bug report. Please use the discussions section for general or troubleshooting questions. title: '[bug]: ' labels: ["bug", "needs triage"] assignees: '' --- ### Background Describe your issue here. ### Your environment * version of `btcd` * which operating system (`uname -a` on *Nix) * any other relevant environment details ### Steps to reproduce Tell us how to reproduce this issue. Please provide stacktraces and links to code in question. ### Expected behaviour Tell us what should happen ### Actual behaviour Tell us what happens instead ================================================ FILE: .github/ISSUE_TEMPLATE/config.yml ================================================ blank_issues_enabled: false contact_links: - name: Discussions url: https://github.com/btcsuite/btcd/discussions about: For general or troubleshooting questions or if you're not sure what issue type to pick. - name: Community Slack url: https://lightning.engineering/slack.html about: Please ask and answer questions here. - name: Security issue disclosure policy url: https://github.com/lightningnetwork/lnd#security about: Please refer to this document when reporting security related issues. ================================================ FILE: .github/ISSUE_TEMPLATE/feature_request.md ================================================ --- name: Feature request about: Suggest a new feature for `btcd`. title: '[feature]: ' labels: enhancement assignees: '' --- **Is your feature request related to a problem? Please describe.** **Describe the solution you'd like** **Describe alternatives you've considered** **Additional context** ================================================ FILE: .github/pull_request_template.md ================================================ ## Change Description Description of change / link to associated issue. ## Steps to Test Steps for reviewers to follow to test the change. ## Pull Request Checklist ### Testing - [ ] Your PR passes all CI checks. - [ ] Tests covering the positive and negative (error paths) are included. - [ ] Bug fixes contain tests triggering the bug to prevent regressions. ### Code Style and Documentation - [ ] The change is not [insubstantial](https://github.com/btcsuite/btcd/blob/master/docs/code_contribution_guidelines.md#substantial-contributions-only). Typo fixes are not accepted to fight bot spam. - [ ] The change obeys the [Code Documentation and Commenting](https://github.com/btcsuite/btcd/blob/master/docs/code_contribution_guidelines.md#code-documentation-and-commenting) guidelines, and lines wrap at 80. - [ ] Commits follow the [Ideal Git Commit Structure](https://github.com/btcsuite/btcd/blob/master/docs/code_contribution_guidelines.md#model-git-commit-messages). - [ ] Any new logging statements use an appropriate subsystem and logging level. 📝 Please see our [Contribution Guidelines](https://github.com/btcsuite/btcd/blob/master/docs/code_contribution_guidelines.md) for further guidance. ================================================ FILE: .github/workflows/Dockerfile ================================================ # GitHub action dockerfile # Requires docker experimental features as buildx and BuildKit so not suitable for developers regular use. # https://docs.docker.com/develop/develop-images/build_enhancements/#to-enable-buildkit-builds ########################### # Build binaries stage ########################### FROM --platform=$BUILDPLATFORM golang:1.23-alpine AS build ADD . /app WORKDIR /app # Arguments required to build binaries targetting the correct OS and CPU architectures ARG TARGETOS TARGETARCH # Actually building the binaries RUN GOOS=$TARGETOS GOARCH=$TARGETARCH go install -v . ./cmd/... ########################### # Build docker image stage ########################### FROM alpine:3.15 COPY --from=build /go/bin /bin # 8333 Mainnet Bitcoin peer-to-peer port # 8334 Mainet RPC port EXPOSE 8333 8334 ENTRYPOINT ["btcd"] ================================================ FILE: .github/workflows/dimagespub.yml ================================================ name: Docker images build and publish on: push: tags: - v* # Allows you to run this workflow manually from the Actions tab workflow_dispatch: env: REGISTRY: ghcr.io IMAGE_NAME: ${{ github.repository }} # Build for default OS, linux, and common CPU architectures # Reference https://github.com/docker/setup-buildx-action#quick-start TPLATFORMS: linux/amd64,linux/arm64,linux/arm,linux/386 jobs: build-push: runs-on: ubuntu-latest permissions: contents: read packages: write steps: - name: Checkout repository uses: actions/checkout@v4 - name: Docker Setup Buildx id: buildx uses: docker/setup-buildx-action@94ab11c41e45d028884a99163086648e898eed25 - name: Log in to the Container registry uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 with: registry: ${{ env.REGISTRY }} username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - name: Extract metadata (tags, labels) for Docker id: meta uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 with: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - name: Build and push Docker images uses: docker/build-push-action@ac9327eae2b366085ac7f6a2d02df8aa8ead720a with: file: .github/workflows/Dockerfile labels: ${{ steps.meta.outputs.labels }} platforms: ${{ env.TPLATFORMS }} push: true tags: ${{ steps.meta.outputs.tags }} ================================================ FILE: .github/workflows/main.yml ================================================ name: Build and Test on: [push, pull_request] env: # go needs absolute directories, using the $HOME variable doesn't work here. GOCACHE: /home/runner/work/go/pkg/build GOPATH: /home/runner/work/go GOBIN: /home/runner/work/go/bin GO_VERSION: 1.22.11 jobs: build: name: Build runs-on: ubuntu-latest steps: - name: Set up Go uses: actions/setup-go@v5 with: go-version: ${{ env.GO_VERSION }} - name: Check out source uses: actions/checkout@v4 - name: Build run: make build test-cover: name: Unit coverage runs-on: ubuntu-latest steps: - name: Set up Go uses: actions/setup-go@v5 with: go-version: ${{ env.GO_VERSION }} - name: Check out source uses: actions/checkout@v4 - name: Test run: make unit-cover - name: Send top-level coverage uses: coverallsapp/github-action@v2 continue-on-error: true with: file: coverage.txt flag-name: btcd format: 'golang' parallel: true - name: Send btcec uses: coverallsapp/github-action@v2 continue-on-error: true with: file: btcec/coverage.txt flag-name: btcec format: 'golang' parallel: true - name: Send btcutil coverage uses: coverallsapp/github-action@v2 continue-on-error: true with: file: btcutil/coverage.txt flag-name: btcutil format: 'golang' parallel: true - name: Send btcutil coverage for psbt package uses: coverallsapp/github-action@v2 continue-on-error: true with: file: btcutil/psbt/coverage.txt flag-name: btcutilpsbt format: 'golang' parallel: true - name: Notify coveralls all reports sent uses: coverallsapp/github-action@v2 continue-on-error: true with: parallel-finished: true test-race: name: Unit race runs-on: ubuntu-latest steps: - name: Set up Go uses: actions/setup-go@v5 with: go-version: ${{ env.GO_VERSION }} - name: Check out source uses: actions/checkout@v4 - name: Test run: make unit-race ================================================ FILE: .gitignore ================================================ # Temp files *~ # Databases btcd.db *-shm *-wal # Log files *.log # Compiled Object files, Static and Dynamic libs (Shared Objects) *.o *.a *.so # Folders _obj _test vendor # Architecture specific extensions/prefixes *.[568vq] [568vq].out *.cgo1.go *.cgo2.c _cgo_defun.c _cgo_gotypes.go _cgo_export.* _testmain.go *.exe # Code coverage files profile.tmp profile.cov coverage.txt btcec/coverage.txt btcutil/coverage.txt btcutil/psbt/coverage.txt # vim *.swp *.swo /.vim #IDE .idea # Binaries produced by "make build" /addblock /btcctl /btcd /findcheckpoint /gencerts .DS_Store .aider* ================================================ FILE: .golangci.yml ================================================ version: "2" issues: # Only show newly introduced problems. new-from-rev: 80b74d6c5a0088a66dc96df6777d21e15c04849c ================================================ FILE: CHANGES ================================================ ============================================================================ User visible changes for btcd A full-node bitcoin implementation written in Go ============================================================================ Changes in 0.22.0 (Tue Jun 01 2021) - Protocol and network-related changes: - Add support for witness tx and block in notfound msg (#1625) - Add support for receiving sendaddrv2 messages from a peer (#1670) - Fix bug in peer package causing last block height to go backwards (#1606) - Add chain parameters for connecting to the public Signet network (#1692, #1718) - Crypto changes: - Fix bug causing panic due to bad R and S signature components in btcec.RecoverCompact (#1691) - Set the name (secp256k1) in the CurveParams of the S256 curve (#1565) - Notable developer-related package changes: - Remove unknown block version warning in the blockchain package, due to false positives triggered by AsicBoost (#1463) - Add chaincfg.RegisterHDKeyID function to populate HD key ID pairs (#1617) - Add new method mining.AddWitnessCommitment to add the witness commitment as an OP_RETURN output within the coinbase transaction. (#1716) - RPC changes: - Support Batch JSON-RPC in rpcclient and server (#1583) - Add rpcclient method to invoke getdescriptorinfo JSON-RPC command (#1578) - Update the rpcserver handler for validateaddress JSON-RPC command to have parity with the bitcoind 0.20.0 interface (#1613) - Add rpcclient method to invoke getblockfilter JSON-RPC command (#1579) - Add signmessagewithprivkey JSON-RPC command in rpcserver (#1585) - Add rpcclient method to invoke importmulti JSON-RPC command (#1579) - Add watchOnly argument in rpcclient method to invoke listtransactions JSON-RPC command (#1628) - Update btcjson.ListTransactionsResult for compatibility with Bitcoin Core 0.20.0 (#1626) - Support nullable optional JSON-RPC parameters (#1594) - Add rpcclient and server method to invoke getnodeaddresses JSON-RPC command (#1590) - Add rpcclient methods to invoke PSBT JSON-RPC commands (#1596) - Add rpcclient method to invoke listsinceblock with the include_watchonly parameter enabled (#1451) - Add rpcclient method to invoke deriveaddresses JSON-RPC command (#1631) - Add rpcclient method to invoke getblocktemplate JSON-RPC command (#1629) - Add rpcclient method to invoke getaddressinfo JSON-RPC command (#1633) - Add rpcclient method to invoke getwalletinfo JSON-RPC command (#1638) - Fix error message in rpcserver when an unknown RPC command is encountered (#1695) - Fix error message returned by estimatefee when the number of blocks exceeds the max depth (#1678) - Update btcjson.GetBlockChainInfoResult to include new fields in Bitcoin Core (#1676) - Add ExtraHeaders in rpcclient.ConnConfig struct (#1669) - Fix bitcoind compatibility issue with the sendrawtransaction JSON-RPC command (#1659) - Add new JSON-RPC errors to btcjson package, and documented them (#1648) - Add rpcclient method to invoke createwallet JSON-RPC command (#1650) - Add rpcclient methods to invoke backupwallet, dumpwallet, loadwallet and unloadwallet JSON-RPC commands (#1645) - Fix unmarshalling error in getmininginfo JSON-RPC command, for valid integers in scientific notation (#1644) - Add rpcclient method to invoke gettxoutsetinfo JSON-RPC command (#1641) - Add rpcclient method to invoke signrawtransactionwithwallet JSON-RPC command (#1642) - Add txid to getblocktemplate response of rpcserver (#1639) - Fix monetary unit used in createrawtransaction JSON-RPC command in rpcserver (#1614) - Add rawtx field to btcjson.GetBlockVerboseTxResult to provide backwards compatibility with older versions of Bitcoin Core (#1677) - Misc changes: - Update btcutil dependency (#1704) - Add Dockerfile to build and run btcd on Docker (#1465) - Rework documentation and publish on https://btcd.readthedocs.io (#1468) - Add support for Go 1.15 (#1619) - Add Go 1.14 as the minimum supported version of Golang (#1621) - Contributors (alphabetical order): - 10gic - Andrew Tugarinov - Anirudha Bose - Appelberg-s - Armando Ochoa - Aurèle Oulès - Calvin Kim - Christian Lehmann - Conner Fromknecht - Dan Cline - David Mazary - Elliott Minns - Federico Bond - Friedger Müffke - Gustavo Chain - Hanjun Kim - Henry Fisher - Iskander Sharipov - Jake Sylvestre - Johan T. Halseth - John C. Vernaleo - Liran Sharir - Mikael Lindlof - Olaoluwa Osuntokun - Oliver Gugger - Rjected - Steven Kreuzer - Torkel Rogstad - Tristyn - Victor Lavaud - Vinayak Borkar - Wilmer Paulino - Yaacov Akiba Slama - ebiiim - ipriver - wakiyamap - yyforyongyu Changes in 0.21.0 (Thu Aug 27 2020) - Network-related changes: - Handle notfound messages from peers in netsync package (#1603) - RPC changes: - Add compatibility for getblock RPC changes in bitcoind 0.15.0 (#1529) - Add new optional Params field to rpcclient.ConnConfig (#1467) - Add new error code ErrRPCInWarmup in btcjson (#1541) - Add compatibility for changes to getmempoolentry response in bitcoind 0.19.0 (#1524) - Add rpcclient methods for estimatesmartfee and generatetoaddress commands (#1500) - Add rpcclient method for getblockstats command (#1500) - Parse serialized transaction from createrawtransaction command using both segwit, and legacy format (#1502) - Support cookie-based authentication in rpcclient (#1460) - Add rpcclient method for getchaintxstats command (#1571) - Add rpcclient method for fundrawtransaction command (#1553) - Add rpcclient method for getbalances command (#1595) - Add new method rpcclient.GetTransactionWatchOnly (#1592) - Crypto changes: - Fix panic in fieldVal.SetByteSlice when called with large values, and improve the method to be 35% faster (#1602) - btcctl changes: - Add -regtest mode to btcctl (#1556) - Misc changes: - Fix a bug due to a deadlock in connmgr's dynamic ban scoring (#1509) - Add blockchain.NewUtxoEntry() to directly create entries for UtxoViewpoint (#1588) - Replace LRU cache implementation in peer package with a generic one from decred/dcrd (#1599) - Contributors (alphabetical order): - Anirudha Bose - Antonin Hildebrand - Dan Cline - Daniel McNally - David Hill - Federico Bond - George Tankersley - Henry - Henry Harder - Iskander Sharipov - Ivan Kuznetsov - Jake Sylvestre - Javed Khan - JeremyRand - Jin - John C. Vernaleo - Kulpreet Singh - Mikael Lindlof - Murray Nesbitt - Nisen - Olaoluwa Osuntokun - Oliver Gugger - Steven Roose - Torkel Rogstad - Tyler Chambers - Wilmer Paulino - Yash Bhutwala - adiabat - jalavosus - mohanson - qqjettkgjzhxmwj - qshuai - shuai.qi - tpkeeper Changes in v0.20.1 (Wed Nov 13 2019) - RPC changes: - Add compatibility for bitcoind v0.19.0 in rpcclient and btcjson packages (#1484) - Contributors (alphabetical order): - Eugene Zeigel - Olaoluwa Osuntokun - Wilmer Paulino Changes in v0.20.0 (Tue Oct 15 2019) - Significant changes made since 0.12.0. See git log or refer to release notes on GitHub for full details. - Contributors (alphabetical order): - Albert Puigsech Galicia - Alex Akselrod - Alex Bosworth - Alex Manuskin - Alok Menghrajani - Anatoli Babenia - Andy Weidenbaum - Calvin McAnarney - Chris Martin - Chris Pacia - Chris Shepherd - Conner Fromknecht - Craig Sturdy - Cédric Félizard - Daniel Krawisz - Daniel Martí - Daniel McNally - Dario Nieuwenhuis - Dave Collins - David Hill - David de Kloet - GeertJohan - Grace Noah - Gregory Trubetskoy - Hector Jusforgues - Iskander (Alex) Sharipov - Janus Troelsen - Jasper - Javed Khan - Jeremiah Goyette - Jim Posen - Jimmy Song - Johan T. Halseth - John C. Vernaleo - Jonathan Gillham - Josh Rickmar - Jon Underwood - Jonathan Zeppettini - Jouke Hofman - Julian Meyer - Kai - Kamil Slowikowski - Kefkius - Leonardo Lazzaro - Marco Peereboom - Marko Bencun - Mawueli Kofi Adzoe - Michail Kargakis - Mitchell Paull - Nathan Bass - Nicola 'tekNico' Larosa - Olaoluwa Osuntokun - Pedro Martelletto - Ricardo Velhote - Roei Erez - Ruben de Vries - Rune T. Aune - Sad Pencil - Shuai Qi - Steven Roose - Tadge Dryja - Tibor Bősze - Tomás Senart - Tzu-Jung Lee - Vadym Popov - Waldir Pimenta - Wilmer Paulino - benma - danda - dskloet - esemplastic - jadeblaquiere - nakagawa - preminem - qshuai Changes in 0.12.0 (Fri Nov 20 2015) - Protocol and network related changes: - Add a new checkpoint at block height 382320 (#555) - Implement BIP0065 which includes support for version 4 blocks, a new consensus opcode (OP_CHECKLOCKTIMEVERIFY) that enforces transaction lock times, and a double-threshold switchover mechanism (#535, #459, #455) - Implement BIP0111 which provides a new bloom filter service flag and hence provides support for protocol version 70011 (#499) - Add a new parameter --nopeerbloomfilters to allow disabling bloom filter support (#499) - Reject non-canonically encoded variable length integers (#507) - Add mainnet peer discovery DNS seed (seed.bitcoin.jonasschnelli.ch) (#496) - Correct reconnect handling for persistent peers (#463, #464) - Ignore requests for block headers if not fully synced (#444) - Add CLI support for specifying the zone id on IPv6 addresses (#538) - Fix a couple of issues where the initial block sync could stall (#518, #229, #486) - Fix an issue which prevented the --onion option from working as intended (#446) - Transaction relay (memory pool) changes: - Require transactions to only include signatures encoded with the canonical 'low-s' encoding (#512) - Add a new parameter --minrelaytxfee to allow the minimum transaction fee in BTC/kB to be overridden (#520) - Retain memory pool transactions when they redeem another one that is removed when a block is accepted (#539) - Do not send reject messages for a transaction if it is valid but causes an orphan transaction which depends on it to be determined as invalid (#546) - Refrain from attempting to add orphans to the memory pool multiple times when the transaction they redeem is added (#551) - Modify minimum transaction fee calculations to scale based on bytes instead of full kilobyte boundaries (#521, #537) - Implement signature cache: - Provides a limited memory cache of validated signatures which is a huge optimization when verifying blocks for transactions that are already in the memory pool (#506) - Add a new parameter '--sigcachemaxsize' which allows the size of the new cache to be manually changed if desired (#506) - Mining support changes: - Notify getblocktemplate long polling clients when a block is pushed via submitblock (#488) - Speed up getblocktemplate by making use of the new signature cache (#506) - RPC changes: - Implement getmempoolinfo command (#453) - Implement getblockheader command (#461) - Modify createrawtransaction command to accept a new optional parameter 'locktime' (#529) - Modify listunspent result to include the 'spendable' field (#440) - Modify getinfo command to include 'errors' field (#511) - Add timestamps to blockconnected and blockdisconnected notifications (#450) - Several modifications to searchrawtranscations command: - Accept a new optional parameter 'vinextra' which causes the results to include information about the outputs referenced by a transaction's inputs (#485, #487) - Skip entries in the mempool too (#495) - Accept a new optional parameter 'reverse' to return the results in reverse order (most recent to oldest) (#497) - Accept a new optional parameter 'filteraddrs' which causes the results to only include inputs and outputs which involve the provided addresses (#516) - Change the notification order to notify clients about mined transactions (recvtx, redeemingtx) before the blockconnected notification (#449) - Update verifymessage RPC to use the standard algorithm so it is compatible with other implementations (#515) - Improve ping statistics by pinging on an interval (#517) - Websocket changes: - Implement session command which returns a per-session unique id (#500, #503) - btcctl utility changes: - Add getmempoolinfo command (#453) - Add getblockheader command (#461) - Add getwalletinfo command (#471) - Notable developer-related package changes: - Introduce a new peer package which acts a common base for creating and concurrently managing bitcoin network peers (#445) - Various cleanup of the new peer package (#528, #531, #524, #534, #549) - Blocks heights now consistently use int32 everywhere (#481) - The BlockHeader type in the wire package now provides the BtcDecode and BtcEncode methods (#467) - Update wire package to recognize BIP0064 (getutxo) service bit (#489) - Export LockTimeThreshold constant from txscript package (#454) - Export MaxDataCarrierSize constant from txscript package (#466) - Provide new IsUnspendable function from the txscript package (#478) - Export variable length string functions from the wire package (#514) - Export DNS Seeds for each network from the chaincfg package (#544) - Preliminary work towards separating the memory pool into a separate package (#525, #548) - Misc changes: - Various documentation updates (#442, #462, #465, #460, #470, #473, #505, #530, #545) - Add installation instructions for gentoo (#542) - Ensure an error is shown if OS limits can't be set at startup (#498) - Tighten the standardness checks for multisig scripts (#526) - Test coverage improvement (#468, #494, #527, #543, #550) - Several optimizations (#457, #474, #475, #476, #508, #509) - Minor code cleanup and refactoring (#472, #479, #482, #519, #540) - Contributors (alphabetical order): - Ben Echols - Bruno Clermont - danda - Daniel Krawisz - Dario Nieuwenhuis - Dave Collins - David Hill - Javed Khan - Jonathan Gillham - Joseph Becher - Josh Rickmar - Justus Ranvier - Mawuli Adzoe - Olaoluwa Osuntokun - Rune T. Aune Changes in 0.11.1 (Wed May 27 2015) - Protocol and network related changes: - Use correct sub-command in reject message for rejected transactions (#436, #437) - Add a new parameter --torisolation which forces new circuits for each connection when using tor (#430) - Transaction relay (memory pool) changes: - Reduce the default number max number of allowed orphan transactions to 1000 (#419) - Add a new parameter --maxorphantx which allows the maximum number of orphan transactions stored in the mempool to be specified (#419) - RPC changes: - Modify listtransactions result to include the 'involveswatchonly' and 'vout' fields (#427) - Update getrawtransaction result to omit the 'confirmations' field when it is 0 (#420, #422) - Update signrawtransaction result to include errors (#423) - btcctl utility changes: - Add gettxoutproof command (#428) - Add verifytxoutproof command (#428) - Notable developer-related package changes: - The btcec package now provides the ability to perform ECDH encryption and decryption (#375) - The block and header validation in the blockchain package has been split to help pave the way toward concurrent downloads (#386) - Misc changes: - Minor peer optimization (#433) - Contributors (alphabetical order): - Dave Collins - David Hill - Federico Bond - Ishbir Singh - Josh Rickmar Changes in 0.11.0 (Wed May 06 2015) - Protocol and network related changes: - **IMPORTANT: Update is required due to the following point** - Correct a few corner cases in script handling which could result in forking from the network on non-standard transactions (#425) - Add a new checkpoint at block height 352940 (#418) - Optimized script execution (#395, #400, #404, #409) - Fix a case that could lead stalled syncs (#138, #296) - Network address manager changes: - Implement eclipse attack countermeasures as proposed in http://cs-people.bu.edu/heilman/eclipse (#370, #373) - Optional address indexing changes: - Fix an issue where a reorg could cause an orderly shutdown when the address index is active (#340, #357) - Transaction relay (memory pool) changes: - Increase maximum allowed space for nulldata transactions to 80 bytes (#331) - Implement support for the following rules specified by BIP0062: - The S value in ECDSA signature must be at most half the curve order (rule 5) (#349) - Script execution must result in a single non-zero value on the stack (rule 6) (#347) - NOTE: All 7 rules of BIP0062 are now implemented - Use network adjusted time in finalized transaction checks to improve consistency across nodes (#332) - Process orphan transactions on acceptance of new transactions (#345) - RPC changes: - Add support for a limited RPC user which is not allowed admin level operations on the server (#363) - Implement node command for more unified control over connected peers (#79, #341) - Implement generate command for regtest/simnet to support deterministically mining a specified number of blocks (#362, #407) - Update searchrawtransactions to return the matching transactions in order (#354) - Correct an issue with searchrawtransactions where it could return duplicates (#346, #354) - Increase precision of 'difficulty' field in getblock result to 8 (#414, #415) - Omit 'nextblockhash' field from getblock result when it is empty (#416, #417) - Add 'id' and 'timeoffset' fields to getpeerinfo result (#335) - Websocket changes: - Implement new commands stopnotifyspent, stopnotifyreceived, stopnotifyblocks, and stopnotifynewtransactions to allow clients to cancel notification registrations (#122, #342) - btcctl utility changes: - A single dash can now be used as an argument to cause that argument to be read from stdin (#348) - Add generate command - Notable developer-related package changes: - The new version 2 btcjson package has now replaced the deprecated version 1 package (#368) - The btcec package now performs all signing using RFC6979 deterministic signatures (#358, #360) - The txscript package has been significantly cleaned up and had a few API changes (#387, #388, #389, #390, #391, #392, #393, #395, #396, #400, #403, #404, #405, #406, #408, #409, #410, #412) - A new PkScriptLocs function has been added to the wire package MsgTx type which provides callers that deal with scripts optimization opportunities (#343) - Misc changes: - Minor wire hashing optimizations (#366, #367) - Other minor internal optimizations - Contributors (alphabetical order): - Alex Akselrod - Arne Brutschy - Chris Jepson - Daniel Krawisz - Dave Collins - David Hill - Jimmy Song - Jonas Nick - Josh Rickmar - Olaoluwa Osuntokun - Oleg Andreev Changes in 0.10.0 (Sun Mar 01 2015) - Protocol and network related changes: - Add a new checkpoint at block height 343185 - Implement BIP066 which includes support for version 3 blocks, a new consensus rule which prevents non-DER encoded signatures, and a double-threshold switchover mechanism - Rather than announcing all known addresses on getaddr requests which can possibly result in multiple messages, randomize the results and limit them to the max allowed by a single message (1000 addresses) - Add more reserved IP spaces to the address manager - Transaction relay (memory pool) changes: - Make transactions which contain reserved opcodes nonstandard - No longer accept or relay free and low-fee transactions that have insufficient priority to be mined in the next block - Implement support for the following rules specified by BIP0062: - ECDSA signature must use strict DER encoding (rule 1) - The signature script must only contain push operations (rule 2) - All push operations must use the smallest possible encoding (rule 3) - All stack values interpreted as a number must be encoding using the shortest possible form (rule 4) - NOTE: Rule 1 was already enforced, however the entire script now evaluates to false rather than only the signature verification as required by BIP0062 - Allow transactions with nulldata transaction outputs to be treated as standard - Mining support changes: - Modify the getblocktemplate RPC to generate and return block templates for version 3 blocks which are compatible with BIP0066 - Allow getblocktemplate to serve blocks when the current time is less than the minimum allowed time for a generated block template (https://github.com/btcsuite/btcd/issues/209) - Crypto changes: - Optimize scalar multiplication by the base point by using a pre-computed table which results in approximately a 35% speedup (https://github.com/btcsuite/btcec/issues/2) - Optimize general scalar multiplication by using the secp256k1 endomorphism which results in approximately a 17-20% speedup (https://github.com/btcsuite/btcec/issues/1) - Optimize general scalar multiplication by using non-adjacent form which results in approximately an additional 8% speedup (https://github.com/btcsuite/btcec/issues/3) - Implement optional address indexing: - Add a new parameter --addrindex which will enable the creation of an address index which can be queried to determine all transactions which involve a given address (https://github.com/btcsuite/btcd/issues/190) - Add a new logging subsystem for address index related operations - Support new searchrawtransactions RPC (https://github.com/btcsuite/btcd/issues/185) - RPC changes: - Require TLS version 1.2 as the minimum version for all TLS connections - Provide support for disabling TLS when only listening on localhost (https://github.com/btcsuite/btcd/pull/192) - Modify help output for all commands to provide much more consistent and detailed information - Correct case in getrawtransaction which would refuse to serve certain transactions with invalid scripts (https://github.com/btcsuite/btcd/issues/210) - Correct error handling in the getrawtransaction RPC which could lead to a crash in rare cases (https://github.com/btcsuite/btcd/issues/196) - Update getinfo RPC to include the appropriate 'timeoffset' calculated from the median network time - Modify listreceivedbyaddress result type to include txids field so it is compatible - Add 'iswatchonly' field to validateaddress result - Add 'startingpriority' and 'currentpriority' fields to getrawmempool (https://github.com/btcsuite/btcd/issues/178) - Don't omit the 'confirmations' field from getrawtransaction when it is zero - Websocket changes: - Modify the behavior of the rescan command to automatically register for notifications about transactions paying to rescanned addresses or spending outputs from the final rescan utxo set when the rescan is through the best block in the chain - btcctl utility changes: - Make the list of commands available via the -l option rather than dumping the entire list on usage errors - Alphabetize and categorize the list of commands by chain and wallet - Make the help option only show the help options instead of also dumping all of the commands - Make the usage syntax much more consistent and correct a few cases of misnamed fields (https://github.com/btcsuite/btcd/issues/305) - Improve usage errors to show the specific parameter number, reason, and error code - Only show the usage for specific command is shown when a valid command is provided with invalid parameters - Add support for a SOCK5 proxy - Modify output for integer fields (such as timestamps) to display normally instead in scientific notation - Add invalidateblock command - Add reconsiderblock command - Add createnewaccount command - Add renameaccount command - Add searchrawtransactions command - Add importaddress command - Add importpubkey command - showblock utility changes: - Remove utility in favor of the RPC getblock method - Notable developer-related package changes: - Many of the core packages have been relocated into the btcd repository (https://github.com/btcsuite/btcd/issues/214) - A new version of the btcjson package that has been completely redesigned from the ground up based based upon how the project has evolved and lessons learned while using it since it was first written is now available in the btcjson/v2/btcjson directory - This will ultimately replace the current version so anyone making use of this package will need to update their code accordingly - The btcec package now provides better facilities for working directly with its public and private keys without having to mix elements from the ecdsa package - Update the script builder to ensure all rules specified by BIP0062 are adhered to when creating scripts - The blockchain package now provides a MedianTimeSource interface and concrete implementation for providing time samples from remote peers and using that data to calculate an offset against the local time - Misc changes: - Fix a slow memory leak due to tickers not being stopped (https://github.com/btcsuite/btcd/issues/189) - Fix an issue where a mix of orphans and SPV clients could trigger a condition where peers would no longer be served (https://github.com/btcsuite/btcd/issues/231) - The RPC username and password can now contain symbols which previously conflicted with special symbols used in URLs - Improve handling of obtaining random nonces to prevent cases where it could error when not enough entropy was available - Improve handling of home directory creation errors such as in the case of unmounted symlinks (https://github.com/btcsuite/btcd/issues/193) - Improve the error reporting for rejected transactions to include the inputs which are missing and/or being double spent - Update sample config file with new options and correct a comment regarding the fact the RPC server only listens on localhost by default (https://github.com/btcsuite/btcd/issues/218) - Update the continuous integration builds to run several tools which help keep code quality high - Significant amount of internal code cleanup and improvements - Other minor internal optimizations - Code Contributors (alphabetical order): - Beldur - Ben Holden-Crowther - Dave Collins - David Evans - David Hill - Guilherme Salgado - Javed Khan - Jimmy Song - John C. Vernaleo - Jonathan Gillham - Josh Rickmar - Michael Ford - Michail Kargakis - kac - Olaoluwa Osuntokun Changes in 0.9.0 (Sat Sep 20 2014) - Protocol and network related changes: - Add a new checkpoint at block height 319400 - Add support for BIP0037 bloom filters (https://github.com/conformal/btcd/issues/132) - Implement BIP0061 reject handling and hence support for protocol version 70002 (https://github.com/conformal/btcd/issues/133) - Add testnet DNS seeds for peer discovery (testnet-seed.alexykot.me and testnet-seed.bitcoin.schildbach.de) - Add mainnet DNS seed for peer discovery (seeds.bitcoin.open-nodes.org) - Make multisig transactions with non-null dummy data nonstandard (https://github.com/conformal/btcd/issues/131) - Make transactions with an excessive number of signature operations nonstandard - Perform initial DNS lookups concurrently which allows connections more quickly - Improve the address manager to significantly reduce memory usage and add tests - Remove orphan transactions when they appear in a mined block (https://github.com/conformal/btcd/issues/166) - Apply incremental back off on connection retries for persistent peers that give invalid replies to mirror the logic used for failed connections (https://github.com/conformal/btcd/issues/103) - Correct rate-limiting of free and low-fee transactions - Mining support changes: - Implement getblocktemplate RPC with the following support: (https://github.com/conformal/btcd/issues/124) - BIP0022 Non-Optional Sections - BIP0022 Long Polling - BIP0023 Basic Pool Extensions - BIP0023 Mutation coinbase/append - BIP0023 Mutations time, time/increment, and time/decrement - BIP0023 Mutation transactions/add - BIP0023 Mutations prevblock, coinbase, and generation - BIP0023 Block Proposals - Implement built-in concurrent CPU miner (https://github.com/conformal/btcd/issues/137) NOTE: CPU mining on mainnet is pointless. This has been provided for testing purposes such as for the new simulation test network - Add --generate flag to enable CPU mining - Deprecate the --getworkkey flag in favor of --miningaddr which specifies which addresses generated blocks will choose from to pay the subsidy to - RPC changes: - Implement gettxout command (https://github.com/conformal/btcd/issues/141) - Implement validateaddress command - Implement verifymessage command - Mark getunconfirmedbalance RPC as wallet-only - Mark getwalletinfo RPC as wallet-only - Update getgenerate, setgenerate, gethashespersec, and getmininginfo to return the appropriate information about new CPU mining status - Modify getpeerinfo pingtime and pingwait field types to float64 so they are compatible - Improve disconnect handling for normal HTTP clients - Make error code returns for invalid hex more consistent - Websocket changes: - Switch to a new more efficient websocket package (https://github.com/conformal/btcd/issues/134) - Add rescanfinished notification - Modify the rescanprogress notification to include block hash as well as height (https://github.com/conformal/btcd/issues/151) - btcctl utility changes: - Accept --simnet flag which automatically selects the appropriate port and TLS certificates needed to communicate with btcd and btcwallet on the simulation test network - Fix createrawtransaction command to send amounts denominated in BTC - Add estimatefee command - Add estimatepriority command - Add getmininginfo command - Add getnetworkinfo command - Add gettxout command - Add lockunspent command - Add signrawtransaction command - addblock utility changes: - Accept --simnet flag which automatically selects the appropriate port and TLS certificates needed to communicate with btcd and btcwallet on the simulation test network - Notable developer-related package changes: - Provide a new bloom package in btcutil which allows creating and working with BIP0037 bloom filters - Provide a new hdkeychain package in btcutil which allows working with BIP0032 hierarchical deterministic key chains - Introduce a new btcnet package which houses network parameters - Provide new simnet network (--simnet) which is useful for private simulation testing - Enforce low S values in serialized signatures as detailed in BIP0062 - Return errors from all methods on the btcdb.Db interface (https://github.com/conformal/btcdb/issues/5) - Allow behavior flags to alter btcchain.ProcessBlock (https://github.com/conformal/btcchain/issues/5) - Provide a new SerializeSize API for blocks (https://github.com/conformal/btcwire/issues/19) - Several of the core packages now work with Google App Engine - Misc changes: - Correct an issue where the database could corrupt under certain circumstances which would require a new chain download - Slightly optimize deserialization - Use the correct IP block for he.net - Fix an issue where it was possible the block manager could hang on shutdown - Update sample config file so the comments are on a separate line rather than the end of a line so they are not interpreted as settings (https://github.com/conformal/btcd/issues/135) - Correct an issue where getdata requests were not being properly throttled which could lead to larger than necessary memory usage - Always show help when given the help flag even when the config file contains invalid entries - General code cleanup and minor optimizations Changes in 0.8.0-beta (Sun May 25 2014) - Btcd is now Beta (https://github.com/conformal/btcd/issues/130) - Add a new checkpoint at block height 300255 - Protocol and network related changes: - Lower the minimum transaction relay fee to 1000 satoshi to match recent reference client changes (https://github.com/conformal/btcd/issues/100) - Raise the maximum signature script size to support standard 15-of-15 multi-signature pay-to-script-hash transactions with compressed pubkeys to remain compatible with the reference client (https://github.com/conformal/btcd/issues/128) - Reduce max bytes allowed for a standard nulldata transaction to 40 for compatibility with the reference client - Introduce a new btcnet package which houses all of the network params for each network (mainnet, testnet3, regtest) to ultimately enable easier addition and tweaking of networks without needing to change several packages - Fix several script discrepancies found by reference client test data - Add new DNS seed for peer discovery (seed.bitnodes.io) - Reduce the max known inventory cache from 20000 items to 1000 items - Fix an issue where unknown inventory types could lead to a hung peer - Implement inventory rebroadcast handler for sendrawtransaction (https://github.com/conformal/btcd/issues/99) - Update user agent to fully support BIP0014 (https://github.com/conformal/btcwire/issues/10) - Implement initial mining support: - Add a new logging subsystem for mining related operations - Implement infrastructure for creating block templates - Provide options to control block template creation settings - Support the getwork RPC - Allow address identifiers to apply to more than one network since both testnet3 and the regression test network unfortunately use the same identifier - RPC changes: - Set the content type for HTTP POST RPC connections to application/json (https://github.com/conformal/btcd/issues/121) - Modified the RPC server startup so it only requires at least one valid listen interface - Correct an error path where it was possible certain errors would not be returned - Implement getwork command (https://github.com/conformal/btcd/issues/125) - Update sendrawtransaction command to reject orphans - Update sendrawtransaction command to include the reason a transaction was rejected - Update getinfo command to populate connection count field - Update getinfo command to include relay fee field (https://github.com/conformal/btcd/issues/107) - Allow transactions submitted with sendrawtransaction to bypass the rate limiter - Allow the getcurrentnet and getbestblock extensions to be accessed via HTTP POST in addition to Websockets (https://github.com/conformal/btcd/issues/127) - Websocket changes: - Rework notifications to ensure they are delivered in the order they occur - Rename notifynewtxs command to notifyreceived (funds received) - Rename notifyallnewtxs command to notifynewtransactions - Rename alltx notification to txaccepted - Rename allverbosetx notification to txacceptedverbose (https://github.com/conformal/btcd/issues/98) - Add rescan progress notification - Add recvtx notification - Add redeemingtx notification - Modify notifyspent command to accept an array of outpoints (https://github.com/conformal/btcd/issues/123) - Significantly optimize the rescan command to yield up to a 60x speed increase - btcctl utility changes: - Add createencryptedwallet command - Add getblockchaininfo command - Add importwallet command - Add addmultisigaddress command - Add setgenerate command - Accept --testnet and --wallet flags which automatically select the appropriate port and TLS certificates needed to communicate with btcd and btcwallet (https://github.com/conformal/btcd/issues/112) - Allow path expansion from config file entries (https://github.com/conformal/btcd/issues/113) - Minor refactor simplify handling of options - addblock utility changes: - Improve logging by making it consistent with the logging provided by btcd (https://github.com/conformal/btcd/issues/90) - Improve several package APIs for developers: - Add new amount type for consistently handling monetary values - Add new coin selector API - Add new WIF (Wallet Import Format) API - Add new crypto types for private keys and signatures - Add new API to sign transactions including script merging and hash types - Expose function to extract all pushed data from a script (https://github.com/conformal/btcscript/issues/8) - Misc changes: - Optimize address manager shuffling to do 67% less work on average - Resolve a couple of benign data races found by the race detector (https://github.com/conformal/btcd/issues/101) - Add IP address to all peer related errors to clarify which peer is the cause (https://github.com/conformal/btcd/issues/102) - Fix a UPNP case issue that prevented the --upnp option from working with some UPNP servers - Update documentation in the sample config file regarding debug levels - Adjust some logging levels to improve debug messages - Improve the throughput of query messages to the block manager - Several minor optimizations to reduce GC churn and enhance speed - Other minor refactoring - General code cleanup Changes in 0.7.0 (Thu Feb 20 2014) - Fix an issue when parsing scripts which contain a multi-signature script which require zero signatures such as testnet block 000000001881dccfeda317393c261f76d09e399e15e27d280e5368420f442632 (https://github.com/conformal/btcscript/issues/7) - Add check to ensure all transactions accepted to mempool only contain canonical data pushes (https://github.com/conformal/btcscript/issues/6) - Fix an issue causing excessive memory consumption - Significantly rework and improve the websocket notification system: - Each client is now independent so slow clients no longer limit the speed of other connected clients - Potentially long-running operations such as rescans are now run in their own handler and rate-limited to one operation at a time without preventing simultaneous requests from the same client for the faster requests or notifications - A couple of scenarios which could cause shutdown to hang have been resolved - Update notifynewtx notifications to support all address types instead of only pay-to-pubkey-hash - Provide a --rpcmaxwebsockets option to allow limiting the number of concurrent websocket clients - Add a new websocket command notifyallnewtxs to request notifications (https://github.com/conformal/btcd/issues/86) (thanks @flammit) - Improve btcctl utility in the following ways: - Add getnetworkhashps command - Add gettransaction command (wallet-specific) - Add signmessage command (wallet-specific) - Update getwork command to accept - Continue cleanup and work on implementing the RPC API: - Implement getnettotals command (https://github.com/conformal/btcd/issues/84) - Implement networkhashps command (https://github.com/conformal/btcd/issues/87) - Update getpeerinfo to always include syncnode field even when false - Remove help addenda for getpeerinfo now that it supports all fields - Close standard RPC connections on auth failure - Provide a --rpcmaxclients option to allow limiting the number of concurrent RPC clients (https://github.com/conformal/btcd/issues/68) - Include IP address in RPC auth failure log messages - Resolve a rather harmless data races found by the race detector (https://github.com/conformal/btcd/issues/94) - Increase block priority size and max standard transaction size to 50k and 100k, respectively (https://github.com/conformal/btcd/issues/71) - Add rate limiting of free transactions to the memory pool to prevent penny flooding (https://github.com/conformal/btcd/issues/40) - Provide a --logdir option (https://github.com/conformal/btcd/issues/95) - Change the default log file path to include the network - Add a new ScriptBuilder interface to btcscript to support creation of custom scripts (https://github.com/conformal/btcscript/issues/5) - General code cleanup Changes in 0.6.0 (Tue Feb 04 2014) - Fix an issue when parsing scripts which contain invalid signatures that caused a chain fork on block 0000000000000001e4241fd0b3469a713f41c5682605451c05d3033288fb2244 - Correct an issue which could lead to an error in removeBlockNode (https://github.com/conformal/btcchain/issues/4) - Improve addblock utility as follows: - Check imported blocks against all chain rules and checkpoints - Skip blocks which are already known so you can stop and restart the import or start the import after you have already downloaded a portion of the chain - Correct an issue where the utility did not shutdown cleanly after processing all blocks - Add error on attempt to import orphan blocks - Improve error handling and reporting - Display statistics after input file has been fully processed - Rework, optimize, and improve headers-first mode: - Resuming the chain sync from any point before the final checkpoint will now use headers-first mode (https://github.com/conformal/btcd/issues/69) - Verify all checkpoints as opposed to only the final one - Reduce and bound memory usage - Rollback to the last known good point when a header does not match a checkpoint - Log information about what is happening with headers - Improve btcctl utility in the following ways: - Add getaddednodeinfo command - Add getnettotals command - Add getblocktemplate command (wallet-specific) - Add getwork command (wallet-specific) - Add getnewaddress command (wallet-specific) - Add walletpassphrasechange command (wallet-specific) - Add walletlock command (wallet-specific) - Add sendfrom command (wallet-specific) - Add sendmany command (wallet-specific) - Add settxfee command (wallet-specific) - Add listsinceblock command (wallet-specific) - Add listaccounts command (wallet-specific) - Add keypoolrefill command (wallet-specific) - Add getreceivedbyaccount command (wallet-specific) - Add getrawchangeaddress command (wallet-specific) - Add gettxoutsetinfo command (wallet-specific) - Add listaddressgroupings command (wallet-specific) - Add listlockunspent command (wallet-specific) - Add listlock command (wallet-specific) - Add listreceivedbyaccount command (wallet-specific) - Add validateaddress command (wallet-specific) - Add verifymessage command (wallet-specific) - Add sendtoaddress command (wallet-specific) - Continue cleanup and work on implementing the RPC API: - Implement submitblock command (https://github.com/conformal/btcd/issues/61) - Implement help command - Implement ping command - Implement getaddednodeinfo command (https://github.com/conformal/btcd/issues/78) - Implement getinfo command - Update getpeerinfo to support bytesrecv and bytessent (https://github.com/conformal/btcd/issues/83) - Improve and correct several RPC server and websocket areas: - Change the connection endpoint for websockets from /wallet to /ws (https://github.com/conformal/btcd/issues/80) - Implement an alternative authentication for websockets so clients such as javascript from browsers that don't support setting HTTP headers can authenticate (https://github.com/conformal/btcd/issues/77) - Add an authentication deadline for RPC connections (https://github.com/conformal/btcd/issues/68) - Use standard authentication failure responses for RPC connections - Make automatically generated certificate more standard so it works from client such as node.js and Firefox - Correct some minor issues which could prevent the RPC server from shutting down in an orderly fashion - Make all websocket notifications require registration - Change the data sent over websockets to text since it is JSON-RPC - Allow connections that do not have an Origin header set - Expose and track the number of bytes read and written per peer (https://github.com/conformal/btcwire/issues/6) - Correct an issue with sendrawtransaction when invoked via websockets which prevented a minedtx notification from being added - Rescan operations issued from remote wallets are no stopped when the wallet disconnects mid-operation (https://github.com/conformal/btcd/issues/66) - Several optimizations related to fetching block information from the database - General code cleanup Changes in 0.5.0 (Mon Jan 13 2014) - Optimize initial block download by introducing a new mode which downloads the block headers first (up to the final checkpoint) - Improve peer handling to remove the potential for slow peers to cause sluggishness amongst all peers (https://github.com/conformal/btcd/issues/63) - Fix an issue where the initial block sync could stall when the sync peer disconnects (https://github.com/conformal/btcd/issues/62) - Correct an issue where --externalip was doing a DNS lookup on the full host:port instead of just the host portion (https://github.com/conformal/btcd/issues/38) - Fix an issue which could lead to a panic on chain switches (https://github.com/conformal/btcd/issues/70) - Improve btcctl utility in the following ways: - Show getdifficulty output as floating point to 6 digits of precision - Show all JSON object replies formatted as standard JSON - Allow btcctl getblock to accept optional params - Add getaccount command (wallet-specific) - Add getaccountaddress command (wallet-specific) - Add sendrawtransaction command - Continue cleanup and work on implementing RPC API calls - Update getrawmempool to support new optional verbose flag - Update getrawtransaction to match the reference client - Update getblock to support new optional verbose flag - Update raw transactions to fully match the reference client including support for all transaction types and address types - Correct getrawmempool fee field to return BTC instead of Satoshi - Correct getpeerinfo service flag to return 8 digit string so it matches the reference client - Correct verifychain to return a boolean - Implement decoderawtransaction command - Implement createrawtransaction command - Implement decodescript command - Implement gethashespersec command - Allow RPC handler overrides when invoked via a websocket versus legacy connection - Add new DNS seed for peer discovery - Display user agent on new valid peer log message (https://github.com/conformal/btcd/issues/64) - Notify wallet when new transactions that pay to registered addresses show up in the mempool before being mined into a block - Support a tor-specific proxy in addition to a normal proxy (https://github.com/conformal/btcd/issues/47) - Remove deprecated sqlite3 imports from utilities - Remove leftover profile write from addblock utility - Quite a bit of code cleanup and refactoring to improve maintainability Changes in 0.4.0 (Thu Dec 12 2013) - Allow listen interfaces to be specified via --listen instead of only the port (https://github.com/conformal/btcd/issues/33) - Allow listen interfaces for the RPC server to be specified via --rpclisten instead of only the port (https://github.com/conformal/btcd/issues/34) - Only disable listening when --connect or --proxy are used when no --listen interface are specified (https://github.com/conformal/btcd/issues/10) - Add several new standard transaction checks to transaction memory pool: - Support nulldata scripts as standard - Only allow a max of one nulldata output per transaction - Enforce a maximum of 3 public keys in multi-signature transactions - The number of signatures in multi-signature transactions must not exceed the number of public keys - The number of inputs to a signature script must match the expected number of inputs for the script type - The number of inputs pushed onto the stack by a redeeming signature script must match the number of inputs consumed by the referenced public key script - When a block is connected, remove any transactions from the memory pool which are now double spends as a result of the newly connected transactions - Don't relay transactions resurrected during a chain switch since other peers will also be switching chains and therefore already know about them - Cleanup a few cases where rejected transactions showed as an error rather than as a rejected transaction - Ignore the default configuration file when --regtest (regression test mode) is specified - Implement TLS support for RPC including automatic certificate generation - Support HTTP authentication headers for web sockets - Update address manager to recognize and properly work with Tor addresses (https://github.com/conformal/btcd/issues/36) and (https://github.com/conformal/btcd/issues/37) - Improve btcctl utility in the following ways: - Add the ability to specify a configuration file - Add a default entry for the RPC cert to point to the location it will likely be in the btcd home directory - Implement --version flag - Provide a --notls option to support non-TLS configurations - Fix a couple of minor races found by the Go race detector - Improve logging - Allow logging level to be specified on a per subsystem basis (https://github.com/conformal/btcd/issues/48) - Allow logging levels to be dynamically changed via RPC (https://github.com/conformal/btcd/issues/15) - Implement a rolling log file with a max of 10MB per file and a rotation size of 3 which results in a max logging size of 30 MB - Correct a minor issue with the rescanning websocket call (https://github.com/conformal/btcd/issues/54) - Fix a race with pushing address messages that could lead to a panic (https://github.com/conformal/btcd/issues/58) - Improve which external IP address is reported to peers based on which interface they are connected through (https://github.com/conformal/btcd/issues/35) - Add --externalip option to allow an external IP address to be specified for cases such as tor hidden services or advanced network configurations (https://github.com/conformal/btcd/issues/38) - Add --upnp option to support automatic port mapping via UPnP (https://github.com/conformal/btcd/issues/51) - Update Ctrl+C interrupt handler to properly sync address manager and remove the UPnP port mapping (if needed) - Continue cleanup and work on implementing RPC API calls - Add importprivkey (import private key) command to btcctl - Update getrawtransaction to provide addresses properly, support new verbose param, and match the reference implementation with the exception of MULTISIG (thanks @flammit) - Update getblock with new verbose flag (thanks @flammit) - Add listtransactions command to btcctl - Add getbalance command to btcctl - Add basic support for btcd to run as a native Windows service (https://github.com/conformal/btcd/issues/42) - Package addblock utility with Windows MSIs - Add support for TravisCI (continuous build integration) - Cleanup some documentation and usage - Several other minor bug fixes and general code cleanup Changes in 0.3.3 (Wed Nov 13 2013) - Significantly improve initial block chain download speed (https://github.com/conformal/btcd/issues/20) - Add a new checkpoint at block height 267300 - Optimize most recently used inventory handling (https://github.com/conformal/btcd/issues/21) - Optimize duplicate transaction input check (https://github.com/conformal/btcchain/issues/2) - Optimize transaction hashing (https://github.com/conformal/btcd/issues/25) - Rework and optimize wallet listener notifications (https://github.com/conformal/btcd/issues/22) - Optimize serialization and deserialization (https://github.com/conformal/btcd/issues/27) - Add support for minimum transaction fee to memory pool acceptance (https://github.com/conformal/btcd/issues/29) - Improve leveldb database performance by removing explicit GC call - Fix an issue where Ctrl+C was not always finishing orderly database shutdown - Fix an issue in the script handling for OP_CHECKSIG - Impose max limits on all variable length protocol entries to prevent abuse from malicious peers - Enforce DER signatures for transactions allowed into the memory pool - Separate the debug profile http server from the RPC server - Rework of the RPC code to improve performance and make the code cleaner - The getrawtransaction RPC call now properly checks the memory pool before consulting the db (https://github.com/conformal/btcd/issues/26) - Add support for the following RPC calls: getpeerinfo, getconnectedcount, addnode, verifychain (https://github.com/conformal/btcd/issues/13) (https://github.com/conformal/btcd/issues/17) - Implement rescan websocket extension to allow wallet rescans - Use correct paths for application data storage for all supported operating systems (https://github.com/conformal/btcd/issues/30) - Add a default redirect to the http profiling page when accessing the http profile server - Add a new --cpuprofile option which can be used to generate CPU profiling data on platforms that support it - Several other minor performance optimizations - Other minor bug fixes and general code cleanup Changes in 0.3.2 (Tue Oct 22 2013) - Fix an issue that could cause the download of the block chain to stall (https://github.com/conformal/btcd/issues/12) - Remove deprecated sqlite as an available database backend - Close sqlite compile issue as sqlite has now been removed (https://github.com/conformal/btcd/issues/11) - Change default RPC ports to 8334 (mainnet) and 18334 (testnet) - Continue cleanup and work on implementing RPC API calls - Add support for the following RPC calls: getrawmempool, getbestblockhash, decoderawtransaction, getdifficulty, getconnectioncount, getpeerinfo, and addnode - Improve the btcctl utility that is used to issue JSON-RPC commands - Fix an issue preventing btcd from cleanly shutting down with the RPC stop command - Add a number of database interface tests to ensure backends implement the expected interface - Expose some additional information from btcscript to be used for identifying "standard"" transactions - Add support for plan9 - thanks @mischief (https://github.com/conformal/btcd/pull/19) - Other minor bug fixes and general code cleanup Changes in 0.3.1-alpha (Tue Oct 15 2013) - Change default database to leveldb NOTE: This does mean you will have to redownload the block chain. Since we are still in alpha, we didn't feel writing a converter was worth the time as it would take away from more important issues at this stage - Add a warning if there are multiple block chain databases of different types - Fix issue with unexpected EOF in leveldb -- https://github.com/conformal/btcd/issues/18 - Fix issue preventing block 21066 on testnet -- https://github.com/conformal/btcchain/issues/1 - Fix issue preventing block 96464 on testnet -- https://github.com/conformal/btcscript/issues/1 - Optimize transaction lookups - Correct a few cases of list removal that could result in improper cleanup of no longer needed orphans - Add functionality to increase ulimits on non-Windows platforms - Add support for mempool command which allows remote peers to query the transaction memory pool via the bitcoin protocol - Clean up logging a bit - Add a flag to disable checkpoints for developers - Add a lot of useful debug logging such as message summaries - Other minor bug fixes and general code cleanup Initial Release 0.3.0-alpha (Sat Oct 05 2013): - Initial release ================================================ FILE: Dockerfile ================================================ # This Dockerfile builds btcd from source and creates a small (55 MB) docker container based on alpine linux. # # Clone this repository and run the following command to build and tag a fresh btcd amd64 container: # # docker build . -t yourregistry/btcd # # You can use the following command to build an arm64v8 container: # # docker build . -t yourregistry/btcd --build-arg ARCH=arm64v8 # # For more information how to use this docker image visit: # https://github.com/btcsuite/btcd/tree/master/docs # # 8333 Mainnet Bitcoin peer-to-peer port # 8334 Mainet RPC port ARG ARCH=amd64 # using the SHA256 instead of tags # https://github.com/opencontainers/image-spec/blob/main/descriptor.md#digests # https://cloud.google.com/architecture/using-container-images # https://github.com/google/go-containerregistry/blob/main/cmd/crane/README.md # ➜ ~ crane digest golang:1.23.12-alpine3.21 # sha256:4bb4be21ac98da06bc26437ee870c4973f8039f13e9a1a36971b4517632b0fc6 FROM golang@sha256:4bb4be21ac98da06bc26437ee870c4973f8039f13e9a1a36971b4517632b0fc6 AS build-container ARG ARCH ADD . /app WORKDIR /app RUN set -ex \ && if [ "${ARCH}" = "amd64" ]; then export GOARCH=amd64; fi \ && if [ "${ARCH}" = "arm32v7" ]; then export GOARCH=arm; fi \ && if [ "${ARCH}" = "arm64v8" ]; then export GOARCH=arm64; fi \ && echo "Compiling for $GOARCH" \ && go install -v . ./cmd/... FROM $ARCH/alpine:3.21 COPY --from=build-container /go/bin /bin VOLUME ["/root/.btcd"] EXPOSE 8333 8334 ENTRYPOINT ["btcd"] ================================================ FILE: LICENSE ================================================ ISC License Copyright (c) 2013-2025 The btcsuite developers Copyright (c) 2015-2016 The Decred developers Permission to use, copy, modify, and distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ================================================ FILE: Makefile ================================================ PKG := github.com/btcsuite/btcd LINT_PKG := github.com/golangci/golangci-lint/v2/cmd/golangci-lint GOIMPORTS_PKG := golang.org/x/tools/cmd/goimports GO_BIN := ${shell go env GOBIN} # If GOBIN is not set, default to GOPATH/bin. ifeq ($(GO_BIN),) GO_BIN := $(shell go env GOPATH)/bin endif LINT_BIN := $(GO_BIN)/golangci-lint GOIMPORTS_BIN := $(GO_BIN)/goimports LINT_COMMIT := v2.1.6 GOIMPORTS_COMMIT := a24facf9e5586c95743d2f4ad15d148c7a8cf00b GOBUILD := go build -v GOINSTALL := go install -v DEV_TAGS := rpctest GOTEST_DEV = go test -v -tags=$(DEV_TAGS) GOTEST := go test -v COVER_FLAGS = -coverprofile=coverage.txt -covermode=atomic -coverpkg=$(PKG)/... # Linting uses a lot of memory, so keep it under control by limiting the number # of workers if requested. ifneq ($(workers),) LINT_WORKERS = --concurrency=$(workers) endif LINT_TIMEOUT := 5m LINT = $(LINT_BIN) run -v $(LINT_WORKERS) --timeout=$(LINT_TIMEOUT) GREEN := "\\033[0;32m" NC := "\\033[0m" define print echo $(GREEN)$1$(NC) endef #? default: Run `make build` default: build #? all: Run `make build` and `make check` all: build check # ============ # DEPENDENCIES # ============ $(LINT_BIN): @$(call print, "Fetching linter") $(GOINSTALL) $(LINT_PKG)@$(LINT_COMMIT) #? goimports: Install goimports goimports: @$(call print, "Installing goimports.") $(GOINSTALL) $(GOIMPORTS_PKG)@$(GOIMPORTS_COMMIT) # ============ # INSTALLATION # ============ #? build: Build all binaries, place them in project directory build: @$(call print, "Building all binaries") $(GOBUILD) $(PKG) $(GOBUILD) $(PKG)/cmd/btcctl $(GOBUILD) $(PKG)/cmd/gencerts $(GOBUILD) $(PKG)/cmd/findcheckpoint $(GOBUILD) $(PKG)/cmd/addblock #? install: Install all binaries, place them in $GOPATH/bin install: @$(call print, "Installing all binaries") $(GOINSTALL) $(PKG) $(GOINSTALL) $(PKG)/cmd/btcctl $(GOINSTALL) $(PKG)/cmd/gencerts $(GOINSTALL) $(PKG)/cmd/findcheckpoint $(GOINSTALL) $(PKG)/cmd/addblock #? release-install: Install btcd and btcctl release binaries, place them in $GOBIN release-install: @$(call print, "Installing btcd and btcctl release binaries") env CGO_ENABLED=0 $(GOINSTALL) -trimpath -ldflags="-s -w -buildid=" $(PKG) env CGO_ENABLED=0 $(GOINSTALL) -trimpath -ldflags="-s -w -buildid=" $(PKG)/cmd/btcctl # ======= # TESTING # ======= #? check: Run `make unit` check: unit #? unit: Run unit tests unit: @$(call print, "Running unit tests.") $(GOTEST_DEV) ./... -test.timeout=20m cd btcec && $(GOTEST_DEV) ./... -test.timeout=20m cd btcutil && $(GOTEST_DEV) ./... -test.timeout=20m cd btcutil/psbt && $(GOTEST_DEV) ./... -test.timeout=20m #? unit-cover: Run unit coverage tests unit-cover: @$(call print, "Running unit coverage tests.") $(GOTEST) $(COVER_FLAGS) ./... # We need to remove the /v2 pathing from the module to have it work # nicely with the CI tool we use to render live code coverage. cd btcec && $(GOTEST) $(COVER_FLAGS) ./... && sed -i.bak 's/v2\///g' coverage.txt cd btcutil && $(GOTEST) $(COVER_FLAGS) ./... cd btcutil/psbt && $(GOTEST) $(COVER_FLAGS) ./... #? unit-race: Run unit race tests unit-race: @$(call print, "Running unit race tests.") env CGO_ENABLED=1 GORACE="history_size=7 halt_on_errors=1" $(GOTEST) -race -test.timeout=20m ./... cd btcec && env CGO_ENABLED=1 GORACE="history_size=7 halt_on_errors=1" $(GOTEST) -race -test.timeout=20m ./... cd btcutil && env CGO_ENABLED=1 GORACE="history_size=7 halt_on_errors=1" $(GOTEST) -race -test.timeout=20m ./... cd btcutil/psbt && env CGO_ENABLED=1 GORACE="history_size=7 halt_on_errors=1" $(GOTEST) -race -test.timeout=20m ./... # ========= # UTILITIES # ========= #? fmt: Fix imports and formatting source fmt: goimports @$(call print, "Fixing imports.") $(GOIMPORTS_BIN) -w . @$(call print, "Formatting source.") gofmt -l -w -s . #? lint: Lint source lint: $(LINT_BIN) @$(call print, "Linting source.") $(LINT) #? clean: Clean source clean: @$(call print, "Cleaning source.$(NC)") rm -f coverage.txt btcec/coverage.txt btcutil/coverage.txt btcutil/psbt/coverage.txt #? tidy-module: Run 'go mod tidy' for all modules tidy-module: echo "Running 'go mod tidy' for all modules" scripts/tidy_modules.sh .PHONY: all \ default \ build \ check \ unit \ unit-cover \ unit-race \ fmt \ lint \ clean \ tidy-module #? help: Get more info on make commands help: Makefile @echo " Choose a command run in btcd:" @sed -n 's/^#?//p' $< | column -t -s ':' | sort | sed -e 's/^/ /' .PHONY: help ================================================ FILE: README.md ================================================ btcd ==== [![Build Status](https://github.com/btcsuite/btcd/workflows/Build%20and%20Test/badge.svg)](https://github.com/btcsuite/btcd/actions) [![Coverage Status](https://coveralls.io/repos/github/btcsuite/btcd/badge.svg?branch=master)](https://coveralls.io/github/btcsuite/btcd?branch=master) [![ISC License](https://img.shields.io/badge/license-ISC-blue.svg)](http://copyfree.org) [![GoDoc](https://img.shields.io/badge/godoc-reference-blue.svg)](https://pkg.go.dev/github.com/btcsuite/btcd) btcd is an alternative full node bitcoin 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 since October 2013. It properly downloads, validates, and serves the block chain using the exact rules (including consensus bugs) for block acceptance as Bitcoin Core. We have taken great care to avoid btcd causing a fork to the block chain. It includes a full block validation testing framework which contains all of the 'official' block acceptance tests (and some additional ones) that is run on every pull request to help ensure it properly follows consensus. Also, it passes all of the JSON test data in the Bitcoin Core code. It also properly relays newly mined blocks, maintains a transaction pool, and relays individual transactions that have not yet made it into a block. It ensures all individual transactions admitted to the pool follow the rules required by the block chain and also includes more strict checks which filter transactions based on miner requirements ("standard" transactions). One key difference between btcd and Bitcoin Core is that btcd does *NOT* include wallet functionality and this was a very intentional design decision. See the blog entry [here](https://web.archive.org/web/20171125143919/https://blog.conformal.com/btcd-not-your-moms-bitcoin-daemon) for more details. This means you can't actually make or receive payments directly with btcd. That functionality is provided by the [btcwallet](https://github.com/btcsuite/btcwallet) and [Paymetheus](https://github.com/btcsuite/Paymetheus) (Windows-only) projects which are both under active development. ## Requirements [Go](http://golang.org) 1.22 or newer. ## Installation https://github.com/btcsuite/btcd/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: ```bash $ 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. It is also recommended to add `$GOPATH/bin` to your `PATH` at this point. - Run the following commands to obtain btcd, all dependencies, and install it: ```bash $ cd $GOPATH/src/github.com/btcsuite/btcd $ go install -v . ./cmd/... ``` - btcd (and utilities) will now be installed in ```$GOPATH/bin```. If you did not already add the bin directory to your system path during Go installation, we recommend you do so now. ## Updating #### Linux/BSD/MacOSX/POSIX - Build from Source - Run the following commands to update btcd, all dependencies, and install it: ```bash $ cd $GOPATH/src/github.com/btcsuite/btcd $ git pull $ go install -v . ./cmd/... ``` ## Getting Started btcd has several configuration options available to tweak how it runs, but all of the basic operations described in the intro section work with zero configuration. #### Linux/BSD/POSIX/Source ```bash $ ./btcd ``` ## IRC - irc.libera.chat - channel #btcd - [webchat](https://web.libera.chat/gamja/?channels=btcd) ## Issue Tracker The [integrated github issue tracker](https://github.com/btcsuite/btcd/issues) is used for this project. ## Documentation The documentation is a work-in-progress. It is located in the [docs](https://github.com/btcsuite/btcd/tree/master/docs) folder. ## Release Verification Please see our [documentation on the current build/verification process](https://github.com/btcsuite/btcd/tree/master/release) for all our releases for information on how to verify the integrity of published releases using our reproducible build system. ## License btcd is licensed under the [copyfree](http://copyfree.org) ISC License. ================================================ FILE: SECURITY.md ================================================ # Security Policy ## Supported Versions The last major `btcd` release is to be considered the current support version. Given an issue severe enough, a backport will be issued either to the prior major release or the set of releases considered utilized enough. ## Reporting a Vulnerability To report security issues, send an email to security@lightning.engineering (this list isn't to be used for support). The following key can be used to communicate sensitive information: `91FE 464C D751 01DA 6B6B AB60 555C 6465 E5BC B3AF`. ================================================ FILE: addrmgr/addrmanager.go ================================================ // Copyright (c) 2013-2016 The btcsuite developers // Copyright (c) 2015-2018 The Decred developers // Use of this source code is governed by an ISC // license that can be found in the LICENSE file. package addrmgr import ( "container/list" crand "crypto/rand" // for seeding "encoding/base32" "encoding/binary" "encoding/json" "fmt" "io" "math/rand" "net" "os" "path/filepath" "strconv" "strings" "sync" "sync/atomic" "time" "github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/btcsuite/btcd/wire" ) // AddrManager provides a concurrency safe address manager for caching potential // peers on the bitcoin network. type AddrManager struct { mtx sync.RWMutex peersFile string lookupFunc func(string) ([]net.IP, error) rand *rand.Rand key [32]byte addrIndex map[string]*KnownAddress // address key to ka for all addrs. addrNew [newBucketCount]map[string]*KnownAddress addrTried [triedBucketCount]*list.List started int32 shutdown int32 wg sync.WaitGroup quit chan struct{} nTried int nNew int lamtx sync.Mutex localAddresses map[string]*localAddress version int } type serializedKnownAddress struct { Addr string Src string Attempts int TimeStamp int64 LastAttempt int64 LastSuccess int64 Services wire.ServiceFlag SrcServices wire.ServiceFlag // no refcount or tried, that is available from context. } type serializedAddrManager struct { Version int Key [32]byte Addresses []*serializedKnownAddress NewBuckets [newBucketCount][]string // string is NetAddressKey TriedBuckets [triedBucketCount][]string } type localAddress struct { na *wire.NetAddressV2 score AddressPriority } // AddressPriority type is used to describe the hierarchy of local address // discovery methods. type AddressPriority int const ( // InterfacePrio signifies the address is on a local interface InterfacePrio AddressPriority = iota // BoundPrio signifies the address has been explicitly bounded to. BoundPrio // UpnpPrio signifies the address was obtained from UPnP. UpnpPrio // HTTPPrio signifies the address was obtained from an external HTTP service. HTTPPrio // ManualPrio signifies the address was provided by --externalip. ManualPrio ) const ( // needAddressThreshold is the number of addresses under which the // address manager will claim to need more addresses. needAddressThreshold = 1000 // dumpAddressInterval is the interval used to dump the address // cache to disk for future use. dumpAddressInterval = time.Minute * 10 // triedBucketSize is the maximum number of addresses in each // tried address bucket. triedBucketSize = 256 // triedBucketCount is the number of buckets we split tried // addresses over. triedBucketCount = 64 // newBucketSize is the maximum number of addresses in each new address // bucket. newBucketSize = 64 // newBucketCount is the number of buckets that we spread new addresses // over. newBucketCount = 1024 // triedBucketsPerGroup is the number of tried buckets over which an // address group will be spread. triedBucketsPerGroup = 8 // newBucketsPerGroup is the number of new buckets over which an // source address group will be spread. newBucketsPerGroup = 64 // newBucketsPerAddress is the number of buckets a frequently seen new // address may end up in. newBucketsPerAddress = 8 // numMissingDays is the number of days before which we assume an // address has vanished if we have not seen it announced in that long. numMissingDays = 30 // numRetries is the number of tried without a single success before // we assume an address is bad. numRetries = 3 // maxFailures is the maximum number of failures we will accept without // a success before considering an address bad. maxFailures = 10 // minBadDays is the number of days since the last success before we // will consider evicting an address. minBadDays = 7 // getAddrMax is the most addresses that we will send in response // to a getAddr (in practise the most addresses we will return from a // call to AddressCache()). getAddrMax = 2500 // getAddrPercent is the percentage of total addresses known that we // will share with a call to AddressCache. getAddrPercent = 23 // serialisationVersion is the current version of the on-disk format. serialisationVersion = 2 ) // updateAddress is a helper function to either update an address already known // to the address manager, or to add the address if not already known. func (a *AddrManager) updateAddress(netAddr, srcAddr *wire.NetAddressV2) { // Filter out non-routable addresses. Note that non-routable // also includes invalid and local addresses. if !IsRoutable(netAddr) { return } addr := NetAddressKey(netAddr) ka := a.find(netAddr) if ka != nil { // TODO: only update addresses periodically. // Update the last seen time and services. // note that to prevent causing excess garbage on getaddr // messages the netaddresses in addrmanager are *immutable*, // if we need to change them then we replace the pointer with a // new copy so that we don't have to copy every na for getaddr. if netAddr.Timestamp.After(ka.na.Timestamp) || (ka.na.Services&netAddr.Services) != netAddr.Services { naCopy := *ka.na naCopy.Timestamp = netAddr.Timestamp naCopy.AddService(netAddr.Services) ka.mtx.Lock() ka.na = &naCopy ka.mtx.Unlock() } // If already in tried, we have nothing to do here. if ka.tried { return } // Already at our max? if ka.refs == newBucketsPerAddress { return } // The more entries we have, the less likely we are to add more. // likelihood is 2N. factor := int32(2 * ka.refs) if a.rand.Int31n(factor) != 0 { return } } else { // Make a copy of the net address to avoid races since it is // updated elsewhere in the addrmanager code and would otherwise // change the actual netaddress on the peer. netAddrCopy := *netAddr ka = &KnownAddress{na: &netAddrCopy, srcAddr: srcAddr} a.addrIndex[addr] = ka a.nNew++ // XXX time penalty? } bucket := a.getNewBucket(netAddr, srcAddr) // Already exists? if _, ok := a.addrNew[bucket][addr]; ok { return } // Enforce max addresses. if len(a.addrNew[bucket]) > newBucketSize { log.Tracef("new bucket is full, expiring old") a.expireNew(bucket) } // Add to new bucket. ka.refs++ a.addrNew[bucket][addr] = ka log.Tracef("Added new address %s for a total of %d addresses", addr, a.nTried+a.nNew) } // expireNew makes space in the new buckets by expiring the really bad entries. // If no bad entries are available we look at a few and remove the oldest. func (a *AddrManager) expireNew(bucket int) { // First see if there are any entries that are so bad we can just throw // them away. otherwise we throw away the oldest entry in the cache. // Bitcoind here chooses four random and just throws the oldest of // those away, but we keep track of oldest in the initial traversal and // use that information instead. var oldest *KnownAddress for k, v := range a.addrNew[bucket] { if v.isBad() { log.Tracef("expiring bad address %v", k) delete(a.addrNew[bucket], k) v.refs-- if v.refs == 0 { a.nNew-- delete(a.addrIndex, k) } continue } if oldest == nil { oldest = v } else if !v.na.Timestamp.After(oldest.na.Timestamp) { oldest = v } } if oldest != nil { key := NetAddressKey(oldest.na) log.Tracef("expiring oldest address %v", key) delete(a.addrNew[bucket], key) oldest.refs-- if oldest.refs == 0 { a.nNew-- delete(a.addrIndex, key) } } } // pickTried selects an address from the tried bucket to be evicted. // We just choose the eldest. Bitcoind selects 4 random entries and throws away // the older of them. func (a *AddrManager) pickTried(bucket int) *list.Element { var oldest *KnownAddress var oldestElem *list.Element for e := a.addrTried[bucket].Front(); e != nil; e = e.Next() { ka := e.Value.(*KnownAddress) if oldest == nil || oldest.na.Timestamp.After(ka.na.Timestamp) { oldestElem = e oldest = ka } } return oldestElem } func (a *AddrManager) getNewBucket(netAddr, srcAddr *wire.NetAddressV2) int { // bitcoind: // doublesha256(key + sourcegroup + int64(doublesha256(key + group + sourcegroup))%bucket_per_source_group) % num_new_buckets data1 := []byte{} data1 = append(data1, a.key[:]...) data1 = append(data1, []byte(GroupKey(netAddr))...) data1 = append(data1, []byte(GroupKey(srcAddr))...) hash1 := chainhash.DoubleHashB(data1) hash64 := binary.LittleEndian.Uint64(hash1) hash64 %= newBucketsPerGroup var hashbuf [8]byte binary.LittleEndian.PutUint64(hashbuf[:], hash64) data2 := []byte{} data2 = append(data2, a.key[:]...) data2 = append(data2, GroupKey(srcAddr)...) data2 = append(data2, hashbuf[:]...) hash2 := chainhash.DoubleHashB(data2) return int(binary.LittleEndian.Uint64(hash2) % newBucketCount) } func (a *AddrManager) getTriedBucket(netAddr *wire.NetAddressV2) int { // bitcoind hashes this as: // doublesha256(key + group + truncate_to_64bits(doublesha256(key)) % buckets_per_group) % num_buckets data1 := []byte{} data1 = append(data1, a.key[:]...) data1 = append(data1, []byte(NetAddressKey(netAddr))...) hash1 := chainhash.DoubleHashB(data1) hash64 := binary.LittleEndian.Uint64(hash1) hash64 %= triedBucketsPerGroup var hashbuf [8]byte binary.LittleEndian.PutUint64(hashbuf[:], hash64) data2 := []byte{} data2 = append(data2, a.key[:]...) data2 = append(data2, GroupKey(netAddr)...) data2 = append(data2, hashbuf[:]...) hash2 := chainhash.DoubleHashB(data2) return int(binary.LittleEndian.Uint64(hash2) % triedBucketCount) } // addressHandler is the main handler for the address manager. It must be run // as a goroutine. func (a *AddrManager) addressHandler() { dumpAddressTicker := time.NewTicker(dumpAddressInterval) defer dumpAddressTicker.Stop() out: for { select { case <-dumpAddressTicker.C: a.savePeers() case <-a.quit: break out } } a.savePeers() a.wg.Done() log.Trace("Address handler done") } // savePeers saves all the known addresses to a file so they can be read back // in at next run. func (a *AddrManager) savePeers() { a.mtx.Lock() defer a.mtx.Unlock() // First we make a serialisable datastructure so we can encode it to // json. sam := new(serializedAddrManager) sam.Version = a.version copy(sam.Key[:], a.key[:]) sam.Addresses = make([]*serializedKnownAddress, len(a.addrIndex)) i := 0 for k, v := range a.addrIndex { ska := new(serializedKnownAddress) ska.Addr = k ska.TimeStamp = v.na.Timestamp.Unix() ska.Src = NetAddressKey(v.srcAddr) ska.Attempts = v.attempts ska.LastAttempt = v.lastattempt.Unix() ska.LastSuccess = v.lastsuccess.Unix() if a.version > 1 { ska.Services = v.na.Services ska.SrcServices = v.srcAddr.Services } // Tried and refs are implicit in the rest of the structure // and will be worked out from context on unserialisation. sam.Addresses[i] = ska i++ } for i := range a.addrNew { sam.NewBuckets[i] = make([]string, len(a.addrNew[i])) j := 0 for k := range a.addrNew[i] { sam.NewBuckets[i][j] = k j++ } } for i := range a.addrTried { sam.TriedBuckets[i] = make([]string, a.addrTried[i].Len()) j := 0 for e := a.addrTried[i].Front(); e != nil; e = e.Next() { ka := e.Value.(*KnownAddress) sam.TriedBuckets[i][j] = NetAddressKey(ka.na) j++ } } w, err := os.Create(a.peersFile) if err != nil { log.Errorf("Error opening file %s: %v", a.peersFile, err) return } enc := json.NewEncoder(w) defer w.Close() if err := enc.Encode(&sam); err != nil { log.Errorf("Failed to encode file %s: %v", a.peersFile, err) return } } // loadPeers loads the known address from the saved file. If empty, missing, or // malformed file, just don't load anything and start fresh func (a *AddrManager) loadPeers() { a.mtx.Lock() defer a.mtx.Unlock() err := a.deserializePeers(a.peersFile) if err != nil { log.Errorf("Failed to parse file %s: %v", a.peersFile, err) // if it is invalid we nuke the old one unconditionally. err = os.Remove(a.peersFile) if err != nil { log.Warnf("Failed to remove corrupt peers file %s: %v", a.peersFile, err) } a.reset() return } log.Infof("Loaded %d addresses from file '%s'", a.numAddresses(), a.peersFile) } func (a *AddrManager) deserializePeers(filePath string) error { _, err := os.Stat(filePath) if os.IsNotExist(err) { return nil } r, err := os.Open(filePath) if err != nil { return fmt.Errorf("%s error opening file: %v", filePath, err) } defer r.Close() var sam serializedAddrManager dec := json.NewDecoder(r) err = dec.Decode(&sam) if err != nil { return fmt.Errorf("error reading %s: %v", filePath, err) } // Since decoding JSON is backwards compatible (i.e., only decodes // fields it understands), we'll only return an error upon seeing a // version past our latest supported version. if sam.Version > serialisationVersion { return fmt.Errorf("unknown version %v in serialized "+ "addrmanager", sam.Version) } copy(a.key[:], sam.Key[:]) for _, v := range sam.Addresses { ka := new(KnownAddress) // The first version of the serialized address manager was not // aware of the service bits associated with this address, so // we'll assign a default of SFNodeNetwork to it. if sam.Version == 1 { v.Services = wire.SFNodeNetwork } ka.na, err = a.DeserializeNetAddress(v.Addr, v.Services) if err != nil { return fmt.Errorf("failed to deserialize netaddress "+ "%s: %v", v.Addr, err) } // The first version of the serialized address manager was not // aware of the service bits associated with the source address, // so we'll assign a default of SFNodeNetwork to it. if sam.Version == 1 { v.SrcServices = wire.SFNodeNetwork } ka.srcAddr, err = a.DeserializeNetAddress(v.Src, v.SrcServices) if err != nil { return fmt.Errorf("failed to deserialize netaddress "+ "%s: %v", v.Src, err) } ka.attempts = v.Attempts ka.lastattempt = time.Unix(v.LastAttempt, 0) ka.lastsuccess = time.Unix(v.LastSuccess, 0) a.addrIndex[NetAddressKey(ka.na)] = ka } for i := range sam.NewBuckets { for _, val := range sam.NewBuckets[i] { ka, ok := a.addrIndex[val] if !ok { return fmt.Errorf("newbucket contains %s but "+ "none in address list", val) } if ka.refs == 0 { a.nNew++ } ka.refs++ a.addrNew[i][val] = ka } } for i := range sam.TriedBuckets { for _, val := range sam.TriedBuckets[i] { ka, ok := a.addrIndex[val] if !ok { return fmt.Errorf("Newbucket contains %s but "+ "none in address list", val) } ka.tried = true a.nTried++ a.addrTried[i].PushBack(ka) } } // Sanity checking. for k, v := range a.addrIndex { if v.refs == 0 && !v.tried { return fmt.Errorf("address %s after serialisation "+ "with no references", k) } if v.refs > 0 && v.tried { return fmt.Errorf("address %s after serialisation "+ "which is both new and tried!", k) } } return nil } // DeserializeNetAddress converts a given address string to a *wire.NetAddress. func (a *AddrManager) DeserializeNetAddress(addr string, services wire.ServiceFlag) (*wire.NetAddressV2, error) { host, portStr, err := net.SplitHostPort(addr) if err != nil { return nil, err } port, err := strconv.ParseUint(portStr, 10, 16) if err != nil { return nil, err } return a.HostToNetAddress(host, uint16(port), services) } // Start begins the core address handler which manages a pool of known // addresses, timeouts, and interval based writes. func (a *AddrManager) Start() { // Already started? if atomic.AddInt32(&a.started, 1) != 1 { return } log.Trace("Starting address manager") // Load peers we already know about from file. a.loadPeers() // Start the address ticker to save addresses periodically. a.wg.Add(1) go a.addressHandler() } // Stop gracefully shuts down the address manager by stopping the main handler. func (a *AddrManager) Stop() error { if atomic.AddInt32(&a.shutdown, 1) != 1 { log.Warnf("Address manager is already in the process of " + "shutting down") return nil } log.Infof("Address manager shutting down") close(a.quit) a.wg.Wait() return nil } // AddAddresses adds new addresses to the address manager. It enforces a max // number of addresses and silently ignores duplicate addresses. It is // safe for concurrent access. func (a *AddrManager) AddAddresses(addrs []*wire.NetAddressV2, srcAddr *wire.NetAddressV2) { a.mtx.Lock() defer a.mtx.Unlock() for _, na := range addrs { a.updateAddress(na, srcAddr) } } // AddAddress adds a new address to the address manager. It enforces a max // number of addresses and silently ignores duplicate addresses. It is // safe for concurrent access. func (a *AddrManager) AddAddress(addr, srcAddr *wire.NetAddressV2) { a.mtx.Lock() defer a.mtx.Unlock() a.updateAddress(addr, srcAddr) } // AddAddressByIP adds an address where we are given an ip:port and not a // wire.NetAddress. func (a *AddrManager) AddAddressByIP(addrIP string) error { // Split IP and port addr, portStr, err := net.SplitHostPort(addrIP) if err != nil { return err } // Put it in wire.Netaddress ip := net.ParseIP(addr) if ip == nil { return fmt.Errorf("invalid ip address %s", addr) } port, err := strconv.ParseUint(portStr, 10, 0) if err != nil { return fmt.Errorf("invalid port %s: %v", portStr, err) } na := wire.NetAddressV2FromBytes(time.Now(), 0, ip, uint16(port)) a.AddAddress(na, na) // XXX use correct src address return nil } // NumAddresses returns the number of addresses known to the address manager. func (a *AddrManager) numAddresses() int { return a.nTried + a.nNew } // NumAddresses returns the number of addresses known to the address manager. func (a *AddrManager) NumAddresses() int { a.mtx.RLock() defer a.mtx.RUnlock() return a.numAddresses() } // NeedMoreAddresses returns whether or not the address manager needs more // addresses. func (a *AddrManager) NeedMoreAddresses() bool { a.mtx.RLock() defer a.mtx.RUnlock() return a.numAddresses() < needAddressThreshold } // AddressCache returns the current address cache. It must be treated as // read-only (but since it is a copy now, this is not as dangerous). func (a *AddrManager) AddressCache() []*wire.NetAddressV2 { allAddr := a.getAddresses() numAddresses := len(allAddr) * getAddrPercent / 100 if numAddresses > getAddrMax { numAddresses = getAddrMax } // Fisher-Yates shuffle the array. We only need to do the first // `numAddresses' since we are throwing the rest. for i := 0; i < numAddresses; i++ { // pick a number between current index and the end j := rand.Intn(len(allAddr)-i) + i allAddr[i], allAddr[j] = allAddr[j], allAddr[i] } // slice off the limit we are willing to share. return allAddr[0:numAddresses] } // getAddresses returns all of the addresses currently found within the // manager's address cache. func (a *AddrManager) getAddresses() []*wire.NetAddressV2 { a.mtx.RLock() defer a.mtx.RUnlock() addrIndexLen := len(a.addrIndex) if addrIndexLen == 0 { return nil } addrs := make([]*wire.NetAddressV2, 0, addrIndexLen) for _, v := range a.addrIndex { addrs = append(addrs, v.na) } return addrs } // reset resets the address manager by reinitialising the random source // and allocating fresh empty bucket storage. func (a *AddrManager) reset() { a.addrIndex = make(map[string]*KnownAddress) // fill key with bytes from a good random source. io.ReadFull(crand.Reader, a.key[:]) for i := range a.addrNew { a.addrNew[i] = make(map[string]*KnownAddress) } for i := range a.addrTried { a.addrTried[i] = list.New() } } // HostToNetAddress returns a netaddress given a host address. If the address // is a Tor .onion address this will be taken care of. Else if the host is // not an IP address it will be resolved (via Tor if required). func (a *AddrManager) HostToNetAddress(host string, port uint16, services wire.ServiceFlag) (*wire.NetAddressV2, error) { var ( na *wire.NetAddressV2 ip net.IP ) // Tor v2 address is 16 char base32 + ".onion" if len(host) == wire.TorV2EncodedSize && host[wire.TorV2EncodedSize-6:] == ".onion" { // go base32 encoding uses capitals (as does the rfc // but Tor and bitcoind tend to user lowercase, so we switch // case here. data, err := base32.StdEncoding.DecodeString( strings.ToUpper(host[:wire.TorV2EncodedSize-6])) if err != nil { return nil, err } na = wire.NetAddressV2FromBytes( time.Now(), services, data, port, ) } else if len(host) == wire.TorV3EncodedSize && host[wire.TorV3EncodedSize-6:] == ".onion" { // Tor v3 addresses are 56 base32 characters with the 6 byte // onion suffix. data, err := base32.StdEncoding.DecodeString( strings.ToUpper(host[:wire.TorV3EncodedSize-6]), ) if err != nil { return nil, err } // The first 32 bytes is the ed25519 public key and is enough // to reconstruct the .onion address. na = wire.NetAddressV2FromBytes( time.Now(), services, data[:wire.TorV3Size], port, ) } else if ip = net.ParseIP(host); ip == nil { ips, err := a.lookupFunc(host) if err != nil { return nil, err } if len(ips) == 0 { return nil, fmt.Errorf("no addresses found for %s", host) } ip = ips[0] na = wire.NetAddressV2FromBytes(time.Now(), services, ip, port) } else { // This is an non-nil IP address that was parsed in the else if // above. na = wire.NetAddressV2FromBytes(time.Now(), services, ip, port) } return na, nil } // NetAddressKey returns a string key in the form of ip:port for IPv4 addresses // or [ip]:port for IPv6 addresses. It also handles onion v2 and v3 addresses. func NetAddressKey(na *wire.NetAddressV2) string { port := strconv.FormatUint(uint64(na.Port), 10) return net.JoinHostPort(na.Addr.String(), port) } // GetAddress returns a single address that should be routable. It picks a // random one from the possible addresses with preference given to ones that // have not been used recently and should not pick 'close' addresses // consecutively. func (a *AddrManager) GetAddress() *KnownAddress { // Protect concurrent access. a.mtx.Lock() defer a.mtx.Unlock() if a.numAddresses() == 0 { return nil } // Use a 50% chance for choosing between tried and new table entries. if a.nTried > 0 && (a.nNew == 0 || a.rand.Intn(2) == 0) { // Tried entry. large := 1 << 30 factor := 1.0 for { // pick a random bucket. bucket := a.rand.Intn(len(a.addrTried)) if a.addrTried[bucket].Len() == 0 { continue } // Pick a random entry in the list e := a.addrTried[bucket].Front() for i := a.rand.Int63n(int64(a.addrTried[bucket].Len())); i > 0; i-- { e = e.Next() } ka := e.Value.(*KnownAddress) randval := a.rand.Intn(large) if float64(randval) < (factor * ka.chance() * float64(large)) { log.Tracef("Selected %v from tried bucket", NetAddressKey(ka.na)) return ka } factor *= 1.2 } } else { // new node. // XXX use a closure/function to avoid repeating this. large := 1 << 30 factor := 1.0 for { // Pick a random bucket. bucket := a.rand.Intn(len(a.addrNew)) if len(a.addrNew[bucket]) == 0 { continue } // Then, a random entry in it. var ka *KnownAddress nth := a.rand.Intn(len(a.addrNew[bucket])) for _, value := range a.addrNew[bucket] { if nth == 0 { ka = value } nth-- } randval := a.rand.Intn(large) if float64(randval) < (factor * ka.chance() * float64(large)) { log.Tracef("Selected %v from new bucket", NetAddressKey(ka.na)) return ka } factor *= 1.2 } } } func (a *AddrManager) find(addr *wire.NetAddressV2) *KnownAddress { return a.addrIndex[NetAddressKey(addr)] } // Attempt increases the given address' attempt counter and updates // the last attempt time. func (a *AddrManager) Attempt(addr *wire.NetAddressV2) { a.mtx.Lock() defer a.mtx.Unlock() // find address. // Surely address will be in tried by now? ka := a.find(addr) if ka == nil { return } // set last tried time to now now := time.Now() ka.mtx.Lock() ka.attempts++ ka.lastattempt = now ka.mtx.Unlock() } // Connected Marks the given address as currently connected and working at the // current time. The address must already be known to AddrManager else it will // be ignored. func (a *AddrManager) Connected(addr *wire.NetAddressV2) { a.mtx.Lock() defer a.mtx.Unlock() ka := a.find(addr) if ka == nil { return } // Update the time as long as it has been 20 minutes since last we did // so. now := time.Now() if now.After(ka.na.Timestamp.Add(time.Minute * 20)) { // ka.na is immutable, so replace it. naCopy := *ka.na naCopy.Timestamp = time.Now() ka.mtx.Lock() ka.na = &naCopy ka.mtx.Unlock() } } // Good marks the given address as good. To be called after a successful // connection and version exchange. If the address is unknown to the address // manager it will be ignored. func (a *AddrManager) Good(addr *wire.NetAddressV2) { a.mtx.Lock() defer a.mtx.Unlock() ka := a.find(addr) if ka == nil { return } // ka.Timestamp is not updated here to avoid leaking information // about currently connected peers. now := time.Now() ka.mtx.Lock() ka.lastsuccess = now ka.lastattempt = now ka.attempts = 0 ka.mtx.Unlock() // tried and refs synchronized via a.mtx // move to tried set, optionally evicting other addresses if need. if ka.tried { return } // ok, need to move it to tried. // remove from all new buckets. // record one of the buckets in question and call it the `first' addrKey := NetAddressKey(addr) oldBucket := -1 for i := range a.addrNew { // we check for existence so we can record the first one if _, ok := a.addrNew[i][addrKey]; ok { delete(a.addrNew[i], addrKey) ka.refs-- if oldBucket == -1 { oldBucket = i } } } a.nNew-- if oldBucket == -1 { // What? wasn't in a bucket after all.... Panic? return } bucket := a.getTriedBucket(ka.na) // Room in this tried bucket? if a.addrTried[bucket].Len() < triedBucketSize { ka.tried = true a.addrTried[bucket].PushBack(ka) a.nTried++ return } // No room, we have to evict something else. entry := a.pickTried(bucket) rmka := entry.Value.(*KnownAddress) // First bucket it would have been put in. newBucket := a.getNewBucket(rmka.na, rmka.srcAddr) // If no room in the original bucket, we put it in a bucket we just // freed up a space in. if len(a.addrNew[newBucket]) >= newBucketSize { newBucket = oldBucket } // replace with ka in list. ka.tried = true entry.Value = ka rmka.tried = false rmka.refs++ // We don't touch a.nTried here since the number of tried stays the same // but we decemented new above, raise it again since we're putting // something back. a.nNew++ rmkey := NetAddressKey(rmka.na) log.Tracef("Replacing %s with %s in tried", rmkey, addrKey) // We made sure there is space here just above. a.addrNew[newBucket][rmkey] = rmka } // SetServices sets the services for the giiven address to the provided value. func (a *AddrManager) SetServices(addr *wire.NetAddressV2, services wire.ServiceFlag) { a.mtx.Lock() defer a.mtx.Unlock() ka := a.find(addr) if ka == nil { return } // Update the services if needed. if ka.na.Services != services { // ka.na is immutable, so replace it. naCopy := *ka.na naCopy.Services = services ka.mtx.Lock() ka.na = &naCopy ka.mtx.Unlock() } } // AddLocalAddress adds na to the list of known local addresses to advertise // with the given priority. func (a *AddrManager) AddLocalAddress(na *wire.NetAddressV2, priority AddressPriority) error { if !IsRoutable(na) { return fmt.Errorf( "address %s is not routable", na.Addr.String(), ) } a.lamtx.Lock() defer a.lamtx.Unlock() key := NetAddressKey(na) la, ok := a.localAddresses[key] if !ok || la.score < priority { if ok { la.score = priority + 1 } else { a.localAddresses[key] = &localAddress{ na: na, score: priority, } } } return nil } // getReachabilityFrom returns the relative reachability of the provided local // address to the provided remote address. func getReachabilityFrom(localAddr, remoteAddr *wire.NetAddressV2) int { const ( Unreachable = 0 Default = iota Teredo Ipv6Weak Ipv4 Ipv6Strong Private ) if !IsRoutable(remoteAddr) { return Unreachable } if remoteAddr.IsTorV3() { if localAddr.IsTorV3() { return Private } lna := localAddr.ToLegacy() if IsOnionCatTor(lna) { // Modern v3 clients should not be able to connect to // deprecated v2 hidden services. return Unreachable } if IsRoutable(localAddr) && IsIPv4(lna) { return Ipv4 } return Default } // We can't be sure if the remote party can actually connect to this // address or not. if localAddr.IsTorV3() { return Default } // Convert the V2 addresses into legacy to access the network // functions. remoteLna := remoteAddr.ToLegacy() localLna := localAddr.ToLegacy() if IsOnionCatTor(remoteLna) { if IsOnionCatTor(localLna) { return Private } if IsRoutable(localAddr) && IsIPv4(localLna) { return Ipv4 } return Default } if IsRFC4380(remoteLna) { if !IsRoutable(localAddr) { return Default } if IsRFC4380(localLna) { return Teredo } if IsIPv4(localLna) { return Ipv4 } return Ipv6Weak } if IsIPv4(remoteLna) { if IsRoutable(localAddr) && IsIPv4(localLna) { return Ipv4 } return Unreachable } /* ipv6 */ var tunnelled bool // Is our v6 is tunnelled? if IsRFC3964(localLna) || IsRFC6052(localLna) || IsRFC6145(localLna) { tunnelled = true } if !IsRoutable(localAddr) { return Default } if IsRFC4380(localLna) { return Teredo } if IsIPv4(localLna) { return Ipv4 } if tunnelled { // only prioritise ipv6 if we aren't tunnelling it. return Ipv6Weak } return Ipv6Strong } // GetBestLocalAddress returns the most appropriate local address to use // for the given remote address. func (a *AddrManager) GetBestLocalAddress(remoteAddr *wire.NetAddressV2) *wire.NetAddressV2 { a.lamtx.Lock() defer a.lamtx.Unlock() bestreach := 0 var bestscore AddressPriority var bestAddress *wire.NetAddressV2 for _, la := range a.localAddresses { reach := getReachabilityFrom(la.na, remoteAddr) if reach > bestreach || (reach == bestreach && la.score > bestscore) { bestreach = reach bestscore = la.score bestAddress = la.na } } if bestAddress != nil { log.Debugf("Suggesting address %s:%d for %s:%d", bestAddress.Addr.String(), bestAddress.Port, remoteAddr.Addr.String(), remoteAddr.Port) } else { log.Debugf("No worthy address for %s:%d", remoteAddr.Addr.String(), remoteAddr.Port) // Send something unroutable if nothing suitable. var ip net.IP if remoteAddr.IsTorV3() { ip = net.IPv4zero } else { remoteLna := remoteAddr.ToLegacy() if !IsIPv4(remoteLna) && !IsOnionCatTor(remoteLna) { ip = net.IPv6zero } else { ip = net.IPv4zero } } services := wire.SFNodeNetwork | wire.SFNodeWitness | wire.SFNodeBloom bestAddress = wire.NetAddressV2FromBytes( time.Now(), services, ip, 0, ) } return bestAddress } // New returns a new bitcoin address manager. // Use Start to begin processing asynchronous address updates. func New(dataDir string, lookupFunc func(string) ([]net.IP, error)) *AddrManager { am := AddrManager{ peersFile: filepath.Join(dataDir, "peers.json"), lookupFunc: lookupFunc, rand: rand.New(rand.NewSource(time.Now().UnixNano())), quit: make(chan struct{}), localAddresses: make(map[string]*localAddress), version: serialisationVersion, } am.reset() return &am } ================================================ FILE: addrmgr/addrmanager_internal_test.go ================================================ package addrmgr import ( "math/rand" "net" "testing" "time" "github.com/btcsuite/btcd/wire" ) // randAddr generates a *wire.NetAddressV2 backed by a random IPv4/IPv6 // address. Some of the returned addresses may not be routable. func randAddr(t *testing.T) *wire.NetAddressV2 { t.Helper() ipv4 := rand.Intn(2) == 0 var ip net.IP if ipv4 { var b [4]byte if _, err := rand.Read(b[:]); err != nil { t.Fatal(err) } ip = b[:] } else { var b [16]byte if _, err := rand.Read(b[:]); err != nil { t.Fatal(err) } ip = b[:] } services := wire.ServiceFlag(rand.Uint64()) port := uint16(rand.Uint32()) return wire.NetAddressV2FromBytes( time.Now(), services, ip, port, ) } // routableRandAddr generates a *wire.NetAddressV2 backed by a random IPv4/IPv6 // address that is always routable. func routableRandAddr(t *testing.T) *wire.NetAddressV2 { t.Helper() var addr *wire.NetAddressV2 // If the address is not routable, try again. routable := false for !routable { addr = randAddr(t) routable = IsRoutable(addr) } return addr } // assertAddr ensures that the two addresses match. The timestamp is not // checked as it does not affect uniquely identifying a specific address. func assertAddr(t *testing.T, got, expected *wire.NetAddressV2) { if got.Services != expected.Services { t.Fatalf("expected address services %v, got %v", expected.Services, got.Services) } gotAddr := got.Addr.String() expectedAddr := expected.Addr.String() if gotAddr != expectedAddr { t.Fatalf("expected address IP %v, got %v", expectedAddr, gotAddr) } if got.Port != expected.Port { t.Fatalf("expected address port %d, got %d", expected.Port, got.Port) } } // assertAddrs ensures that the manager's address cache matches the given // expected addresses. func assertAddrs(t *testing.T, addrMgr *AddrManager, expectedAddrs map[string]*wire.NetAddressV2) { t.Helper() addrs := addrMgr.getAddresses() if len(addrs) != len(expectedAddrs) { t.Fatalf("expected to find %d addresses, found %d", len(expectedAddrs), len(addrs)) } for _, addr := range addrs { addrStr := NetAddressKey(addr) expectedAddr, ok := expectedAddrs[addrStr] if !ok { t.Fatalf("expected to find address %v", addrStr) } assertAddr(t, addr, expectedAddr) } } // TestAddrManagerSerialization ensures that we can properly serialize and // deserialize the manager's current address cache. func TestAddrManagerSerialization(t *testing.T) { t.Parallel() // We'll start by creating our address manager backed by a temporary // directory. tempDir := t.TempDir() addrMgr := New(tempDir, nil) // We'll be adding 5 random addresses to the manager. const numAddrs = 5 expectedAddrs := make(map[string]*wire.NetAddressV2, numAddrs) for i := 0; i < numAddrs; i++ { addr := routableRandAddr(t) expectedAddrs[NetAddressKey(addr)] = addr addrMgr.AddAddress(addr, routableRandAddr(t)) } // Now that the addresses have been added, we should be able to retrieve // them. assertAddrs(t, addrMgr, expectedAddrs) // Then, we'll persist these addresses to disk and restart the address // manager. addrMgr.savePeers() addrMgr = New(tempDir, nil) // Finally, we'll read all of the addresses from disk and ensure they // match as expected. addrMgr.loadPeers() assertAddrs(t, addrMgr, expectedAddrs) } // TestAddrManagerV1ToV2 ensures that we can properly upgrade the serialized // version of the address manager from v1 to v2. func TestAddrManagerV1ToV2(t *testing.T) { t.Parallel() // We'll start by creating our address manager backed by a temporary // directory. tempDir := t.TempDir() addrMgr := New(tempDir, nil) // As we're interested in testing the upgrade path from v1 to v2, we'll // override the manager's current version. addrMgr.version = 1 // We'll be adding 5 random addresses to the manager. Since this is v1, // each addresses' services will not be stored. const numAddrs = 5 expectedAddrs := make(map[string]*wire.NetAddressV2, numAddrs) for i := 0; i < numAddrs; i++ { addr := routableRandAddr(t) expectedAddrs[NetAddressKey(addr)] = addr addrMgr.AddAddress(addr, routableRandAddr(t)) } // Then, we'll persist these addresses to disk and restart the address // manager - overriding its version back to v1. addrMgr.savePeers() addrMgr = New(tempDir, nil) addrMgr.version = 1 // When we read all of the addresses back from disk, we should expect to // find all of them, but their services will be set to a default of // SFNodeNetwork since they were not previously stored. After ensuring // that this default is set, we'll override each addresses' services // with the original value from when they were created. addrMgr.loadPeers() addrs := addrMgr.getAddresses() if len(addrs) != len(expectedAddrs) { t.Fatalf("expected to find %d addresses, found %d", len(expectedAddrs), len(addrs)) } for _, addr := range addrs { addrStr := NetAddressKey(addr) expectedAddr, ok := expectedAddrs[addrStr] if !ok { t.Fatalf("expected to find address %v", addrStr) } if addr.Services != wire.SFNodeNetwork { t.Fatalf("expected address services to be %v, got %v", wire.SFNodeNetwork, addr.Services) } addrMgr.SetServices(addr, expectedAddr.Services) } // We'll also bump up the manager's version to v2, which should signal // that it should include the address services when persisting its // state. addrMgr.version = 2 addrMgr.savePeers() // Finally, we'll recreate the manager and ensure that the services were // persisted correctly. addrMgr = New(tempDir, nil) addrMgr.loadPeers() assertAddrs(t, addrMgr, expectedAddrs) } ================================================ FILE: addrmgr/addrmanager_test.go ================================================ // Copyright (c) 2013-2014 The btcsuite developers // Use of this source code is governed by an ISC // license that can be found in the LICENSE file. package addrmgr_test import ( "errors" "fmt" "net" "reflect" "testing" "time" "github.com/btcsuite/btcd/addrmgr" "github.com/btcsuite/btcd/wire" ) // naTest is used to describe a test to be performed against the NetAddressKey // method. type naTest struct { in wire.NetAddressV2 want string } // naTests houses all of the tests to be performed against the NetAddressKey // method. var naTests = make([]naTest, 0) // Put some IP in here for convenience. Points to google. var someIP = "173.194.115.66" // addNaTests func addNaTests() { // IPv4 // Localhost addNaTest("127.0.0.1", 8333, "127.0.0.1:8333") addNaTest("127.0.0.1", 8334, "127.0.0.1:8334") // Class A addNaTest("1.0.0.1", 8333, "1.0.0.1:8333") addNaTest("2.2.2.2", 8334, "2.2.2.2:8334") addNaTest("27.253.252.251", 8335, "27.253.252.251:8335") addNaTest("123.3.2.1", 8336, "123.3.2.1:8336") // Private Class A addNaTest("10.0.0.1", 8333, "10.0.0.1:8333") addNaTest("10.1.1.1", 8334, "10.1.1.1:8334") addNaTest("10.2.2.2", 8335, "10.2.2.2:8335") addNaTest("10.10.10.10", 8336, "10.10.10.10:8336") // Class B addNaTest("128.0.0.1", 8333, "128.0.0.1:8333") addNaTest("129.1.1.1", 8334, "129.1.1.1:8334") addNaTest("180.2.2.2", 8335, "180.2.2.2:8335") addNaTest("191.10.10.10", 8336, "191.10.10.10:8336") // Private Class B addNaTest("172.16.0.1", 8333, "172.16.0.1:8333") addNaTest("172.16.1.1", 8334, "172.16.1.1:8334") addNaTest("172.16.2.2", 8335, "172.16.2.2:8335") addNaTest("172.16.172.172", 8336, "172.16.172.172:8336") // Class C addNaTest("193.0.0.1", 8333, "193.0.0.1:8333") addNaTest("200.1.1.1", 8334, "200.1.1.1:8334") addNaTest("205.2.2.2", 8335, "205.2.2.2:8335") addNaTest("223.10.10.10", 8336, "223.10.10.10:8336") // Private Class C addNaTest("192.168.0.1", 8333, "192.168.0.1:8333") addNaTest("192.168.1.1", 8334, "192.168.1.1:8334") addNaTest("192.168.2.2", 8335, "192.168.2.2:8335") addNaTest("192.168.192.192", 8336, "192.168.192.192:8336") // IPv6 // Localhost addNaTest("::1", 8333, "[::1]:8333") addNaTest("fe80::1", 8334, "[fe80::1]:8334") // Link-local addNaTest("fe80::1:1", 8333, "[fe80::1:1]:8333") addNaTest("fe91::2:2", 8334, "[fe91::2:2]:8334") addNaTest("fea2::3:3", 8335, "[fea2::3:3]:8335") addNaTest("feb3::4:4", 8336, "[feb3::4:4]:8336") // Site-local addNaTest("fec0::1:1", 8333, "[fec0::1:1]:8333") addNaTest("fed1::2:2", 8334, "[fed1::2:2]:8334") addNaTest("fee2::3:3", 8335, "[fee2::3:3]:8335") addNaTest("fef3::4:4", 8336, "[fef3::4:4]:8336") } func addNaTest(ip string, port uint16, want string) { nip := net.ParseIP(ip) na := wire.NetAddressV2FromBytes( time.Now(), wire.SFNodeNetwork, nip, port, ) test := naTest{*na, want} naTests = append(naTests, test) } func lookupFunc(host string) ([]net.IP, error) { return nil, errors.New("not implemented") } func TestStartStop(t *testing.T) { n := addrmgr.New("teststartstop", lookupFunc) n.Start() err := n.Stop() if err != nil { t.Fatalf("Address Manager failed to stop: %v", err) } } func TestAddAddressByIP(t *testing.T) { fmtErr := fmt.Errorf("") addrErr := &net.AddrError{} var tests = []struct { addrIP string err error }{ { someIP + ":8333", nil, }, { someIP, addrErr, }, { someIP[:12] + ":8333", fmtErr, }, { someIP + ":abcd", fmtErr, }, } amgr := addrmgr.New("testaddressbyip", nil) for i, test := range tests { err := amgr.AddAddressByIP(test.addrIP) if test.err != nil && err == nil { t.Errorf("TestGood test %d failed expected an error and got none", i) continue } if test.err == nil && err != nil { t.Errorf("TestGood test %d failed expected no error and got one", i) continue } if reflect.TypeOf(err) != reflect.TypeOf(test.err) { t.Errorf("TestGood test %d failed got %v, want %v", i, reflect.TypeOf(err), reflect.TypeOf(test.err)) continue } } } func TestAddLocalAddress(t *testing.T) { var tests = []struct { address wire.NetAddressV2 priority addrmgr.AddressPriority valid bool }{ { *wire.NetAddressV2FromBytes( time.Now(), 0, net.ParseIP("192.168.0.100"), 0, ), addrmgr.InterfacePrio, false, }, { *wire.NetAddressV2FromBytes( time.Now(), 0, net.ParseIP("204.124.1.1"), 0, ), addrmgr.InterfacePrio, true, }, { *wire.NetAddressV2FromBytes( time.Now(), 0, net.ParseIP("204.124.1.1"), 0, ), addrmgr.BoundPrio, true, }, { *wire.NetAddressV2FromBytes( time.Now(), 0, net.ParseIP("::1"), 0, ), addrmgr.InterfacePrio, false, }, { *wire.NetAddressV2FromBytes( time.Now(), 0, net.ParseIP("fe80::1"), 0, ), addrmgr.InterfacePrio, false, }, { *wire.NetAddressV2FromBytes( time.Now(), 0, net.ParseIP("2620:100::1"), 0, ), addrmgr.InterfacePrio, true, }, } amgr := addrmgr.New("testaddlocaladdress", nil) for x, test := range tests { result := amgr.AddLocalAddress(&test.address, test.priority) if result == nil && !test.valid { t.Errorf("TestAddLocalAddress test #%d failed: %s should have "+ "been accepted", x, test.address.Addr.String()) continue } if result != nil && test.valid { t.Errorf("TestAddLocalAddress test #%d failed: %s should not have "+ "been accepted", x, test.address.Addr.String()) continue } } } func TestAttempt(t *testing.T) { n := addrmgr.New("testattempt", lookupFunc) // Add a new address and get it err := n.AddAddressByIP(someIP + ":8333") if err != nil { t.Fatalf("Adding address failed: %v", err) } ka := n.GetAddress() if !ka.LastAttempt().IsZero() { t.Errorf("Address should not have attempts, but does") } na := ka.NetAddress() n.Attempt(na) if ka.LastAttempt().IsZero() { t.Errorf("Address should have an attempt, but does not") } } func TestConnected(t *testing.T) { n := addrmgr.New("testconnected", lookupFunc) // Add a new address and get it err := n.AddAddressByIP(someIP + ":8333") if err != nil { t.Fatalf("Adding address failed: %v", err) } ka := n.GetAddress() na := ka.NetAddress() // make it an hour ago na.Timestamp = time.Unix(time.Now().Add(time.Hour*-1).Unix(), 0) n.Connected(na) if !ka.NetAddress().Timestamp.After(na.Timestamp) { t.Errorf("Address should have a new timestamp, but does not") } } func TestNeedMoreAddresses(t *testing.T) { n := addrmgr.New("testneedmoreaddresses", lookupFunc) addrsToAdd := 1500 b := n.NeedMoreAddresses() if !b { t.Errorf("Expected that we need more addresses") } addrs := make([]*wire.NetAddressV2, addrsToAdd) var err error for i := 0; i < addrsToAdd; i++ { s := fmt.Sprintf("%d.%d.173.147:8333", i/128+60, i%128+60) addrs[i], err = n.DeserializeNetAddress(s, wire.SFNodeNetwork) if err != nil { t.Errorf("Failed to turn %s into an address: %v", s, err) } } srcAddr := wire.NetAddressV2FromBytes( time.Now(), 0, net.IPv4(173, 144, 173, 111), 8333, ) n.AddAddresses(addrs, srcAddr) numAddrs := n.NumAddresses() if numAddrs > addrsToAdd { t.Errorf("Number of addresses is too many %d vs %d", numAddrs, addrsToAdd) } b = n.NeedMoreAddresses() if b { t.Errorf("Expected that we don't need more addresses") } } func TestGood(t *testing.T) { n := addrmgr.New("testgood", lookupFunc) addrsToAdd := 64 * 64 addrs := make([]*wire.NetAddressV2, addrsToAdd) var err error for i := 0; i < addrsToAdd; i++ { s := fmt.Sprintf("%d.173.147.%d:8333", i/64+60, i%64+60) addrs[i], err = n.DeserializeNetAddress(s, wire.SFNodeNetwork) if err != nil { t.Errorf("Failed to turn %s into an address: %v", s, err) } } srcAddr := wire.NetAddressV2FromBytes( time.Now(), 0, net.IPv4(173, 144, 173, 111), 8333, ) n.AddAddresses(addrs, srcAddr) for _, addr := range addrs { n.Good(addr) } numAddrs := n.NumAddresses() if numAddrs >= addrsToAdd { t.Errorf("Number of addresses is too many: %d vs %d", numAddrs, addrsToAdd) } numCache := len(n.AddressCache()) if numCache >= numAddrs/4 { t.Errorf("Number of addresses in cache: got %d, want %d", numCache, numAddrs/4) } } func TestGetAddress(t *testing.T) { n := addrmgr.New("testgetaddress", lookupFunc) // Get an address from an empty set (should error) if rv := n.GetAddress(); rv != nil { t.Errorf("GetAddress failed: got: %v want: %v\n", rv, nil) } // Add a new address and get it err := n.AddAddressByIP(someIP + ":8333") if err != nil { t.Fatalf("Adding address failed: %v", err) } ka := n.GetAddress() if ka == nil { t.Fatalf("Did not get an address where there is one in the pool") } if ka.NetAddress().Addr.String() != someIP { t.Errorf("Wrong IP: got %v, want %v", ka.NetAddress().Addr.String(), someIP) } // Mark this as a good address and get it n.Good(ka.NetAddress()) ka = n.GetAddress() if ka == nil { t.Fatalf("Did not get an address where there is one in the pool") } if ka.NetAddress().Addr.String() != someIP { t.Errorf("Wrong IP: got %v, want %v", ka.NetAddress().Addr.String(), someIP) } numAddrs := n.NumAddresses() if numAddrs != 1 { t.Errorf("Wrong number of addresses: got %d, want %d", numAddrs, 1) } } func TestGetBestLocalAddress(t *testing.T) { localAddrs := []wire.NetAddressV2{ *wire.NetAddressV2FromBytes( time.Now(), 0, net.ParseIP("192.168.0.100"), 0, ), *wire.NetAddressV2FromBytes( time.Now(), 0, net.ParseIP("::1"), 0, ), *wire.NetAddressV2FromBytes( time.Now(), 0, net.ParseIP("fe80::1"), 0, ), *wire.NetAddressV2FromBytes( time.Now(), 0, net.ParseIP("2001:470::1"), 0, ), } var tests = []struct { remoteAddr wire.NetAddressV2 want0 wire.NetAddressV2 want1 wire.NetAddressV2 want2 wire.NetAddressV2 want3 wire.NetAddressV2 }{ { // Remote connection from public IPv4 *wire.NetAddressV2FromBytes( time.Now(), 0, net.ParseIP("204.124.8.1"), 0, ), *wire.NetAddressV2FromBytes( time.Now(), 0, net.IPv4zero, 0, ), *wire.NetAddressV2FromBytes( time.Now(), 0, net.IPv4zero, 0, ), *wire.NetAddressV2FromBytes( time.Now(), 0, net.ParseIP("204.124.8.100"), 0, ), *wire.NetAddressV2FromBytes( time.Now(), 0, net.ParseIP("fd87:d87e:eb43:25::1"), 0, ), }, { // Remote connection from private IPv4 *wire.NetAddressV2FromBytes( time.Now(), 0, net.ParseIP("172.16.0.254"), 0, ), *wire.NetAddressV2FromBytes( time.Now(), 0, net.IPv4zero, 0, ), *wire.NetAddressV2FromBytes( time.Now(), 0, net.IPv4zero, 0, ), *wire.NetAddressV2FromBytes( time.Now(), 0, net.IPv4zero, 0, ), *wire.NetAddressV2FromBytes( time.Now(), 0, net.IPv4zero, 0, ), }, { // Remote connection from public IPv6 *wire.NetAddressV2FromBytes( time.Now(), 0, net.ParseIP("2602:100:abcd::102"), 0, ), *wire.NetAddressV2FromBytes( time.Now(), 0, net.IPv6zero, 0, ), *wire.NetAddressV2FromBytes( time.Now(), 0, net.ParseIP("2001:470::1"), 0, ), *wire.NetAddressV2FromBytes( time.Now(), 0, net.ParseIP("2001:470::1"), 0, ), *wire.NetAddressV2FromBytes( time.Now(), 0, net.ParseIP("2001:470::1"), 0, ), }, /* XXX { // Remote connection from Tor wire.NetAddress{IP: net.ParseIP("fd87:d87e:eb43::100")}, wire.NetAddress{IP: net.IPv4zero}, wire.NetAddress{IP: net.ParseIP("204.124.8.100")}, wire.NetAddress{IP: net.ParseIP("fd87:d87e:eb43:25::1")}, }, */ } amgr := addrmgr.New("testgetbestlocaladdress", nil) // Test against default when there's no address for x, test := range tests { got := amgr.GetBestLocalAddress(&test.remoteAddr) wantAddr := test.want0.Addr.String() gotAddr := got.Addr.String() if wantAddr != gotAddr { remoteAddr := test.remoteAddr.Addr.String() t.Errorf("TestGetBestLocalAddress test1 #%d failed for remote address %s: want %s got %s", x, remoteAddr, wantAddr, gotAddr) continue } } for _, localAddr := range localAddrs { amgr.AddLocalAddress(&localAddr, addrmgr.InterfacePrio) } // Test against want1 for x, test := range tests { got := amgr.GetBestLocalAddress(&test.remoteAddr) wantAddr := test.want1.Addr.String() gotAddr := got.Addr.String() if wantAddr != gotAddr { remoteAddr := test.remoteAddr.Addr.String() t.Errorf("TestGetBestLocalAddress test1 #%d failed for remote address %s: want %s got %s", x, remoteAddr, wantAddr, gotAddr) continue } } // Add a public IP to the list of local addresses. localAddr := wire.NetAddressV2FromBytes( time.Now(), 0, net.ParseIP("204.124.8.100"), 0, ) amgr.AddLocalAddress(localAddr, addrmgr.InterfacePrio) // Test against want2 for x, test := range tests { got := amgr.GetBestLocalAddress(&test.remoteAddr) wantAddr := test.want2.Addr.String() gotAddr := got.Addr.String() if wantAddr != gotAddr { remoteAddr := test.remoteAddr.Addr.String() t.Errorf("TestGetBestLocalAddress test2 #%d failed for remote address %s: want %s got %s", x, remoteAddr, wantAddr, gotAddr) continue } } /* // Add a Tor generated IP address localAddr = wire.NetAddress{IP: net.ParseIP("fd87:d87e:eb43:25::1")} amgr.AddLocalAddress(&localAddr, addrmgr.ManualPrio) // Test against want3 for x, test := range tests { got := amgr.GetBestLocalAddress(&test.remoteAddr) if !test.want3.IP.Equal(got.IP) { t.Errorf("TestGetBestLocalAddress test3 #%d failed for remote address %s: want %s got %s", x, test.remoteAddr.IP, test.want3.IP, got.IP) continue } } */ } func TestNetAddressKey(t *testing.T) { addNaTests() t.Logf("Running %d tests", len(naTests)) for i, test := range naTests { key := addrmgr.NetAddressKey(&test.in) if key != test.want { t.Errorf("NetAddressKey #%d\n got: %s want: %s", i, key, test.want) continue } } } ================================================ FILE: addrmgr/cov_report.sh ================================================ #!/bin/sh # This script uses the standard Go test coverage tools to generate a test coverage report. # Run tests with coverage enabled and generate coverage profile. go test -cover -coverprofile=coverage.txt ./... # Display function-level coverage statistics. go tool cover -func=coverage.txt ================================================ FILE: addrmgr/doc.go ================================================ // Copyright (c) 2014 The btcsuite developers // Use of this source code is governed by an ISC // license that can be found in the LICENSE file. /* Package addrmgr implements concurrency safe Bitcoin address manager. # Address Manager Overview In order maintain the peer-to-peer Bitcoin network, there needs to be a source of addresses to connect to as nodes come and go. The Bitcoin protocol provides the getaddr and addr messages to allow peers to communicate known addresses with each other. However, there needs to a mechanism to store those results and select peers from them. It is also important to note that remote peers can't be trusted to send valid peers nor attempt to provide you with only peers they control with malicious intent. With that in mind, this package provides a concurrency safe address manager for caching and selecting peers in a non-deterministic manner. The general idea is the caller adds addresses to the address manager and notifies it when addresses are connected, known good, and attempted. The caller also requests addresses as it needs them. The address manager internally segregates the addresses into groups and non-deterministically selects groups in a cryptographically random manner. This reduce the chances multiple addresses from the same nets are selected which generally helps provide greater peer diversity, and perhaps more importantly, drastically reduces the chances an attacker is able to coerce your peer into only connecting to nodes they control. The address manager also understands routability and Tor addresses and tries hard to only return routable addresses. In addition, it uses the information provided by the caller about connected, known good, and attempted addresses to periodically purge peers which no longer appear to be good peers as well as bias the selection toward known good peers. The general idea is to make a best effort at only providing usable addresses. */ package addrmgr ================================================ FILE: addrmgr/internal_test.go ================================================ // Copyright (c) 2013-2015 The btcsuite developers // Use of this source code is governed by an ISC // license that can be found in the LICENSE file. package addrmgr import ( "time" "github.com/btcsuite/btcd/wire" ) func TstKnownAddressIsBad(ka *KnownAddress) bool { return ka.isBad() } func TstKnownAddressChance(ka *KnownAddress) float64 { return ka.chance() } func TstNewKnownAddress(na *wire.NetAddressV2, attempts int, lastattempt, lastsuccess time.Time, tried bool, refs int) *KnownAddress { return &KnownAddress{na: na, attempts: attempts, lastattempt: lastattempt, lastsuccess: lastsuccess, tried: tried, refs: refs} } ================================================ FILE: addrmgr/knownaddress.go ================================================ // Copyright (c) 2013-2014 The btcsuite developers // Use of this source code is governed by an ISC // license that can be found in the LICENSE file. package addrmgr import ( "sync" "time" "github.com/btcsuite/btcd/wire" ) // KnownAddress tracks information about a known network address that is used // to determine how viable an address is. type KnownAddress struct { mtx sync.RWMutex // na and lastattempt na *wire.NetAddressV2 srcAddr *wire.NetAddressV2 attempts int lastattempt time.Time lastsuccess time.Time tried bool refs int // reference count of new buckets } // NetAddress returns the underlying wire.NetAddressV2 associated with the // known address. func (ka *KnownAddress) NetAddress() *wire.NetAddressV2 { ka.mtx.RLock() defer ka.mtx.RUnlock() return ka.na } // LastAttempt returns the last time the known address was attempted. func (ka *KnownAddress) LastAttempt() time.Time { ka.mtx.RLock() defer ka.mtx.RUnlock() return ka.lastattempt } // Services returns the services supported by the peer with the known address. func (ka *KnownAddress) Services() wire.ServiceFlag { ka.mtx.RLock() defer ka.mtx.RUnlock() return ka.na.Services } // The unexported methods, chance and isBad, are used from within AddrManager // where KnownAddress field access is synchronized via it's own Mutex. // chance returns the selection probability for a known address. The priority // depends upon how recently the address has been seen, how recently it was last // attempted and how often attempts to connect to it have failed. func (ka *KnownAddress) chance() float64 { now := time.Now() lastAttempt := now.Sub(ka.lastattempt) if lastAttempt < 0 { lastAttempt = 0 } c := 1.0 // Very recent attempts are less likely to be retried. if lastAttempt < 10*time.Minute { c *= 0.01 } // Failed attempts deprioritise. for i := ka.attempts; i > 0; i-- { c /= 1.5 } return c } // isBad returns true if the address in question has not been tried in the last // minute and meets one of the following criteria: // 1) It claims to be from the future // 2) It hasn't been seen in over a month // 3) It has failed at least three times and never succeeded // 4) It has failed ten times in the last week // All addresses that meet these criteria are assumed to be worthless and not // worth keeping hold of. func (ka *KnownAddress) isBad() bool { if ka.lastattempt.After(time.Now().Add(-1 * time.Minute)) { return false } // From the future? if ka.na.Timestamp.After(time.Now().Add(10 * time.Minute)) { return true } // Over a month old? if ka.na.Timestamp.Before(time.Now().Add(-1 * numMissingDays * time.Hour * 24)) { return true } // Never succeeded? if ka.lastsuccess.IsZero() && ka.attempts >= numRetries { return true } // Hasn't succeeded in too long? if !ka.lastsuccess.After(time.Now().Add(-1*minBadDays*time.Hour*24)) && ka.attempts >= maxFailures { return true } return false } ================================================ FILE: addrmgr/knownaddress_test.go ================================================ // Copyright (c) 2013-2015 The btcsuite developers // Use of this source code is governed by an ISC // license that can be found in the LICENSE file. package addrmgr_test import ( "math" "testing" "time" "github.com/btcsuite/btcd/addrmgr" "github.com/btcsuite/btcd/wire" ) func TestChance(t *testing.T) { now := time.Unix(time.Now().Unix(), 0) var tests = []struct { addr *addrmgr.KnownAddress expected float64 }{ { //Test normal case addrmgr.TstNewKnownAddress(&wire.NetAddressV2{Timestamp: now.Add(-35 * time.Second)}, 0, time.Now().Add(-30*time.Minute), time.Now(), false, 0), 1.0, }, { //Test case in which lastseen < 0 addrmgr.TstNewKnownAddress(&wire.NetAddressV2{Timestamp: now.Add(20 * time.Second)}, 0, time.Now().Add(-30*time.Minute), time.Now(), false, 0), 1.0, }, { //Test case in which lastattempt < 0 addrmgr.TstNewKnownAddress(&wire.NetAddressV2{Timestamp: now.Add(-35 * time.Second)}, 0, time.Now().Add(30*time.Minute), time.Now(), false, 0), 1.0 * .01, }, { //Test case in which lastattempt < ten minutes addrmgr.TstNewKnownAddress(&wire.NetAddressV2{Timestamp: now.Add(-35 * time.Second)}, 0, time.Now().Add(-5*time.Minute), time.Now(), false, 0), 1.0 * .01, }, { //Test case with several failed attempts. addrmgr.TstNewKnownAddress(&wire.NetAddressV2{Timestamp: now.Add(-35 * time.Second)}, 2, time.Now().Add(-30*time.Minute), time.Now(), false, 0), 1 / 1.5 / 1.5, }, } err := .0001 for i, test := range tests { chance := addrmgr.TstKnownAddressChance(test.addr) if math.Abs(test.expected-chance) >= err { t.Errorf("case %d: got %f, expected %f", i, chance, test.expected) } } } func TestIsBad(t *testing.T) { now := time.Unix(time.Now().Unix(), 0) future := now.Add(35 * time.Minute) monthOld := now.Add(-43 * time.Hour * 24) secondsOld := now.Add(-2 * time.Second) minutesOld := now.Add(-27 * time.Minute) hoursOld := now.Add(-5 * time.Hour) zeroTime := time.Time{} futureNa := &wire.NetAddressV2{Timestamp: future} minutesOldNa := &wire.NetAddressV2{Timestamp: minutesOld} monthOldNa := &wire.NetAddressV2{Timestamp: monthOld} currentNa := &wire.NetAddressV2{Timestamp: secondsOld} //Test addresses that have been tried in the last minute. if addrmgr.TstKnownAddressIsBad(addrmgr.TstNewKnownAddress(futureNa, 3, secondsOld, zeroTime, false, 0)) { t.Errorf("test case 1: addresses that have been tried in the last minute are not bad.") } if addrmgr.TstKnownAddressIsBad(addrmgr.TstNewKnownAddress(monthOldNa, 3, secondsOld, zeroTime, false, 0)) { t.Errorf("test case 2: addresses that have been tried in the last minute are not bad.") } if addrmgr.TstKnownAddressIsBad(addrmgr.TstNewKnownAddress(currentNa, 3, secondsOld, zeroTime, false, 0)) { t.Errorf("test case 3: addresses that have been tried in the last minute are not bad.") } if addrmgr.TstKnownAddressIsBad(addrmgr.TstNewKnownAddress(currentNa, 3, secondsOld, monthOld, true, 0)) { t.Errorf("test case 4: addresses that have been tried in the last minute are not bad.") } if addrmgr.TstKnownAddressIsBad(addrmgr.TstNewKnownAddress(currentNa, 2, secondsOld, secondsOld, true, 0)) { t.Errorf("test case 5: addresses that have been tried in the last minute are not bad.") } //Test address that claims to be from the future. if !addrmgr.TstKnownAddressIsBad(addrmgr.TstNewKnownAddress(futureNa, 0, minutesOld, hoursOld, true, 0)) { t.Errorf("test case 6: addresses that claim to be from the future are bad.") } //Test address that has not been seen in over a month. if !addrmgr.TstKnownAddressIsBad(addrmgr.TstNewKnownAddress(monthOldNa, 0, minutesOld, hoursOld, true, 0)) { t.Errorf("test case 7: addresses more than a month old are bad.") } //It has failed at least three times and never succeeded. if !addrmgr.TstKnownAddressIsBad(addrmgr.TstNewKnownAddress(minutesOldNa, 3, minutesOld, zeroTime, true, 0)) { t.Errorf("test case 8: addresses that have never succeeded are bad.") } //It has failed ten times in the last week if !addrmgr.TstKnownAddressIsBad(addrmgr.TstNewKnownAddress(minutesOldNa, 10, minutesOld, monthOld, true, 0)) { t.Errorf("test case 9: addresses that have not succeeded in too long are bad.") } //Test an address that should work. if addrmgr.TstKnownAddressIsBad(addrmgr.TstNewKnownAddress(minutesOldNa, 2, minutesOld, hoursOld, true, 0)) { t.Errorf("test case 10: This should be a valid address.") } } ================================================ FILE: addrmgr/log.go ================================================ // Copyright (c) 2013-2014 The btcsuite developers // Use of this source code is governed by an ISC // license that can be found in the LICENSE file. package addrmgr import ( "github.com/btcsuite/btclog" ) // log is a logger that is initialized with no output filters. This // means the package will not perform any logging by default until the caller // requests it. var log btclog.Logger // The default amount of logging is none. func init() { DisableLog() } // DisableLog disables all library log output. Logging output is disabled // by default until either UseLogger or SetLogWriter are called. func DisableLog() { log = btclog.Disabled } // UseLogger uses a specified Logger to output package logging info. // This should be used in preference to SetLogWriter if the caller is also // using btclog. func UseLogger(logger btclog.Logger) { log = logger } ================================================ FILE: addrmgr/network.go ================================================ // Copyright (c) 2013-2014 The btcsuite developers // Use of this source code is governed by an ISC // license that can be found in the LICENSE file. package addrmgr import ( "fmt" "net" "github.com/btcsuite/btcd/wire" ) var ( // rfc1918Nets specifies the IPv4 private address blocks as defined by // by RFC1918 (10.0.0.0/8, 172.16.0.0/12, and 192.168.0.0/16). rfc1918Nets = []net.IPNet{ ipNet("10.0.0.0", 8, 32), ipNet("172.16.0.0", 12, 32), ipNet("192.168.0.0", 16, 32), } // rfc2544Net specifies the IPv4 block as defined by RFC2544 // (198.18.0.0/15) rfc2544Net = ipNet("198.18.0.0", 15, 32) // rfc3849Net specifies the IPv6 documentation address block as defined // by RFC3849 (2001:DB8::/32). rfc3849Net = ipNet("2001:DB8::", 32, 128) // rfc3927Net specifies the IPv4 auto configuration address block as // defined by RFC3927 (169.254.0.0/16). rfc3927Net = ipNet("169.254.0.0", 16, 32) // rfc3964Net specifies the IPv6 to IPv4 encapsulation address block as // defined by RFC3964 (2002::/16). rfc3964Net = ipNet("2002::", 16, 128) // rfc4193Net specifies the IPv6 unique local address block as defined // by RFC4193 (FC00::/7). rfc4193Net = ipNet("FC00::", 7, 128) // rfc4380Net specifies the IPv6 teredo tunneling over UDP address block // as defined by RFC4380 (2001::/32). rfc4380Net = ipNet("2001::", 32, 128) // rfc4843Net specifies the IPv6 ORCHID address block as defined by // RFC4843 (2001:10::/28). rfc4843Net = ipNet("2001:10::", 28, 128) // rfc7343Net specifies the IPv6 ORCHIDv2 address block as defined by // RFC7343 (2001:20::/28). rfc7343Net = ipNet("2001:20::", 28, 128) // rfc4862Net specifies the IPv6 stateless address autoconfiguration // address block as defined by RFC4862 (FE80::/64). rfc4862Net = ipNet("FE80::", 64, 128) // rfc5737Net specifies the IPv4 documentation address blocks as defined // by RFC5737 (192.0.2.0/24, 198.51.100.0/24, 203.0.113.0/24) rfc5737Net = []net.IPNet{ ipNet("192.0.2.0", 24, 32), ipNet("198.51.100.0", 24, 32), ipNet("203.0.113.0", 24, 32), } // rfc6052Net specifies the IPv6 well-known prefix address block as // defined by RFC6052 (64:FF9B::/96). rfc6052Net = ipNet("64:FF9B::", 96, 128) // rfc6145Net specifies the IPv6 to IPv4 translated address range as // defined by RFC6145 (::FFFF:0:0:0/96). rfc6145Net = ipNet("::FFFF:0:0:0", 96, 128) // rfc6598Net specifies the IPv4 block as defined by RFC6598 (100.64.0.0/10) rfc6598Net = ipNet("100.64.0.0", 10, 32) // onionCatNet defines the IPv6 address block used to support Tor. // bitcoind encodes a .onion address as a 16 byte number by decoding the // address prior to the .onion (i.e. the key hash) base32 into a ten // byte number. It then stores the first 6 bytes of the address as // 0xfd, 0x87, 0xd8, 0x7e, 0xeb, 0x43. // // This is the same range used by OnionCat, which is part part of the // RFC4193 unique local IPv6 range. // // In summary the format is: // { magic 6 bytes, 10 bytes base32 decode of key hash } onionCatNet = ipNet("fd87:d87e:eb43::", 48, 128) // zero4Net defines the IPv4 address block for address staring with 0 // (0.0.0.0/8). zero4Net = ipNet("0.0.0.0", 8, 32) // heNet defines the Hurricane Electric IPv6 address block. heNet = ipNet("2001:470::", 32, 128) ) // ipNet returns a net.IPNet struct given the passed IP address string, number // of one bits to include at the start of the mask, and the total number of bits // for the mask. func ipNet(ip string, ones, bits int) net.IPNet { return net.IPNet{IP: net.ParseIP(ip), Mask: net.CIDRMask(ones, bits)} } // IsIPv4 returns whether or not the given address is an IPv4 address. func IsIPv4(na *wire.NetAddress) bool { return na.IP.To4() != nil } // IsLocal returns whether or not the given address is a local address. func IsLocal(na *wire.NetAddress) bool { return na.IP.IsLoopback() || zero4Net.Contains(na.IP) } // IsOnionCatTor returns whether or not the passed address is in the IPv6 range // used by bitcoin to support Tor (fd87:d87e:eb43::/48). Note that this range // is the same range used by OnionCat, which is part of the RFC4193 unique local // IPv6 range. func IsOnionCatTor(na *wire.NetAddress) bool { return onionCatNet.Contains(na.IP) } // IsRFC1918 returns whether or not the passed address is part of the IPv4 // private network address space as defined by RFC1918 (10.0.0.0/8, // 172.16.0.0/12, or 192.168.0.0/16). func IsRFC1918(na *wire.NetAddress) bool { for _, rfc := range rfc1918Nets { if rfc.Contains(na.IP) { return true } } return false } // IsRFC2544 returns whether or not the passed address is part of the IPv4 // address space as defined by RFC2544 (198.18.0.0/15) func IsRFC2544(na *wire.NetAddress) bool { return rfc2544Net.Contains(na.IP) } // IsRFC3849 returns whether or not the passed address is part of the IPv6 // documentation range as defined by RFC3849 (2001:DB8::/32). func IsRFC3849(na *wire.NetAddress) bool { return rfc3849Net.Contains(na.IP) } // IsRFC3927 returns whether or not the passed address is part of the IPv4 // autoconfiguration range as defined by RFC3927 (169.254.0.0/16). func IsRFC3927(na *wire.NetAddress) bool { return rfc3927Net.Contains(na.IP) } // IsRFC3964 returns whether or not the passed address is part of the IPv6 to // IPv4 encapsulation range as defined by RFC3964 (2002::/16). func IsRFC3964(na *wire.NetAddress) bool { return rfc3964Net.Contains(na.IP) } // IsRFC4193 returns whether or not the passed address is part of the IPv6 // unique local range as defined by RFC4193 (FC00::/7). func IsRFC4193(na *wire.NetAddress) bool { return rfc4193Net.Contains(na.IP) } // IsRFC4380 returns whether or not the passed address is part of the IPv6 // teredo tunneling over UDP range as defined by RFC4380 (2001::/32). func IsRFC4380(na *wire.NetAddress) bool { return rfc4380Net.Contains(na.IP) } // IsRFC4843 returns whether or not the passed address is part of the IPv6 // ORCHID range as defined by RFC4843 (2001:10::/28). func IsRFC4843(na *wire.NetAddress) bool { return rfc4843Net.Contains(na.IP) } // IsRFC7343 returns whether or not the passed address is part of the IPv6 // ORCHIDv2 range as defined by RFC7343 (2001:20::/28). func IsRFC7343(na *wire.NetAddress) bool { return rfc7343Net.Contains(na.IP) } // IsRFC4862 returns whether or not the passed address is part of the IPv6 // stateless address autoconfiguration range as defined by RFC4862 (FE80::/64). func IsRFC4862(na *wire.NetAddress) bool { return rfc4862Net.Contains(na.IP) } // IsRFC5737 returns whether or not the passed address is part of the IPv4 // documentation address space as defined by RFC5737 (192.0.2.0/24, // 198.51.100.0/24, 203.0.113.0/24) func IsRFC5737(na *wire.NetAddress) bool { for _, rfc := range rfc5737Net { if rfc.Contains(na.IP) { return true } } return false } // IsRFC6052 returns whether or not the passed address is part of the IPv6 // well-known prefix range as defined by RFC6052 (64:FF9B::/96). func IsRFC6052(na *wire.NetAddress) bool { return rfc6052Net.Contains(na.IP) } // IsRFC6145 returns whether or not the passed address is part of the IPv6 to // IPv4 translated address range as defined by RFC6145 (::FFFF:0:0:0/96). func IsRFC6145(na *wire.NetAddress) bool { return rfc6145Net.Contains(na.IP) } // IsRFC6598 returns whether or not the passed address is part of the IPv4 // shared address space specified by RFC6598 (100.64.0.0/10) func IsRFC6598(na *wire.NetAddress) bool { return rfc6598Net.Contains(na.IP) } // IsValid returns whether or not the passed address is valid. The address is // considered invalid under the following circumstances: // IPv4: It is either a zero or all bits set address. // IPv6: It is either a zero or RFC3849 documentation address. func IsValid(na *wire.NetAddress) bool { // IsUnspecified returns if address is 0, so only all bits set, and // RFC3849 need to be explicitly checked. return na.IP != nil && !(na.IP.IsUnspecified() || na.IP.Equal(net.IPv4bcast)) } // IsRoutable returns whether or not the passed address is routable over // the public internet. This is true as long as the address is valid and is not // in any reserved ranges. func IsRoutable(na *wire.NetAddressV2) bool { if na.IsTorV3() { // na is a torv3 address, return true. return true } // Else na can be represented as a legacy NetAddress since i2p and // cjdns are unsupported. lna := na.ToLegacy() return IsValid(lna) && !(IsRFC1918(lna) || IsRFC2544(lna) || IsRFC3927(lna) || IsRFC4862(lna) || IsRFC3849(lna) || IsRFC4843(lna) || IsRFC7343(lna) || IsRFC5737(lna) || IsRFC6598(lna) || IsLocal(lna) || (IsRFC4193(lna) && !IsOnionCatTor(lna))) } // GroupKey returns a string representing the network group an address is part // of. This is the /16 for IPv4, the /32 (/36 for he.net) for IPv6, the string // "local" for a local address, the string "tor:key" where key is the /4 of the // onion address for Tor address, and the string "unroutable" for an unroutable // address. func GroupKey(na *wire.NetAddressV2) string { if na.IsTorV3() { // na is a torv3 address. Use the same network group keying as // for torv2. return fmt.Sprintf("tor:%d", na.TorV3Key()&((1<<4)-1)) } lna := na.ToLegacy() if IsLocal(lna) { return "local" } if !IsRoutable(na) { return "unroutable" } if IsIPv4(lna) { return lna.IP.Mask(net.CIDRMask(16, 32)).String() } if IsRFC6145(lna) || IsRFC6052(lna) { // last four bytes are the ip address ip := lna.IP[12:16] return ip.Mask(net.CIDRMask(16, 32)).String() } if IsRFC3964(lna) { ip := lna.IP[2:6] return ip.Mask(net.CIDRMask(16, 32)).String() } if IsRFC4380(lna) { // teredo tunnels have the last 4 bytes as the v4 address XOR // 0xff. ip := net.IP(make([]byte, 4)) for i, byte := range lna.IP[12:16] { ip[i] = byte ^ 0xff } return ip.Mask(net.CIDRMask(16, 32)).String() } if IsOnionCatTor(lna) { // group is keyed off the first 4 bits of the actual onion key. return fmt.Sprintf("tor:%d", lna.IP[6]&((1<<4)-1)) } // OK, so now we know ourselves to be a IPv6 address. // bitcoind uses /32 for everything, except for Hurricane Electric's // (he.net) IP range, which it uses /36 for. bits := 32 if heNet.Contains(lna.IP) { bits = 36 } return lna.IP.Mask(net.CIDRMask(bits, 128)).String() } ================================================ FILE: addrmgr/network_test.go ================================================ // Copyright (c) 2013-2014 The btcsuite developers // Use of this source code is governed by an ISC // license that can be found in the LICENSE file. package addrmgr_test import ( "net" "testing" "time" "github.com/btcsuite/btcd/addrmgr" "github.com/btcsuite/btcd/wire" ) // TestIPTypes ensures the various functions which determine the type of an IP // address based on RFCs work as intended. func TestIPTypes(t *testing.T) { type ipTest struct { in wire.NetAddress rfc1918 bool rfc2544 bool rfc3849 bool rfc3927 bool rfc3964 bool rfc4193 bool rfc4380 bool rfc4843 bool rfc4862 bool rfc5737 bool rfc6052 bool rfc6145 bool rfc6598 bool rfc7343 bool local bool valid bool routable bool } newIPTest := func(ip string, rfc1918, rfc2544, rfc3849, rfc3927, rfc3964, rfc4193, rfc4380, rfc4843, rfc4862, rfc5737, rfc6052, rfc6145, rfc6598, rfc7343, local, valid, routable bool) ipTest { nip := net.ParseIP(ip) na := *wire.NewNetAddressIPPort(nip, 8333, wire.SFNodeNetwork) test := ipTest{na, rfc1918, rfc2544, rfc3849, rfc3927, rfc3964, rfc4193, rfc4380, rfc4843, rfc4862, rfc5737, rfc6052, rfc6145, rfc6598, rfc7343, local, valid, routable} return test } tests := []ipTest{ newIPTest("10.255.255.255", true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, true, false), newIPTest("192.168.0.1", true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, true, false), newIPTest("172.31.255.1", true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, true, false), newIPTest("172.32.1.1", false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, true, true), newIPTest("169.254.250.120", false, false, false, true, false, false, false, false, false, false, false, false, false, false, false, true, false), newIPTest("0.0.0.0", false, false, false, false, false, false, false, false, false, false, false, false, false, false, true, false, false), newIPTest("255.255.255.255", false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false), newIPTest("127.0.0.1", false, false, false, false, false, false, false, false, false, false, false, false, false, false, true, true, false), newIPTest("fd00:dead::1", false, false, false, false, false, true, false, false, false, false, false, false, false, false, false, true, false), newIPTest("2001::1", false, false, false, false, false, false, true, false, false, false, false, false, false, false, false, true, true), newIPTest("2001:10:abcd::1:1", false, false, false, false, false, false, false, true, false, false, false, false, false, false, false, true, false), newIPTest("2001:20:abcd::1:1", false, false, false, false, false, false, false, false, false, false, false, false, false, true, false, true, false), newIPTest("fe80::1", false, false, false, false, false, false, false, false, true, false, false, false, false, false, false, true, false), newIPTest("fe80:1::1", false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, true, true), newIPTest("64:ff9b::1", false, false, false, false, false, false, false, false, false, false, true, false, false, false, false, true, true), newIPTest("::ffff:abcd:ef12:1", false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, true, true), newIPTest("::1", false, false, false, false, false, false, false, false, false, false, false, false, false, false, true, true, false), newIPTest("198.18.0.1", false, true, false, false, false, false, false, false, false, false, false, false, false, false, false, true, false), newIPTest("100.127.255.1", false, false, false, false, false, false, false, false, false, false, false, false, true, false, false, true, false), newIPTest("203.0.113.1", false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, true, false), } t.Logf("Running %d tests", len(tests)) for _, test := range tests { if rv := addrmgr.IsRFC1918(&test.in); rv != test.rfc1918 { t.Errorf("IsRFC1918 %s\n got: %v want: %v", test.in.IP, rv, test.rfc1918) } if rv := addrmgr.IsRFC3849(&test.in); rv != test.rfc3849 { t.Errorf("IsRFC3849 %s\n got: %v want: %v", test.in.IP, rv, test.rfc3849) } if rv := addrmgr.IsRFC3927(&test.in); rv != test.rfc3927 { t.Errorf("IsRFC3927 %s\n got: %v want: %v", test.in.IP, rv, test.rfc3927) } if rv := addrmgr.IsRFC3964(&test.in); rv != test.rfc3964 { t.Errorf("IsRFC3964 %s\n got: %v want: %v", test.in.IP, rv, test.rfc3964) } if rv := addrmgr.IsRFC4193(&test.in); rv != test.rfc4193 { t.Errorf("IsRFC4193 %s\n got: %v want: %v", test.in.IP, rv, test.rfc4193) } if rv := addrmgr.IsRFC4380(&test.in); rv != test.rfc4380 { t.Errorf("IsRFC4380 %s\n got: %v want: %v", test.in.IP, rv, test.rfc4380) } if rv := addrmgr.IsRFC4843(&test.in); rv != test.rfc4843 { t.Errorf("IsRFC4843 %s\n got: %v want: %v", test.in.IP, rv, test.rfc4843) } if rv := addrmgr.IsRFC4862(&test.in); rv != test.rfc4862 { t.Errorf("IsRFC4862 %s\n got: %v want: %v", test.in.IP, rv, test.rfc4862) } if rv := addrmgr.IsRFC6052(&test.in); rv != test.rfc6052 { t.Errorf("isRFC6052 %s\n got: %v want: %v", test.in.IP, rv, test.rfc6052) } if rv := addrmgr.IsRFC6145(&test.in); rv != test.rfc6145 { t.Errorf("IsRFC6145 %s\n got: %v want: %v", test.in.IP, rv, test.rfc6145) } if rv := addrmgr.IsRFC7343(&test.in); rv != test.rfc7343 { t.Errorf("IsRFC7343 %s\n got: %v want: %v", test.in.IP, rv, test.rfc7343) } if rv := addrmgr.IsLocal(&test.in); rv != test.local { t.Errorf("IsLocal %s\n got: %v want: %v", test.in.IP, rv, test.local) } if rv := addrmgr.IsValid(&test.in); rv != test.valid { t.Errorf("IsValid %s\n got: %v want: %v", test.in.IP, rv, test.valid) } currentNa := wire.NetAddressV2FromBytes( time.Now(), test.in.Services, test.in.IP, test.in.Port, ) if rv := addrmgr.IsRoutable(currentNa); rv != test.routable { t.Errorf("IsRoutable %s\n got: %v want: %v", test.in.IP, rv, test.routable) } } } // TestGroupKey tests the GroupKey function to ensure it properly groups various // IP addresses. func TestGroupKey(t *testing.T) { tests := []struct { name string ip string expected string }{ // Local addresses. {name: "ipv4 localhost", ip: "127.0.0.1", expected: "local"}, {name: "ipv6 localhost", ip: "::1", expected: "local"}, {name: "ipv4 zero", ip: "0.0.0.0", expected: "local"}, {name: "ipv4 first octet zero", ip: "0.1.2.3", expected: "local"}, // Unroutable addresses. {name: "ipv4 invalid bcast", ip: "255.255.255.255", expected: "unroutable"}, {name: "ipv4 rfc1918 10/8", ip: "10.1.2.3", expected: "unroutable"}, {name: "ipv4 rfc1918 172.16/12", ip: "172.16.1.2", expected: "unroutable"}, {name: "ipv4 rfc1918 192.168/16", ip: "192.168.1.2", expected: "unroutable"}, {name: "ipv6 rfc3849 2001:db8::/32", ip: "2001:db8::1234", expected: "unroutable"}, {name: "ipv4 rfc3927 169.254/16", ip: "169.254.1.2", expected: "unroutable"}, {name: "ipv6 rfc4193 fc00::/7", ip: "fc00::1234", expected: "unroutable"}, {name: "ipv6 rfc4843 2001:10::/28", ip: "2001:10::1234", expected: "unroutable"}, {name: "ipv6 rfc7343 2001:20::/28", ip: "2001:20::1234", expected: "unroutable"}, {name: "ipv6 rfc4862 fe80::/64", ip: "fe80::1234", expected: "unroutable"}, // IPv4 normal. {name: "ipv4 normal class a", ip: "12.1.2.3", expected: "12.1.0.0"}, {name: "ipv4 normal class b", ip: "173.1.2.3", expected: "173.1.0.0"}, {name: "ipv4 normal class c", ip: "196.1.2.3", expected: "196.1.0.0"}, // IPv6/IPv4 translations. {name: "ipv6 rfc3964 with ipv4 encap", ip: "2002:0c01:0203::", expected: "12.1.0.0"}, {name: "ipv6 rfc4380 toredo ipv4", ip: "2001:0:1234::f3fe:fdfc", expected: "12.1.0.0"}, {name: "ipv6 rfc6052 well-known prefix with ipv4", ip: "64:ff9b::0c01:0203", expected: "12.1.0.0"}, {name: "ipv6 rfc6145 translated ipv4", ip: "::ffff:0:0c01:0203", expected: "12.1.0.0"}, // Tor. {name: "ipv6 tor onioncat", ip: "fd87:d87e:eb43:1234::5678", expected: "tor:2"}, {name: "ipv6 tor onioncat 2", ip: "fd87:d87e:eb43:1245::6789", expected: "tor:2"}, {name: "ipv6 tor onioncat 3", ip: "fd87:d87e:eb43:1345::6789", expected: "tor:3"}, // IPv6 normal. {name: "ipv6 normal", ip: "2602:100::1", expected: "2602:100::"}, {name: "ipv6 normal 2", ip: "2602:0100::1234", expected: "2602:100::"}, {name: "ipv6 hurricane electric", ip: "2001:470:1f10:a1::2", expected: "2001:470:1000::"}, {name: "ipv6 hurricane electric 2", ip: "2001:0470:1f10:a1::2", expected: "2001:470:1000::"}, } for i, test := range tests { nip := net.ParseIP(test.ip) na := wire.NetAddressV2FromBytes( time.Now(), wire.SFNodeNetwork, nip, 8333, ) if key := addrmgr.GroupKey(na); key != test.expected { t.Errorf("TestGroupKey #%d (%s): unexpected group key "+ "- got '%s', want '%s'", i, test.name, key, test.expected) } } } ================================================ FILE: addrmgr/test_coverage.txt ================================================ github.com/conformal/btcd/addrmgr/network.go GroupKey 100.00% (23/23) github.com/conformal/btcd/addrmgr/addrmanager.go AddrManager.reset 100.00% (6/6) github.com/conformal/btcd/addrmgr/network.go IsRFC5737 100.00% (4/4) github.com/conformal/btcd/addrmgr/network.go IsRFC1918 100.00% (4/4) github.com/conformal/btcd/addrmgr/addrmanager.go New 100.00% (3/3) github.com/conformal/btcd/addrmgr/addrmanager.go NetAddressKey 100.00% (2/2) github.com/conformal/btcd/addrmgr/network.go IsRFC4862 100.00% (1/1) github.com/conformal/btcd/addrmgr/addrmanager.go AddrManager.numAddresses 100.00% (1/1) github.com/conformal/btcd/addrmgr/log.go init 100.00% (1/1) github.com/conformal/btcd/addrmgr/log.go DisableLog 100.00% (1/1) github.com/conformal/btcd/addrmgr/network.go ipNet 100.00% (1/1) github.com/conformal/btcd/addrmgr/network.go IsIPv4 100.00% (1/1) github.com/conformal/btcd/addrmgr/network.go IsLocal 100.00% (1/1) github.com/conformal/btcd/addrmgr/network.go IsOnionCatTor 100.00% (1/1) github.com/conformal/btcd/addrmgr/network.go IsRFC2544 100.00% (1/1) github.com/conformal/btcd/addrmgr/network.go IsRFC3849 100.00% (1/1) github.com/conformal/btcd/addrmgr/network.go IsRFC3927 100.00% (1/1) github.com/conformal/btcd/addrmgr/network.go IsRFC3964 100.00% (1/1) github.com/conformal/btcd/addrmgr/network.go IsRFC4193 100.00% (1/1) github.com/conformal/btcd/addrmgr/network.go IsRFC4380 100.00% (1/1) github.com/conformal/btcd/addrmgr/network.go IsRFC4843 100.00% (1/1) github.com/conformal/btcd/addrmgr/network.go IsRFC6052 100.00% (1/1) github.com/conformal/btcd/addrmgr/network.go IsRFC6145 100.00% (1/1) github.com/conformal/btcd/addrmgr/network.go IsRFC6598 100.00% (1/1) github.com/conformal/btcd/addrmgr/network.go IsValid 100.00% (1/1) github.com/conformal/btcd/addrmgr/network.go IsRoutable 100.00% (1/1) github.com/conformal/btcd/addrmgr/addrmanager.go AddrManager.GetBestLocalAddress 94.74% (18/19) github.com/conformal/btcd/addrmgr/addrmanager.go AddrManager.AddLocalAddress 90.91% (10/11) github.com/conformal/btcd/addrmgr/addrmanager.go getReachabilityFrom 51.52% (17/33) github.com/conformal/btcd/addrmgr/addrmanager.go ipString 50.00% (2/4) github.com/conformal/btcd/addrmgr/addrmanager.go AddrManager.GetAddress 9.30% (4/43) github.com/conformal/btcd/addrmgr/addrmanager.go AddrManager.deserializePeers 0.00% (0/50) github.com/conformal/btcd/addrmgr/addrmanager.go AddrManager.Good 0.00% (0/44) github.com/conformal/btcd/addrmgr/addrmanager.go AddrManager.savePeers 0.00% (0/39) github.com/conformal/btcd/addrmgr/addrmanager.go AddrManager.updateAddress 0.00% (0/30) github.com/conformal/btcd/addrmgr/addrmanager.go AddrManager.expireNew 0.00% (0/22) github.com/conformal/btcd/addrmgr/addrmanager.go AddrManager.AddressCache 0.00% (0/16) github.com/conformal/btcd/addrmgr/addrmanager.go AddrManager.HostToNetAddress 0.00% (0/15) github.com/conformal/btcd/addrmgr/addrmanager.go AddrManager.getNewBucket 0.00% (0/15) github.com/conformal/btcd/addrmgr/addrmanager.go AddrManager.AddAddressByIP 0.00% (0/14) github.com/conformal/btcd/addrmgr/addrmanager.go AddrManager.getTriedBucket 0.00% (0/14) github.com/conformal/btcd/addrmgr/knownaddress.go knownAddress.chance 0.00% (0/13) github.com/conformal/btcd/addrmgr/addrmanager.go AddrManager.loadPeers 0.00% (0/11) github.com/conformal/btcd/addrmgr/knownaddress.go knownAddress.isBad 0.00% (0/11) github.com/conformal/btcd/addrmgr/addrmanager.go AddrManager.Connected 0.00% (0/10) github.com/conformal/btcd/addrmgr/addrmanager.go AddrManager.addressHandler 0.00% (0/9) github.com/conformal/btcd/addrmgr/addrmanager.go AddrManager.pickTried 0.00% (0/8) github.com/conformal/btcd/addrmgr/addrmanager.go AddrManager.DeserializeNetAddress 0.00% (0/7) github.com/conformal/btcd/addrmgr/addrmanager.go AddrManager.Stop 0.00% (0/7) github.com/conformal/btcd/addrmgr/addrmanager.go AddrManager.Attempt 0.00% (0/7) github.com/conformal/btcd/addrmgr/addrmanager.go AddrManager.Start 0.00% (0/6) github.com/conformal/btcd/addrmgr/addrmanager.go AddrManager.AddAddresses 0.00% (0/4) github.com/conformal/btcd/addrmgr/addrmanager.go AddrManager.NeedMoreAddresses 0.00% (0/3) github.com/conformal/btcd/addrmgr/addrmanager.go AddrManager.NumAddresses 0.00% (0/3) github.com/conformal/btcd/addrmgr/addrmanager.go AddrManager.AddAddress 0.00% (0/3) github.com/conformal/btcd/addrmgr/knownaddress.go knownAddress.LastAttempt 0.00% (0/1) github.com/conformal/btcd/addrmgr/knownaddress.go knownAddress.NetAddress 0.00% (0/1) github.com/conformal/btcd/addrmgr/addrmanager.go AddrManager.find 0.00% (0/1) github.com/conformal/btcd/addrmgr/log.go UseLogger 0.00% (0/1) github.com/conformal/btcd/addrmgr --------------------------------- 21.04% (113/537) ================================================ FILE: blockchain/README.md ================================================ blockchain ========== [![Build Status](https://github.com/btcsuite/btcd/workflows/Build%20and%20Test/badge.svg)](https://github.com/btcsuite/btcd/actions) [![ISC License](http://img.shields.io/badge/license-ISC-blue.svg)](http://copyfree.org) [![GoDoc](https://img.shields.io/badge/godoc-reference-blue.svg)](https://pkg.go.dev/github.com/btcsuite/btcd/blockchain) Package blockchain implements bitcoin block handling and chain selection rules. The test coverage is currently only around 60%, but will be increasing over time. See `test_coverage.txt` for the gocov coverage report. Alternatively, if you are running a POSIX OS, you can run the `cov_report.sh` script for a real-time report. Package blockchain is licensed under the liberal ISC license. There is an associated blog post about the release of this package [here](https://blog.conformal.com/btcchain-the-bitcoin-chain-package-from-bctd/). This package has intentionally been designed so it can be used as a standalone package for any projects needing to handle processing of blocks into the bitcoin block chain. ## Installation and Updating ```bash $ go get -u github.com/btcsuite/btcd/blockchain ``` ## Bitcoin 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 - Save the most recent orphan blocks for a limited time in case their parent blocks become available - Stop processing if the block is an orphan as the rest of the processing depends on the block's position within the block chain - 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 ## Examples * [ProcessBlock Example](https://pkg.go.dev/github.com/btcsuite/btcd/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. * [CompactToBig Example](https://pkg.go.dev/github.com/btcsuite/btcd/blockchain#example-CompactToBig) Demonstrates how to convert the compact "bits" in a block header which represent the target difficulty to a big integer and display it using the typical hex notation. * [BigToCompact Example](https://pkg.go.dev/github.com/btcsuite/btcd/blockchain#example-BigToCompact) Demonstrates how to convert a target difficulty into the compact "bits" in a block header which represent that target difficulty. ## GPG Verification Key All official release tags are signed by Conformal so users can ensure the code has not been tampered with and is coming from the btcsuite developers. To verify the signature perform the following: - Download the public key from the Conformal website at https://opensource.conformal.com/GIT-GPG-KEY-conformal.txt - Import the public key into your GPG keyring: ```bash gpg --import GIT-GPG-KEY-conformal.txt ``` - Verify the release tag with the following command where `TAG_NAME` is a placeholder for the specific tag: ```bash git tag -v TAG_NAME ``` ## License Package blockchain is licensed under the [copyfree](http://copyfree.org) ISC License. ================================================ FILE: blockchain/accept.go ================================================ // Copyright (c) 2013-2017 The btcsuite developers // Use of this source code is governed by an ISC // license that can be found in the LICENSE file. package blockchain import ( "fmt" "github.com/btcsuite/btcd/btcutil" "github.com/btcsuite/btcd/database" ) // maybeAcceptBlock potentially accepts a block into the block chain and, if // accepted, returns whether or not it is on the main chain. It performs // several validation checks which depend on its position within the block chain // before adding it. The block is expected to have already gone through // ProcessBlock before calling this function with it. // // The flags are also passed to checkBlockContext and connectBestChain. See // their documentation for how the flags modify their behavior. // // This function MUST be called with the chain state lock held (for writes). func (b *BlockChain) maybeAcceptBlock(block *btcutil.Block, flags BehaviorFlags) (bool, error) { // The height of this block is one more than the referenced previous // block. prevHash := &block.MsgBlock().Header.PrevBlock prevNode := b.index.LookupNode(prevHash) if prevNode == nil { str := fmt.Sprintf("previous block %s is unknown", prevHash) return false, ruleError(ErrPreviousBlockUnknown, str) } else if b.index.NodeStatus(prevNode).KnownInvalid() { str := fmt.Sprintf("previous block %s is known to be invalid", prevHash) return false, ruleError(ErrInvalidAncestorBlock, str) } blockHeight := prevNode.height + 1 block.SetHeight(blockHeight) // The block must pass all of the validation rules which depend on the // position of the block within the block chain. err := b.checkBlockContext(block, prevNode, flags) if err != nil { return false, err } // Insert the block into the database if it's not already there. Even // though it is possible the block will ultimately fail to connect, it // has already passed all proof-of-work and validity tests which means // it would be prohibitively expensive for an attacker to fill up the // disk with a bunch of blocks that fail to connect. This is necessary // since it allows block download to be decoupled from the much more // expensive connection logic. It also has some other nice properties // such as making blocks that never become part of the main chain or // blocks that fail to connect available for further analysis. err = b.db.Update(func(dbTx database.Tx) error { return dbStoreBlock(dbTx, block) }) if err != nil { return false, err } // Create a new block node for the block and add it to the node index. Even // if the block ultimately gets connected to the main chain, it starts out // on a side chain. blockHeader := &block.MsgBlock().Header newNode := newBlockNode(blockHeader, prevNode) newNode.status = statusDataStored b.index.AddNode(newNode) err = b.index.flushToDB() if err != nil { return false, err } // Connect the passed block to the chain while respecting proper chain // selection according to the chain with the most proof of work. This // also handles validation of the transaction scripts. isMainChain, err := b.connectBestChain(newNode, block, flags) if err != nil { return false, err } // Notify the caller that the new block was accepted into the block // chain. The caller would typically want to react by relaying the // inventory to other peers. func() { b.chainLock.Unlock() defer b.chainLock.Lock() b.sendNotification(NTBlockAccepted, block) }() return isMainChain, nil } ================================================ FILE: blockchain/bench_test.go ================================================ // Copyright (c) 2015 The btcsuite developers // Use of this source code is governed by an ISC // license that can be found in the LICENSE file. package blockchain import ( "testing" "github.com/btcsuite/btcd/btcutil" "github.com/btcsuite/btcd/wire" ) // BenchmarkIsCoinBase performs a simple benchmark against the IsCoinBase // function. func BenchmarkIsCoinBase(b *testing.B) { tx, _ := btcutil.NewBlock(&Block100000).Tx(1) b.ResetTimer() for i := 0; i < b.N; i++ { IsCoinBase(tx) } } // BenchmarkIsCoinBaseTx performs a simple benchmark against the IsCoinBaseTx // function. func BenchmarkIsCoinBaseTx(b *testing.B) { tx := Block100000.Transactions[1] b.ResetTimer() for i := 0; i < b.N; i++ { IsCoinBaseTx(tx) } } func BenchmarkUtxoFetchMap(b *testing.B) { block := Block100000 transactions := block.Transactions b.ResetTimer() for i := 0; i < b.N; i++ { needed := make(map[wire.OutPoint]struct{}, len(transactions)) for _, tx := range transactions[1:] { for _, txIn := range tx.TxIn { needed[txIn.PreviousOutPoint] = struct{}{} } } } } func BenchmarkUtxoFetchSlices(b *testing.B) { block := Block100000 transactions := block.Transactions b.ResetTimer() for i := 0; i < b.N; i++ { needed := make([]wire.OutPoint, 0, len(transactions)) for _, tx := range transactions[1:] { for _, txIn := range tx.TxIn { needed = append(needed, txIn.PreviousOutPoint) } } } } func BenchmarkAncestor(b *testing.B) { height := 1 << 19 blockNodes := chainedNodes(nil, height) b.ResetTimer() for i := 0; i < b.N; i++ { blockNodes[len(blockNodes)-1].Ancestor(0) for j := 0; j <= 19; j++ { blockNodes[len(blockNodes)-1].Ancestor(1 << j) } } } ================================================ FILE: blockchain/blockindex.go ================================================ // Copyright (c) 2015-2017 The btcsuite developers // Use of this source code is governed by an ISC // license that can be found in the LICENSE file. package blockchain import ( "math/big" "sort" "sync" "time" "github.com/btcsuite/btcd/chaincfg" "github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/btcsuite/btcd/database" "github.com/btcsuite/btcd/wire" ) // blockStatus is a bit field representing the validation state of the block. type blockStatus byte const ( // statusDataStored indicates that the block's payload is stored on disk. statusDataStored blockStatus = 1 << iota // statusValid indicates that the block has been fully validated. statusValid // statusValidateFailed indicates that the block has failed validation. statusValidateFailed // statusInvalidAncestor indicates that one of the block's ancestors has // has failed validation, thus the block is also invalid. statusInvalidAncestor // statusNone indicates that the block has no validation state flags set. // // NOTE: This must be defined last in order to avoid influencing iota. statusNone blockStatus = 0 ) // HaveData returns whether the full block data is stored in the database. This // will return false for a block node where only the header is downloaded or // kept. func (status blockStatus) HaveData() bool { return status&statusDataStored != 0 } // KnownValid returns whether the block is known to be valid. This will return // false for a valid block that has not been fully validated yet. func (status blockStatus) KnownValid() bool { return status&statusValid != 0 } // KnownInvalid returns whether the block is known to be invalid. This may be // because the block itself failed validation or any of its ancestors is // invalid. This will return false for invalid blocks that have not been proven // invalid yet. func (status blockStatus) KnownInvalid() bool { return status&(statusValidateFailed|statusInvalidAncestor) != 0 } // blockNode represents a block within the block chain and is primarily used to // aid in selecting the best chain to be the main chain. The main chain is // stored into the block database. type blockNode struct { // NOTE: Additions, deletions, or modifications to the order of the // definitions in this struct should not be changed without considering // how it affects alignment on 64-bit platforms. The current order is // specifically crafted to result in minimal padding. There will be // hundreds of thousands of these in memory, so a few extra bytes of // padding adds up. // parent is the parent block for this node. parent *blockNode // ancestor is a block that is more than one block back from this node. ancestor *blockNode // hash is the double sha 256 of the block. hash chainhash.Hash // workSum is the total amount of work in the chain up to and including // this node. workSum *big.Int // height is the position in the block chain. height int32 // Some fields from block headers to aid in best chain selection and // reconstructing headers from memory. These must be treated as // immutable and are intentionally ordered to avoid padding on 64-bit // platforms. version int32 bits uint32 nonce uint32 timestamp int64 merkleRoot chainhash.Hash // status is a bitfield representing the validation state of the block. The // status field, unlike the other fields, may be written to and so should // only be accessed using the concurrent-safe NodeStatus method on // blockIndex once the node has been added to the global index. status blockStatus } // initBlockNode initializes a block node from the given header and parent node, // calculating the height and workSum from the respective fields on the parent. // This function is NOT safe for concurrent access. It must only be called when // initially creating a node. func initBlockNode(node *blockNode, blockHeader *wire.BlockHeader, parent *blockNode) { *node = blockNode{ hash: blockHeader.BlockHash(), workSum: CalcWork(blockHeader.Bits), version: blockHeader.Version, bits: blockHeader.Bits, nonce: blockHeader.Nonce, timestamp: blockHeader.Timestamp.Unix(), merkleRoot: blockHeader.MerkleRoot, } if parent != nil { node.parent = parent node.height = parent.height + 1 node.workSum = node.workSum.Add(parent.workSum, node.workSum) node.buildAncestor() } } // newBlockNode returns a new block node for the given block header and parent // node, calculating the height and workSum from the respective fields on the // parent. This function is NOT safe for concurrent access. func newBlockNode(blockHeader *wire.BlockHeader, parent *blockNode) *blockNode { var node blockNode initBlockNode(&node, blockHeader, parent) return &node } // Equals compares all the fields of the block node except for the parent and // ancestor and returns true if they're equal. func (node *blockNode) Equals(other *blockNode) bool { return node.hash == other.hash && node.workSum.Cmp(other.workSum) == 0 && node.height == other.height && node.version == other.version && node.bits == other.bits && node.nonce == other.nonce && node.timestamp == other.timestamp && node.merkleRoot == other.merkleRoot && node.status == other.status } // Header constructs a block header from the node and returns it. // // This function is safe for concurrent access. func (node *blockNode) Header() wire.BlockHeader { // No lock is needed because all accessed fields are immutable. prevHash := &zeroHash if node.parent != nil { prevHash = &node.parent.hash } return wire.BlockHeader{ Version: node.version, PrevBlock: *prevHash, MerkleRoot: node.merkleRoot, Timestamp: time.Unix(node.timestamp, 0), Bits: node.bits, Nonce: node.nonce, } } // invertLowestOne turns the lowest 1 bit in the binary representation of a number into a 0. func invertLowestOne(n int32) int32 { return n & (n - 1) } // getAncestorHeight returns a suitable ancestor for the node at the given height. func getAncestorHeight(height int32) int32 { // We pop off two 1 bits of the height. // This results in a maximum of 330 steps to go back to an ancestor // from height 1<<29. return invertLowestOne(invertLowestOne(height)) } // buildAncestor sets an ancestor for the given blocknode. func (node *blockNode) buildAncestor() { if node.parent != nil { node.ancestor = node.parent.Ancestor(getAncestorHeight(node.height)) } } // Ancestor returns the ancestor block node at the provided height by following // the chain backwards from this node. The returned block will be nil when a // height is requested that is after the height of the passed node or is less // than zero. // // This function is safe for concurrent access. func (node *blockNode) Ancestor(height int32) *blockNode { if height < 0 || height > node.height { return nil } // Traverse back until we find the desired node. n := node for n != nil && n.height != height { // If there's an ancestor available, use it. Otherwise, just // follow the parent. if n.ancestor != nil { // Calculate the height for this ancestor and // check if we can take the ancestor skip. if getAncestorHeight(n.height) >= height { n = n.ancestor continue } } // We couldn't take the ancestor skip so traverse back to the parent. n = n.parent } return n } // Height returns the blockNode's height in the chain. // // NOTE: Part of the HeaderCtx interface. func (node *blockNode) Height() int32 { return node.height } // Bits returns the blockNode's nBits. // // NOTE: Part of the HeaderCtx interface. func (node *blockNode) Bits() uint32 { return node.bits } // Timestamp returns the blockNode's timestamp. // // NOTE: Part of the HeaderCtx interface. func (node *blockNode) Timestamp() int64 { return node.timestamp } // Parent returns the blockNode's parent. // // NOTE: Part of the HeaderCtx interface. func (node *blockNode) Parent() HeaderCtx { if node.parent == nil { // This is required since node.parent is a *blockNode and if we // do not explicitly return nil here, the caller may fail when // nil-checking this. return nil } return node.parent } // RelativeAncestorCtx returns the blockNode's ancestor that is distance blocks // before it in the chain. This is equivalent to the RelativeAncestor function // below except that the return type is different. // // This function is safe for concurrent access. // // NOTE: Part of the HeaderCtx interface. func (node *blockNode) RelativeAncestorCtx(distance int32) HeaderCtx { ancestor := node.RelativeAncestor(distance) if ancestor == nil { // This is required since RelativeAncestor returns a *blockNode // and if we do not explicitly return nil here, the caller may // fail when nil-checking this. return nil } return ancestor } // IsAncestor returns if the other node is an ancestor of this block node. func (node *blockNode) IsAncestor(otherNode *blockNode) bool { // Return early as false if the otherNode is nil. if otherNode == nil { return false } ancestor := node.Ancestor(otherNode.height) if ancestor == nil { return false } // If the otherNode has the same height as me, then the returned // ancestor will be me. Return false since I'm not an ancestor of me. if node.height == ancestor.height { return false } // Return true if the fetched ancestor is other node. return ancestor.Equals(otherNode) } // RelativeAncestor returns the ancestor block node a relative 'distance' blocks // before this node. This is equivalent to calling Ancestor with the node's // height minus provided distance. // // This function is safe for concurrent access. func (node *blockNode) RelativeAncestor(distance int32) *blockNode { return node.Ancestor(node.height - distance) } // CalcPastMedianTime calculates the median time of the previous few blocks // prior to, and including, the block node. // // This function is safe for concurrent access. func CalcPastMedianTime(node HeaderCtx) time.Time { // Create a slice of the previous few block timestamps used to calculate // the median per the number defined by the constant medianTimeBlocks. timestamps := make([]int64, medianTimeBlocks) numNodes := 0 iterNode := node for i := 0; i < medianTimeBlocks && iterNode != nil; i++ { timestamps[i] = iterNode.Timestamp() numNodes++ iterNode = iterNode.Parent() } // Prune the slice to the actual number of available timestamps which // will be fewer than desired near the beginning of the block chain // and sort them. timestamps = timestamps[:numNodes] sort.Sort(timeSorter(timestamps)) // NOTE: The consensus rules incorrectly calculate the median for even // numbers of blocks. A true median averages the middle two elements // for a set with an even number of elements in it. Since the constant // for the previous number of blocks to be used is odd, this is only an // issue for a few blocks near the beginning of the chain. I suspect // this is an optimization even though the result is slightly wrong for // a few of the first blocks since after the first few blocks, there // will always be an odd number of blocks in the set per the constant. // // This code follows suit to ensure the same rules are used, however, be // aware that should the medianTimeBlocks constant ever be changed to an // even number, this code will be wrong. medianTimestamp := timestamps[numNodes/2] return time.Unix(medianTimestamp, 0) } // A compile-time assertion to ensure blockNode implements the HeaderCtx // interface. var _ HeaderCtx = (*blockNode)(nil) // blockIndex provides facilities for keeping track of an in-memory index of the // block chain. Although the name block chain suggests a single chain of // blocks, it is actually a tree-shaped structure where any node can have // multiple children. However, there can only be one active branch which does // indeed form a chain from the tip all the way back to the genesis block. type blockIndex struct { // The following fields are set when the instance is created and can't // be changed afterwards, so there is no need to protect them with a // separate mutex. db database.DB chainParams *chaincfg.Params sync.RWMutex index map[chainhash.Hash]*blockNode dirty map[*blockNode]struct{} } // newBlockIndex returns a new empty instance of a block index. The index will // be dynamically populated as block nodes are loaded from the database and // manually added. func newBlockIndex(db database.DB, chainParams *chaincfg.Params) *blockIndex { return &blockIndex{ db: db, chainParams: chainParams, index: make(map[chainhash.Hash]*blockNode), dirty: make(map[*blockNode]struct{}), } } // HaveBlock returns whether or not the block index contains the provided hash. // // This function is safe for concurrent access. func (bi *blockIndex) HaveBlock(hash *chainhash.Hash) bool { bi.RLock() _, hasBlock := bi.index[*hash] bi.RUnlock() return hasBlock } // LookupNode returns the block node identified by the provided hash. It will // return nil if there is no entry for the hash. // // This function is safe for concurrent access. func (bi *blockIndex) LookupNode(hash *chainhash.Hash) *blockNode { bi.RLock() node := bi.index[*hash] bi.RUnlock() return node } // AddNode adds the provided node to the block index and marks it as dirty. // Duplicate entries are not checked so it is up to caller to avoid adding them. // // This function is safe for concurrent access. func (bi *blockIndex) AddNode(node *blockNode) { bi.Lock() bi.addNode(node) bi.dirty[node] = struct{}{} bi.Unlock() } // addNode adds the provided node to the block index, but does not mark it as // dirty. This can be used while initializing the block index. // // This function is NOT safe for concurrent access. func (bi *blockIndex) addNode(node *blockNode) { bi.index[node.hash] = node } // NodeStatus provides concurrent-safe access to the status field of a node. // // This function is safe for concurrent access. func (bi *blockIndex) NodeStatus(node *blockNode) blockStatus { bi.RLock() status := node.status bi.RUnlock() return status } // SetStatusFlags flips the provided status flags on the block node to on, // regardless of whether they were on or off previously. This does not unset any // flags currently on. // // This function is safe for concurrent access. func (bi *blockIndex) SetStatusFlags(node *blockNode, flags blockStatus) { bi.Lock() node.status |= flags bi.dirty[node] = struct{}{} bi.Unlock() } // UnsetStatusFlags flips the provided status flags on the block node to off, // regardless of whether they were on or off previously. // // This function is safe for concurrent access. func (bi *blockIndex) UnsetStatusFlags(node *blockNode, flags blockStatus) { bi.Lock() node.status &^= flags bi.dirty[node] = struct{}{} bi.Unlock() } // InactiveTips returns all the block nodes that aren't in the best chain. // // This function is safe for concurrent access. func (bi *blockIndex) InactiveTips(bestChain *chainView) []*blockNode { bi.RLock() defer bi.RUnlock() // Look through the entire blockindex and look for nodes that aren't in // the best chain. We're gonna keep track of all the orphans and the parents // of the orphans. orphans := make(map[chainhash.Hash]*blockNode) orphanParent := make(map[chainhash.Hash]*blockNode) for hash, node := range bi.index { found := bestChain.Contains(node) if !found { orphans[hash] = node orphanParent[node.parent.hash] = node.parent } } // If an orphan isn't pointed to by another orphan, it is a chain tip. // // We can check this by looking for the orphan in the orphan parent map. // If the orphan exists in the orphan parent map, it means that another // orphan is pointing to it. tips := make([]*blockNode, 0, len(orphans)) for hash, orphan := range orphans { _, found := orphanParent[hash] if !found { tips = append(tips, orphan) } delete(orphanParent, hash) } return tips } // flushToDB writes all dirty block nodes to the database. If all writes // succeed, this clears the dirty set. func (bi *blockIndex) flushToDB() error { bi.Lock() if len(bi.dirty) == 0 { bi.Unlock() return nil } err := bi.db.Update(func(dbTx database.Tx) error { for node := range bi.dirty { err := dbStoreBlockNode(dbTx, node) if err != nil { return err } } return nil }) // If write was successful, clear the dirty set. if err == nil { bi.dirty = make(map[*blockNode]struct{}) } bi.Unlock() return err } ================================================ FILE: blockchain/blockindex_test.go ================================================ // Copyright (c) 2023 The utreexo developers // Use of this source code is governed by an ISC // license that can be found in the LICENSE file. package blockchain import ( "math/rand" "testing" ) func TestAncestor(t *testing.T) { height := 500_000 blockNodes := chainedNodes(nil, height) for i, blockNode := range blockNodes { // Grab a random node that's a child of this node // and try to fetch the current blockNode with Ancestor. randNode := blockNodes[rand.Intn(height-i)+i] got := randNode.Ancestor(blockNode.height) // See if we got the right one. if got.hash != blockNode.hash { t.Fatalf("expected ancestor at height %d "+ "but got a node at height %d", blockNode.height, got.height) } // Gensis doesn't have ancestors so skip the check below. if blockNode.height == 0 { continue } // The ancestors are deterministic so check that this node's // ancestor is the correct one. if blockNode.ancestor.height != getAncestorHeight(blockNode.height) { t.Fatalf("expected anestor at height %d, but it was at %d", getAncestorHeight(blockNode.height), blockNode.ancestor.height) } } } ================================================ FILE: blockchain/chain.go ================================================ // Copyright (c) 2013-2018 The btcsuite developers // Copyright (c) 2015-2018 The Decred developers // Use of this source code is governed by an ISC // license that can be found in the LICENSE file. package blockchain import ( "container/list" "fmt" "sync" "time" "github.com/btcsuite/btcd/btcutil" "github.com/btcsuite/btcd/chaincfg" "github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/btcsuite/btcd/database" "github.com/btcsuite/btcd/txscript" "github.com/btcsuite/btcd/wire" ) const ( // maxOrphanBlocks is the maximum number of orphan blocks that can be // queued. maxOrphanBlocks = 100 ) // BlockLocator is used to help locate a specific block. The algorithm for // building the block locator is to add the hashes in reverse order until // the genesis block is reached. In order to keep the list of locator hashes // to a reasonable number of entries, first the most recent previous 12 block // hashes are added, then the step is doubled each loop iteration to // exponentially decrease the number of hashes as a function of the distance // from the block being located. // // For example, assume a block chain with a side chain as depicted below: // // genesis -> 1 -> 2 -> ... -> 15 -> 16 -> 17 -> 18 // \-> 16a -> 17a // // The block locator for block 17a would be the hashes of blocks: // [17a 16a 15 14 13 12 11 10 9 8 7 6 4 genesis] type BlockLocator []*chainhash.Hash // orphanBlock represents a block that we don't yet have the parent for. It // is a normal block plus an expiration time to prevent caching the orphan // forever. type orphanBlock struct { block *btcutil.Block expiration time.Time } // BestState houses information about the current best block and other info // related to the state of the main chain as it exists from the point of view of // the current best block. // // The BestSnapshot method can be used to obtain access to this information // in a concurrent safe manner and the data will not be changed out from under // the caller when chain state changes occur as the function name implies. // However, the returned snapshot must be treated as immutable since it is // shared by all callers. type BestState struct { Hash chainhash.Hash // The hash of the block. Height int32 // The height of the block. Bits uint32 // The difficulty bits of the block. BlockSize uint64 // The size of the block. BlockWeight uint64 // The weight of the block. NumTxns uint64 // The number of txns in the block. TotalTxns uint64 // The total number of txns in the chain. MedianTime time.Time // Median time as per CalcPastMedianTime. } // newBestState returns a new best stats instance for the given parameters. func newBestState(node *blockNode, blockSize, blockWeight, numTxns, totalTxns uint64, medianTime time.Time) *BestState { return &BestState{ Hash: node.hash, Height: node.height, Bits: node.bits, BlockSize: blockSize, BlockWeight: blockWeight, NumTxns: numTxns, TotalTxns: totalTxns, MedianTime: medianTime, } } // BlockChain provides functions for working with the bitcoin block chain. // It includes functionality such as rejecting duplicate blocks, ensuring blocks // follow all rules, orphan handling, checkpoint handling, and best chain // selection with reorganization. type BlockChain struct { // The following fields are set when the instance is created and can't // be changed afterwards, so there is no need to protect them with a // separate mutex. checkpoints []chaincfg.Checkpoint checkpointsByHeight map[int32]*chaincfg.Checkpoint db database.DB chainParams *chaincfg.Params timeSource MedianTimeSource sigCache *txscript.SigCache indexManager IndexManager hashCache *txscript.HashCache // The following fields are calculated based upon the provided chain // parameters. They are also set when the instance is created and // can't be changed afterwards, so there is no need to protect them with // a separate mutex. minRetargetTimespan int64 // target timespan / adjustment factor maxRetargetTimespan int64 // target timespan * adjustment factor blocksPerRetarget int32 // target timespan / target time per block // chainLock protects concurrent access to the vast majority of the // fields in this struct below this point. chainLock sync.RWMutex // pruneTarget is the size in bytes the database targets for when the node // is pruned. pruneTarget uint64 // These fields are related to the memory block index. They both have // their own locks, however they are often also protected by the chain // lock to help prevent logic races when blocks are being processed. // // index houses the entire block index in memory. The block index is // a tree-shaped structure. // // bestChain tracks the current active chain by making use of an // efficient chain view into the block index. index *blockIndex bestChain *chainView // The UTXO state holds a cached view of the UTXO state of the chain. // It is protected by the chain lock. utxoCache *utxoCache // These fields are related to handling of orphan blocks. They are // protected by a combination of the chain lock and the orphan lock. orphanLock sync.RWMutex orphans map[chainhash.Hash]*orphanBlock prevOrphans map[chainhash.Hash][]*orphanBlock oldestOrphan *orphanBlock // These fields are related to checkpoint handling. They are protected // by the chain lock. nextCheckpoint *chaincfg.Checkpoint checkpointNode *blockNode // The state is used as a fairly efficient way to cache information // about the current best chain state that is returned to callers when // requested. It operates on the principle of MVCC such that any time a // new block becomes the best block, the state pointer is replaced with // a new struct and the old state is left untouched. In this way, // multiple callers can be pointing to different best chain states. // This is acceptable for most callers because the state is only being // queried at a specific point in time. // // In addition, some of the fields are stored in the database so the // chain state can be quickly reconstructed on load. stateLock sync.RWMutex stateSnapshot *BestState // The following caches are used to efficiently keep track of the // current deployment threshold state of each rule change deployment. // // This information is stored in the database so it can be quickly // reconstructed on load. // // warningCaches caches the current deployment threshold state for blocks // in each of the **possible** deployments. This is used in order to // detect when new unrecognized rule changes are being voted on and/or // have been activated such as will be the case when older versions of // the software are being used // // deploymentCaches caches the current deployment threshold state for // blocks in each of the actively defined deployments. warningCaches []thresholdStateCache deploymentCaches []thresholdStateCache // The following fields are used to determine if certain warnings have // already been shown. // // unknownRulesWarned refers to warnings due to unknown rules being // activated. unknownRulesWarned bool // The notifications field stores a slice of callbacks to be executed on // certain blockchain events. notificationsLock sync.RWMutex notifications []NotificationCallback } // HaveBlock returns whether or not the chain instance has the block represented // by the passed hash. This includes checking the various places a block can // be like part of the main chain, on a side chain, or in the orphan pool. // // This function is safe for concurrent access. func (b *BlockChain) HaveBlock(hash *chainhash.Hash) (bool, error) { exists, err := b.blockExists(hash) if err != nil { return false, err } return exists || b.IsKnownOrphan(hash), nil } // IsKnownOrphan returns whether the passed hash is currently a known orphan. // Keep in mind that only a limited number of orphans are held onto for a // limited amount of time, so this function must not be used as an absolute // way to test if a block is an orphan block. A full block (as opposed to just // its hash) must be passed to ProcessBlock for that purpose. However, calling // ProcessBlock with an orphan that already exists results in an error, so this // function provides a mechanism for a caller to intelligently detect *recent* // duplicate orphans and react accordingly. // // This function is safe for concurrent access. func (b *BlockChain) IsKnownOrphan(hash *chainhash.Hash) bool { // Protect concurrent access. Using a read lock only so multiple // readers can query without blocking each other. b.orphanLock.RLock() _, exists := b.orphans[*hash] b.orphanLock.RUnlock() return exists } // GetOrphanRoot returns the head of the chain for the provided hash from the // map of orphan blocks. // // This function is safe for concurrent access. func (b *BlockChain) GetOrphanRoot(hash *chainhash.Hash) *chainhash.Hash { // Protect concurrent access. Using a read lock only so multiple // readers can query without blocking each other. b.orphanLock.RLock() defer b.orphanLock.RUnlock() // Keep looping while the parent of each orphaned block is // known and is an orphan itself. orphanRoot := hash prevHash := hash for { orphan, exists := b.orphans[*prevHash] if !exists { break } orphanRoot = prevHash prevHash = &orphan.block.MsgBlock().Header.PrevBlock } return orphanRoot } // removeOrphanBlock removes the passed orphan block from the orphan pool and // previous orphan index. func (b *BlockChain) removeOrphanBlock(orphan *orphanBlock) { // Protect concurrent access. b.orphanLock.Lock() defer b.orphanLock.Unlock() // Remove the orphan block from the orphan pool. orphanHash := orphan.block.Hash() delete(b.orphans, *orphanHash) // Remove the reference from the previous orphan index too. An indexing // for loop is intentionally used over a range here as range does not // reevaluate the slice on each iteration nor does it adjust the index // for the modified slice. prevHash := &orphan.block.MsgBlock().Header.PrevBlock orphans := b.prevOrphans[*prevHash] for i := 0; i < len(orphans); i++ { hash := orphans[i].block.Hash() if hash.IsEqual(orphanHash) { copy(orphans[i:], orphans[i+1:]) orphans[len(orphans)-1] = nil orphans = orphans[:len(orphans)-1] i-- } } b.prevOrphans[*prevHash] = orphans // Remove the map entry altogether if there are no longer any orphans // which depend on the parent hash. if len(b.prevOrphans[*prevHash]) == 0 { delete(b.prevOrphans, *prevHash) } } // addOrphanBlock adds the passed block (which is already determined to be // an orphan prior calling this function) to the orphan pool. It lazily cleans // up any expired blocks so a separate cleanup poller doesn't need to be run. // It also imposes a maximum limit on the number of outstanding orphan // blocks and will remove the oldest received orphan block if the limit is // exceeded. func (b *BlockChain) addOrphanBlock(block *btcutil.Block) { // Remove expired orphan blocks. for _, oBlock := range b.orphans { if time.Now().After(oBlock.expiration) { b.removeOrphanBlock(oBlock) continue } // Update the oldest orphan block pointer so it can be discarded // in case the orphan pool fills up. if b.oldestOrphan == nil || oBlock.expiration.Before(b.oldestOrphan.expiration) { b.oldestOrphan = oBlock } } // Limit orphan blocks to prevent memory exhaustion. if len(b.orphans)+1 > maxOrphanBlocks { // Remove the oldest orphan to make room for the new one. b.removeOrphanBlock(b.oldestOrphan) b.oldestOrphan = nil } // Protect concurrent access. This is intentionally done here instead // of near the top since removeOrphanBlock does its own locking and // the range iterator is not invalidated by removing map entries. b.orphanLock.Lock() defer b.orphanLock.Unlock() // Insert the block into the orphan map with an expiration time // 1 hour from now. expiration := time.Now().Add(time.Hour) oBlock := &orphanBlock{ block: block, expiration: expiration, } b.orphans[*block.Hash()] = oBlock // Add to previous hash lookup index for faster dependency lookups. prevHash := &block.MsgBlock().Header.PrevBlock b.prevOrphans[*prevHash] = append(b.prevOrphans[*prevHash], oBlock) } // SequenceLock represents the converted relative lock-time in seconds, and // absolute block-height for a transaction input's relative lock-times. // According to SequenceLock, after the referenced input has been confirmed // within a block, a transaction spending that input can be included into a // block either after 'seconds' (according to past median time), or once the // 'BlockHeight' has been reached. type SequenceLock struct { Seconds int64 BlockHeight int32 } // CalcSequenceLock computes a relative lock-time SequenceLock for the passed // transaction using the passed UtxoViewpoint to obtain the past median time // for blocks in which the referenced inputs of the transactions were included // within. The generated SequenceLock lock can be used in conjunction with a // block height, and adjusted median block time to determine if all the inputs // referenced within a transaction have reached sufficient maturity allowing // the candidate transaction to be included in a block. // // This function is safe for concurrent access. func (b *BlockChain) CalcSequenceLock(tx *btcutil.Tx, utxoView *UtxoViewpoint, mempool bool) (*SequenceLock, error) { b.chainLock.Lock() defer b.chainLock.Unlock() return b.calcSequenceLock(b.bestChain.Tip(), tx, utxoView, mempool) } // calcSequenceLock computes the relative lock-times for the passed // transaction. See the exported version, CalcSequenceLock for further details. // // This function MUST be called with the chain state lock held (for writes). func (b *BlockChain) calcSequenceLock(node *blockNode, tx *btcutil.Tx, utxoView *UtxoViewpoint, mempool bool) (*SequenceLock, error) { // A value of -1 for each relative lock type represents a relative time // lock value that will allow a transaction to be included in a block // at any given height or time. This value is returned as the relative // lock time in the case that BIP 68 is disabled, or has not yet been // activated. sequenceLock := &SequenceLock{Seconds: -1, BlockHeight: -1} // The sequence locks semantics are always active for transactions // within the mempool. csvSoftforkActive := mempool // If we're performing block validation, then we need to query the BIP9 // state. if !csvSoftforkActive { // Obtain the latest BIP9 version bits state for the // CSV-package soft-fork deployment. The adherence of sequence // locks depends on the current soft-fork state. csvState, err := b.deploymentState(node.parent, chaincfg.DeploymentCSV) if err != nil { return nil, err } csvSoftforkActive = csvState == ThresholdActive } // If the transaction's version is less than 2, and BIP 68 has not yet // been activated then sequence locks are disabled. Additionally, // sequence locks don't apply to coinbase transactions Therefore, we // return sequence lock values of -1 indicating that this transaction // can be included within a block at any given height or time. mTx := tx.MsgTx() sequenceLockActive := uint32(mTx.Version) >= 2 && csvSoftforkActive if !sequenceLockActive || IsCoinBase(tx) { return sequenceLock, nil } // Grab the next height from the PoV of the passed blockNode to use for // inputs present in the mempool. nextHeight := node.height + 1 for txInIndex, txIn := range mTx.TxIn { utxo := utxoView.LookupEntry(txIn.PreviousOutPoint) if utxo == nil { str := fmt.Sprintf("output %v referenced from "+ "transaction %s:%d either does not exist or "+ "has already been spent", txIn.PreviousOutPoint, tx.Hash(), txInIndex) return sequenceLock, ruleError(ErrMissingTxOut, str) } // If the input height is set to the mempool height, then we // assume the transaction makes it into the next block when // evaluating its sequence blocks. inputHeight := utxo.BlockHeight() if inputHeight == 0x7fffffff { inputHeight = nextHeight } // Given a sequence number, we apply the relative time lock // mask in order to obtain the time lock delta required before // this input can be spent. sequenceNum := txIn.Sequence relativeLock := int64(sequenceNum & wire.SequenceLockTimeMask) switch { // Relative time locks are disabled for this input, so we can // skip any further calculation. case sequenceNum&wire.SequenceLockTimeDisabled == wire.SequenceLockTimeDisabled: continue case sequenceNum&wire.SequenceLockTimeIsSeconds == wire.SequenceLockTimeIsSeconds: // This input requires a relative time lock expressed // in seconds before it can be spent. Therefore, we // need to query for the block prior to the one in // which this input was included within so we can // compute the past median time for the block prior to // the one which included this referenced output. prevInputHeight := inputHeight - 1 if prevInputHeight < 0 { prevInputHeight = 0 } blockNode := node.Ancestor(prevInputHeight) medianTime := CalcPastMedianTime(blockNode) // Time based relative time-locks as defined by BIP 68 // have a time granularity of RelativeLockSeconds, so // we shift left by this amount to convert to the // proper relative time-lock. We also subtract one from // the relative lock to maintain the original lockTime // semantics. timeLockSeconds := (relativeLock << wire.SequenceLockTimeGranularity) - 1 timeLock := medianTime.Unix() + timeLockSeconds if timeLock > sequenceLock.Seconds { sequenceLock.Seconds = timeLock } default: // The relative lock-time for this input is expressed // in blocks so we calculate the relative offset from // the input's height as its converted absolute // lock-time. We subtract one from the relative lock in // order to maintain the original lockTime semantics. blockHeight := inputHeight + int32(relativeLock-1) if blockHeight > sequenceLock.BlockHeight { sequenceLock.BlockHeight = blockHeight } } } return sequenceLock, nil } // LockTimeToSequence converts the passed relative locktime to a sequence // number in accordance to BIP-68. // See: https://github.com/bitcoin/bips/blob/master/bip-0068.mediawiki // - (Compatibility) func LockTimeToSequence(isSeconds bool, locktime uint32) uint32 { // If we're expressing the relative lock time in blocks, then the // corresponding sequence number is simply the desired input age. if !isSeconds { return locktime } // Set the 22nd bit which indicates the lock time is in seconds, then // shift the locktime over by 9 since the time granularity is in // 512-second intervals (2^9). This results in a max lock-time of // 33,553,920 seconds, or 1.1 years. return wire.SequenceLockTimeIsSeconds | locktime>>wire.SequenceLockTimeGranularity } // getReorganizeNodes finds the fork point between the main chain and the passed // node and returns a list of block nodes that would need to be detached from // the main chain and a list of block nodes that would need to be attached to // the fork point (which will be the end of the main chain after detaching the // returned list of block nodes) in order to reorganize the chain such that the // passed node is the new end of the main chain. The lists will be empty if the // passed node is not on a side chain. // // This function may modify node statuses in the block index without flushing. // // This function MUST be called with the chain state lock held (for reads). func (b *BlockChain) getReorganizeNodes(node *blockNode) (*list.List, *list.List) { attachNodes := list.New() detachNodes := list.New() // Do not reorganize to a known invalid chain. Ancestors deeper than the // direct parent are checked below but this is a quick check before doing // more unnecessary work. if b.index.NodeStatus(node.parent).KnownInvalid() { b.index.SetStatusFlags(node, statusInvalidAncestor) return detachNodes, attachNodes } // Find the fork point (if any) adding each block to the list of nodes // to attach to the main tree. Push them onto the list in reverse order // so they are attached in the appropriate order when iterating the list // later. forkNode := b.bestChain.FindFork(node) invalidChain := false for n := node; n != nil && n != forkNode; n = n.parent { if b.index.NodeStatus(n).KnownInvalid() { invalidChain = true break } attachNodes.PushFront(n) } // If any of the node's ancestors are invalid, unwind attachNodes, marking // each one as invalid for future reference. if invalidChain { var next *list.Element for e := attachNodes.Front(); e != nil; e = next { next = e.Next() n := attachNodes.Remove(e).(*blockNode) b.index.SetStatusFlags(n, statusInvalidAncestor) } return detachNodes, attachNodes } // Start from the end of the main chain and work backwards until the // common ancestor adding each block to the list of nodes to detach from // the main chain. for n := b.bestChain.Tip(); n != nil && n != forkNode; n = n.parent { detachNodes.PushBack(n) } return detachNodes, attachNodes } // connectBlock handles connecting the passed node/block to the end of the main // (best) chain. // // Passing in a utxo view is optional. If the passed in utxo view is nil, // connectBlock will assume that the utxo cache has already connected all the // txs in the block being connected. // If a utxo view is passed in, this passed utxo view must have all referenced // txos the block spends marked as spent and all of the new txos the block creates // added to it. // // The passed stxos slice must be populated with all of the information for the // spent txos. This approach is used because the connection validation that // must happen prior to calling this function requires the same details, so // it would be inefficient to repeat it. // // This function MUST be called with the chain state lock held (for writes). func (b *BlockChain) connectBlock(node *blockNode, block *btcutil.Block, stxos []SpentTxOut) error { // Make sure it's extending the end of the best chain. prevHash := &block.MsgBlock().Header.PrevBlock if !prevHash.IsEqual(&b.bestChain.Tip().hash) { return AssertError("connectBlock must be called with a block " + "that extends the main chain") } // Sanity check the correct number of stxos are provided. if len(stxos) != countSpentOutputs(block) { return AssertError("connectBlock called with inconsistent " + "spent transaction out information") } // No warnings about unknown rules until the chain is current. if b.isCurrent() { // Warn if any unknown new rules are either about to activate or // have already been activated. if err := b.warnUnknownRuleActivations(node); err != nil { return err } } // Write any block status changes to DB before updating best state. err := b.index.flushToDB() if err != nil { return err } // Generate a new best state snapshot that will be used to update the // database and later memory if all database updates are successful. b.stateLock.RLock() curTotalTxns := b.stateSnapshot.TotalTxns b.stateLock.RUnlock() numTxns := uint64(len(block.MsgBlock().Transactions)) blockSize := uint64(block.MsgBlock().SerializeSize()) blockWeight := uint64(GetBlockWeight(block)) state := newBestState(node, blockSize, blockWeight, numTxns, curTotalTxns+numTxns, CalcPastMedianTime(node), ) // Atomically insert info into the database. err = b.db.Update(func(dbTx database.Tx) error { // If the pruneTarget isn't 0, we should attempt to delete older blocks // from the database. if b.pruneTarget != 0 { // When the total block size is under the prune target, prune blocks is // a no-op and the deleted hashes are nil. deletedHashes, err := dbTx.PruneBlocks(b.pruneTarget) if err != nil { return err } // Only attempt to delete if we have any deleted blocks. if len(deletedHashes) != 0 { // Delete the spend journals of the pruned blocks. err = dbPruneSpendJournalEntry(dbTx, deletedHashes) if err != nil { return err } // We may need to flush if the prune will delete blocks that // are past our last flush block. // // NOTE: the database will never be inconsistent here as the // actual blocks are not deleted until the db.Update returns. needsFlush, err := b.flushNeededAfterPrune(deletedHashes) if err != nil { return err } if needsFlush { // Since the deleted hashes are past our last // flush block, flush the utxo cache now. err = b.utxoCache.flush(dbTx, FlushRequired, state) if err != nil { return err } } } } // Update best block state. err := dbPutBestState(dbTx, state, node.workSum) if err != nil { return err } // Add the block hash and height to the block index which tracks // the main chain. err = dbPutBlockIndex(dbTx, block.Hash(), node.height) if err != nil { return err } // Update the transaction spend journal by adding a record for // the block that contains all txos spent by it. err = dbPutSpendJournalEntry(dbTx, block.Hash(), stxos) if err != nil { return err } // Allow the index manager to call each of the currently active // optional indexes with the block being connected so they can // update themselves accordingly. if b.indexManager != nil { err := b.indexManager.ConnectBlock(dbTx, block, stxos) if err != nil { return err } } return nil }) if err != nil { return err } // This node is now the end of the best chain. b.bestChain.SetTip(node) // Update the state for the best block. Notice how this replaces the // entire struct instead of updating the existing one. This effectively // allows the old version to act as a snapshot which callers can use // freely without needing to hold a lock for the duration. See the // comments on the state variable for more details. b.stateLock.Lock() b.stateSnapshot = state b.stateLock.Unlock() // Notify the caller that the block was connected to the main chain. // The caller would typically want to react with actions such as // updating wallets. func() { b.chainLock.Unlock() defer b.chainLock.Lock() b.sendNotification(NTBlockConnected, block) }() // Since we may have changed the UTXO cache, we make sure it didn't exceed its // maximum size. If we're pruned and have flushed already, this will be a no-op. return b.db.Update(func(dbTx database.Tx) error { return b.utxoCache.flush(dbTx, FlushIfNeeded, state) }) } // disconnectBlock handles disconnecting the passed node/block from the end of // the main (best) chain. // // This function MUST be called with the chain state lock held (for writes). func (b *BlockChain) disconnectBlock(node *blockNode, block *btcutil.Block, view *UtxoViewpoint) error { // Make sure the node being disconnected is the end of the best chain. if !node.hash.IsEqual(&b.bestChain.Tip().hash) { return AssertError("disconnectBlock must be called with the " + "block at the end of the main chain") } // Load the previous block since some details for it are needed below. prevNode := node.parent var prevBlock *btcutil.Block err := b.db.View(func(dbTx database.Tx) error { var err error prevBlock, err = dbFetchBlockByNode(dbTx, prevNode) return err }) if err != nil { return err } // Write any block status changes to DB before updating best state. err = b.index.flushToDB() if err != nil { return err } // Generate a new best state snapshot that will be used to update the // database and later memory if all database updates are successful. b.stateLock.RLock() curTotalTxns := b.stateSnapshot.TotalTxns b.stateLock.RUnlock() numTxns := uint64(len(prevBlock.MsgBlock().Transactions)) blockSize := uint64(prevBlock.MsgBlock().SerializeSize()) blockWeight := uint64(GetBlockWeight(prevBlock)) newTotalTxns := curTotalTxns - uint64(len(block.MsgBlock().Transactions)) state := newBestState(prevNode, blockSize, blockWeight, numTxns, newTotalTxns, CalcPastMedianTime(prevNode)) err = b.db.Update(func(dbTx database.Tx) error { // Update best block state. err := dbPutBestState(dbTx, state, node.workSum) if err != nil { return err } // Remove the block hash and height from the block index which // tracks the main chain. err = dbRemoveBlockIndex(dbTx, block.Hash(), node.height) if err != nil { return err } // Flush the cache on every disconnect. Since the code for // reorganization modifies the database directly, the cache // will be left in an inconsistent state if we don't flush it // prior to the dbPutUtxoView that happens below. err = b.utxoCache.flush(dbTx, FlushRequired, state) if err != nil { return err } // Update the utxo set using the state of the utxo view. This // entails restoring all of the utxos spent and removing the new // ones created by the block. err = dbPutUtxoView(dbTx, view) if err != nil { return err } // Before we delete the spend journal entry for this back, // we'll fetch it as is so the indexers can utilize if needed. stxos, err := dbFetchSpendJournalEntry(dbTx, block) if err != nil { return err } // Update the transaction spend journal by removing the record // that contains all txos spent by the block. err = dbRemoveSpendJournalEntry(dbTx, block.Hash()) if err != nil { return err } // Allow the index manager to call each of the currently active // optional indexes with the block being disconnected so they // can update themselves accordingly. if b.indexManager != nil { err := b.indexManager.DisconnectBlock(dbTx, block, stxos) if err != nil { return err } } return nil }) if err != nil { return err } // Prune fully spent entries and mark all entries in the view unmodified // now that the modifications have been committed to the database. view.commit() // This node's parent is now the end of the best chain. b.bestChain.SetTip(node.parent) // Update the state for the best block. Notice how this replaces the // entire struct instead of updating the existing one. This effectively // allows the old version to act as a snapshot which callers can use // freely without needing to hold a lock for the duration. See the // comments on the state variable for more details. b.stateLock.Lock() b.stateSnapshot = state b.stateLock.Unlock() // Notify the caller that the block was disconnected from the main // chain. The caller would typically want to react with actions such as // updating wallets. func() { b.chainLock.Unlock() defer b.chainLock.Lock() b.sendNotification(NTBlockDisconnected, block) }() return nil } // countSpentOutputs returns the number of utxos the passed block spends. func countSpentOutputs(block *btcutil.Block) int { // Exclude the coinbase transaction since it can't spend anything. var numSpent int for _, tx := range block.Transactions()[1:] { numSpent += len(tx.MsgTx().TxIn) } return numSpent } // reorganizeChain reorganizes the block chain by disconnecting the nodes in the // detachNodes list and connecting the nodes in the attach list. It expects // that the lists are already in the correct order and are in sync with the // end of the current best chain. Specifically, nodes that are being // disconnected must be in reverse order (think of popping them off the end of // the chain) and nodes the are being attached must be in forwards order // (think pushing them onto the end of the chain). // // This function may modify node statuses in the block index without flushing. // // This function never leaves the utxo set in an inconsistent state for block // disconnects. // // This function MUST be called with the chain state lock held (for writes). func (b *BlockChain) reorganizeChain(detachNodes, attachNodes *list.List) error { // Check first that the detach and the attach nodes are valid and they // pass verification. detachBlocks, attachBlocks, detachSpentTxOuts, err := b.verifyReorganizationValidity(detachNodes, attachNodes) if err != nil { return err } // Track the old and new best chains heads. tip := b.bestChain.Tip() oldBest := tip newBest := tip // Reset the view for the actual connection code below. This is // required because the view was previously modified when checking if // the reorg would be successful and the connection code requires the // view to be valid from the viewpoint of each block being disconnected. view := NewUtxoViewpoint() view.SetBestHash(&b.bestChain.Tip().hash) // Disconnect blocks from the main chain. for i, e := 0, detachNodes.Front(); e != nil; i, e = i+1, e.Next() { n := e.Value.(*blockNode) block := detachBlocks[i] // Load all of the utxos referenced by the block that aren't // already in the view. err := view.fetchInputUtxos(b.utxoCache, block) if err != nil { return err } // Update the view to unspend all of the spent txos and remove // the utxos created by the block. err = view.disconnectTransactions( b.db, block, detachSpentTxOuts[i], ) if err != nil { return err } // Update the database and chain state. The cache will be flushed // here before the utxoview modifications happen to the database. err = b.disconnectBlock(n, block, view) if err != nil { return err } newBest = n.parent } // Set the fork point only if there are nodes to attach since otherwise // blocks are only being disconnected and thus there is no fork point. var forkNode *blockNode if attachNodes.Len() > 0 { forkNode = newBest } // Connect the new best chain blocks using the utxocache directly. It's more // efficient and since we already checked that the blocks are correct and that // the transactions connect properly, it's ok to access the cache. If we suddenly // crash here, we are able to recover as well. for i, e := 0, attachNodes.Front(); e != nil; i, e = i+1, e.Next() { n := e.Value.(*blockNode) block := attachBlocks[i] // Update the cache to mark all utxos referenced by the block // as spent and add all transactions being created by this block // to it. Also, provide an stxo slice so the spent txout // details are generated. stxos := make([]SpentTxOut, 0, countSpentOutputs(block)) err = b.utxoCache.connectTransactions(block, &stxos) if err != nil { return err } // Update the database and chain state. err = b.connectBlock(n, block, stxos) if err != nil { return err } newBest = n } // Log the point where the chain forked and old and new best chain // heads. if forkNode != nil { log.Infof("REORGANIZE: Chain forks at %v (height %v)", forkNode.hash, forkNode.height) } log.Infof("REORGANIZE: Old best chain head was %v (height %v)", &oldBest.hash, oldBest.height) log.Infof("REORGANIZE: New best chain head is %v (height %v)", newBest.hash, newBest.height) return nil } // verifyReorganizationValidity will verify that the disconnects and the connects // that are in the list are able to be processed without mutating the chain. // // For the attach nodes, it'll check that each of the blocks are valid and will // change the status of the block node in the list to invalid if the block fails // to pass verification. For the detach nodes, it'll check that the blocks being // detached and their spend journals are present on the database. func (b *BlockChain) verifyReorganizationValidity(detachNodes, attachNodes *list.List) ( []*btcutil.Block, []*btcutil.Block, [][]SpentTxOut, error) { // Nothing to do if no reorganize nodes were provided. if detachNodes.Len() == 0 && attachNodes.Len() == 0 { return nil, nil, nil, nil } // Ensure the provided nodes match the current best chain. tip := b.bestChain.Tip() if detachNodes.Len() != 0 { firstDetachNode := detachNodes.Front().Value.(*blockNode) if firstDetachNode.hash != tip.hash { return nil, nil, nil, AssertError(fmt.Sprintf("reorganize nodes to detach are "+ "not for the current best chain -- first detach node %v, "+ "current chain %v", &firstDetachNode.hash, &tip.hash)) } } // Ensure the provided nodes are for the same fork point. if attachNodes.Len() != 0 && detachNodes.Len() != 0 { firstAttachNode := attachNodes.Front().Value.(*blockNode) lastDetachNode := detachNodes.Back().Value.(*blockNode) if firstAttachNode.parent.hash != lastDetachNode.parent.hash { return nil, nil, nil, AssertError(fmt.Sprintf("reorganize nodes do not have the "+ "same fork point -- first attach parent %v, last detach "+ "parent %v", &firstAttachNode.parent.hash, &lastDetachNode.parent.hash)) } } // All of the blocks to detach and related spend journal entries needed // to unspend transaction outputs in the blocks being disconnected must // be loaded from the database during the reorg check phase below and // then they are needed again when doing the actual database updates. // Rather than doing two loads, cache the loaded data into these slices. detachBlocks := make([]*btcutil.Block, 0, detachNodes.Len()) detachSpentTxOuts := make([][]SpentTxOut, 0, detachNodes.Len()) attachBlocks := make([]*btcutil.Block, 0, attachNodes.Len()) // Disconnect all of the blocks back to the point of the fork. This // entails loading the blocks and their associated spent txos from the // database and using that information to unspend all of the spent txos // and remove the utxos created by the blocks. view := NewUtxoViewpoint() view.SetBestHash(&tip.hash) for e := detachNodes.Front(); e != nil; e = e.Next() { n := e.Value.(*blockNode) var block *btcutil.Block err := b.db.View(func(dbTx database.Tx) error { var err error block, err = dbFetchBlockByNode(dbTx, n) return err }) if err != nil { return nil, nil, nil, err } if n.hash != *block.Hash() { return nil, nil, nil, AssertError( fmt.Sprintf("detach block node hash %v (height "+ "%v) does not match previous parent block hash %v", &n.hash, n.height, block.Hash())) } // Load all of the utxos referenced by the block that aren't // already in the view. err = view.fetchInputUtxos(b.utxoCache, block) if err != nil { return nil, nil, nil, err } // Load all of the spent txos for the block from the spend // journal. var stxos []SpentTxOut err = b.db.View(func(dbTx database.Tx) error { stxos, err = dbFetchSpendJournalEntry(dbTx, block) return err }) if err != nil { return nil, nil, nil, err } // Store the loaded block and spend journal entry for later. detachBlocks = append(detachBlocks, block) detachSpentTxOuts = append(detachSpentTxOuts, stxos) err = view.disconnectTransactions(b.db, block, stxos) if err != nil { return nil, nil, nil, err } } // Perform several checks to verify each block that needs to be attached // to the main chain can be connected without violating any rules and // without actually connecting the block. // // NOTE: These checks could be done directly when connecting a block, // however the downside to that approach is that if any of these checks // fail after disconnecting some blocks or attaching others, all of the // operations have to be rolled back to get the chain back into the // state it was before the rule violation (or other failure). There are // at least a couple of ways accomplish that rollback, but both involve // tweaking the chain and/or database. This approach catches these // issues before ever modifying the chain. for e := attachNodes.Front(); e != nil; e = e.Next() { n := e.Value.(*blockNode) var block *btcutil.Block err := b.db.View(func(dbTx database.Tx) error { var err error block, err = dbFetchBlockByNode(dbTx, n) return err }) if err != nil { return nil, nil, nil, err } // Store the loaded block for later. attachBlocks = append(attachBlocks, block) // Skip checks if node has already been fully validated. Although // checkConnectBlock gets skipped, we still need to update the UTXO // view. if b.index.NodeStatus(n).KnownValid() { err = view.fetchInputUtxos(b.utxoCache, block) if err != nil { return nil, nil, nil, err } err = view.connectTransactions(block, nil) if err != nil { return nil, nil, nil, err } continue } // Notice the spent txout details are not requested here and // thus will not be generated. This is done because the state // is not being immediately written to the database, so it is // not needed. // // In the case the block is determined to be invalid due to a // rule violation, mark it as invalid and mark all of its // descendants as having an invalid ancestor. err = b.checkConnectBlock(n, block, view, nil) if err != nil { if _, ok := err.(RuleError); ok { b.index.SetStatusFlags(n, statusValidateFailed) for de := e.Next(); de != nil; de = de.Next() { dn := de.Value.(*blockNode) b.index.SetStatusFlags(dn, statusInvalidAncestor) } } return nil, nil, nil, err } b.index.SetStatusFlags(n, statusValid) } return detachBlocks, attachBlocks, detachSpentTxOuts, nil } // connectBestChain handles connecting the passed block to the chain while // respecting proper chain selection according to the chain with the most // proof of work. In the typical case, the new block simply extends the main // chain. However, it may also be extending (or creating) a side chain (fork) // which may or may not end up becoming the main chain depending on which fork // cumulatively has the most proof of work. It returns whether or not the block // ended up on the main chain (either due to extending the main chain or causing // a reorganization to become the main chain). // // The flags modify the behavior of this function as follows: // - BFFastAdd: Avoids several expensive transaction validation operations. // This is useful when using checkpoints. // // This function MUST be called with the chain state lock held (for writes). func (b *BlockChain) connectBestChain(node *blockNode, block *btcutil.Block, flags BehaviorFlags) (bool, error) { fastAdd := flags&BFFastAdd == BFFastAdd flushIndexState := func() { // Intentionally ignore errors writing updated node status to DB. If // it fails to write, it's not the end of the world. If the block is // valid, we flush in connectBlock and if the block is invalid, the // worst that can happen is we revalidate the block after a restart. if writeErr := b.index.flushToDB(); writeErr != nil { log.Warnf("Error flushing block index changes to disk: %v", writeErr) } } // We are extending the main (best) chain with a new block. This is the // most common case. parentHash := &block.MsgBlock().Header.PrevBlock if parentHash.IsEqual(&b.bestChain.Tip().hash) { // Skip checks if node has already been fully validated. fastAdd = fastAdd || b.index.NodeStatus(node).KnownValid() // Perform several checks to verify the block can be connected // to the main chain without violating any rules and without // actually connecting the block. if !fastAdd { // We create a viewpoint here to avoid spending or adding new // coins to the utxo cache. // // checkConnectBlock spends and adds utxos before doing the // signature validation and if the signature validation fails, // we would be forced to undo the utxo cache. // // TODO (kcalvinalvin): Doing all of the validation before connecting // the tx inside check connect block would allow us to pass the utxo // cache directly to the check connect block. This would save on the // expensive memory allocation done by fetch input utxos. view := NewUtxoViewpoint() view.SetBestHash(parentHash) err := b.checkConnectBlock(node, block, view, nil) if err == nil { b.index.SetStatusFlags(node, statusValid) } else if _, ok := err.(RuleError); ok { b.index.SetStatusFlags(node, statusValidateFailed) } else { return false, err } flushIndexState() if err != nil { return false, err } } // Connect the transactions to the cache. All the txs are considered valid // at this point as they have passed validation or was considered valid already. stxos := make([]SpentTxOut, 0, countSpentOutputs(block)) err := b.utxoCache.connectTransactions(block, &stxos) if err != nil { return false, err } // Connect the block to the main chain. err = b.connectBlock(node, block, stxos) if err != nil { // If we got hit with a rule error, then we'll mark // that status of the block as invalid and flush the // index state to disk before returning with the error. if _, ok := err.(RuleError); ok { b.index.SetStatusFlags( node, statusValidateFailed, ) } flushIndexState() return false, err } // If this is fast add, or this block node isn't yet marked as // valid, then we'll update its status and flush the state to // disk again. if fastAdd || !b.index.NodeStatus(node).KnownValid() { b.index.SetStatusFlags(node, statusValid) flushIndexState() } return true, nil } if fastAdd { log.Warnf("fastAdd set in the side chain case? %v\n", block.Hash()) } // We're extending (or creating) a side chain, but the cumulative // work for this new side chain is not enough to make it the new chain. if node.workSum.Cmp(b.bestChain.Tip().workSum) <= 0 { // Log information about how the block is forking the chain. fork := b.bestChain.FindFork(node) if fork.hash.IsEqual(parentHash) { log.Infof("FORK: Block %v forks the chain at height %d"+ "/block %v, but does not cause a reorganize", node.hash, fork.height, fork.hash) } else { log.Infof("EXTEND FORK: Block %v extends a side chain "+ "which forks the chain at height %d/block %v", node.hash, fork.height, fork.hash) } return false, nil } // We're extending (or creating) a side chain and the cumulative work // for this new side chain is more than the old best chain, so this side // chain needs to become the main chain. In order to accomplish that, // find the common ancestor of both sides of the fork, disconnect the // blocks that form the (now) old fork from the main chain, and attach // the blocks that form the new chain to the main chain starting at the // common ancenstor (the point where the chain forked). detachNodes, attachNodes := b.getReorganizeNodes(node) // Reorganize the chain. log.Infof("REORGANIZE: Block %v is causing a reorganize.", node.hash) err := b.reorganizeChain(detachNodes, attachNodes) // Either getReorganizeNodes or reorganizeChain could have made unsaved // changes to the block index, so flush regardless of whether there was an // error. The index would only be dirty if the block failed to connect, so // we can ignore any errors writing. if writeErr := b.index.flushToDB(); writeErr != nil { log.Warnf("Error flushing block index changes to disk: %v", writeErr) } return err == nil, err } // isCurrent returns whether or not the chain believes it is current. Several // factors are used to guess, but the key factors that allow the chain to // believe it is current are: // - Latest block height is after the latest checkpoint (if enabled) // - Latest block has a timestamp newer than 24 hours ago // // This function MUST be called with the chain state lock held (for reads). func (b *BlockChain) isCurrent() bool { // Not current if the latest main (best) chain height is before the // latest known good checkpoint (when checkpoints are enabled). checkpoint := b.LatestCheckpoint() if checkpoint != nil && b.bestChain.Tip().height < checkpoint.Height { return false } // Not current if the latest best block has a timestamp before 24 hours // ago. // // The chain appears to be current if none of the checks reported // otherwise. minus24Hours := b.timeSource.AdjustedTime().Add(-24 * time.Hour).Unix() return b.bestChain.Tip().timestamp >= minus24Hours } // IsCurrent returns whether or not the chain believes it is current. Several // factors are used to guess, but the key factors that allow the chain to // believe it is current are: // - Latest block height is after the latest checkpoint (if enabled) // - Latest block has a timestamp newer than 24 hours ago // // This function is safe for concurrent access. func (b *BlockChain) IsCurrent() bool { b.chainLock.RLock() defer b.chainLock.RUnlock() return b.isCurrent() } // BestSnapshot returns information about the current best chain block and // related state as of the current point in time. The returned instance must be // treated as immutable since it is shared by all callers. // // This function is safe for concurrent access. func (b *BlockChain) BestSnapshot() *BestState { b.stateLock.RLock() snapshot := b.stateSnapshot b.stateLock.RUnlock() return snapshot } // TipStatus is the status of a chain tip. type TipStatus byte const ( // StatusUnknown indicates that the tip status isn't any of the defined // statuses. StatusUnknown TipStatus = iota // StatusActive indicates that the tip is considered active and is in // the best chain. StatusActive // StatusInvalid indicates that this tip or any of the ancestors of this // tip are invalid. StatusInvalid // StatusValidFork is given if: // 1: Not a part of the best chain. // 2: Is not invalid. // 3: Has the block data stored to disk. StatusValidFork ) // String returns the status flags as string. func (ts TipStatus) String() string { switch ts { case StatusActive: return "active" case StatusInvalid: return "invalid" case StatusValidFork: return "valid-fork" } return fmt.Sprintf("unknown: %b", ts) } // ChainTip represents the last block in a branch of the block tree. type ChainTip struct { // Height of the tip. Height int32 // BlockHash hash of the tip. BlockHash chainhash.Hash // BranchLen is length of the fork point of this chain from the main chain. // Returns 0 if the chain tip is a part of the best chain. BranchLen int32 // Status is the validity status of the branch this tip is in. Status TipStatus } // ChainTips returns all the chain tips the node itself is aware of. Each tip is // represented by its height, block hash, branch length, and status. // // This function is safe for concurrent access. func (b *BlockChain) ChainTips() []ChainTip { b.chainLock.RLock() defer b.chainLock.RUnlock() // Grab all the inactive tips. tips := b.index.InactiveTips(b.bestChain) // Add the current tip. tips = append(tips, b.bestChain.Tip()) chainTips := make([]ChainTip, 0, len(tips)) // Go through all the tips and grab the height, hash, branch length, and the block // status. for _, tip := range tips { var status TipStatus switch { // The tip is considered active if it's in the best chain. case b.bestChain.Contains(tip): status = StatusActive // This block or any of the ancestors of this block are invalid. case tip.status.KnownInvalid(): status = StatusInvalid // If the tip meets the following criteria: // 1: Not a part of the best chain. // 2: Is not invalid. // 3: Has the block data stored to disk. // // The tip is considered a valid fork. // // We can check if a tip is a valid-fork by checking that // its data is available. Since the behavior is to give a // block node the statusDataStored status once it passes // the proof of work checks and basic chain validity checks. // // We can't use the KnownValid status since it's only given // to blocks that passed the validation AND were a part of // the bestChain. case tip.status.HaveData(): status = StatusValidFork } chainTip := ChainTip{ Height: tip.height, BlockHash: tip.hash, BranchLen: tip.height - b.bestChain.FindFork(tip).height, Status: status, } chainTips = append(chainTips, chainTip) } return chainTips } // HeaderByHash returns the block header identified by the given hash or an // error if it doesn't exist. Note that this will return headers from both the // main and side chains. func (b *BlockChain) HeaderByHash(hash *chainhash.Hash) (wire.BlockHeader, error) { node := b.index.LookupNode(hash) if node == nil { err := fmt.Errorf("block %s is not known", hash) return wire.BlockHeader{}, err } return node.Header(), nil } // MainChainHasBlock returns whether or not the block with the given hash is in // the main chain. // // This function is safe for concurrent access. func (b *BlockChain) MainChainHasBlock(hash *chainhash.Hash) bool { node := b.index.LookupNode(hash) return node != nil && b.bestChain.Contains(node) } // BlockLocatorFromHash returns a block locator for the passed block hash. // See BlockLocator for details on the algorithm used to create a block locator. // // In addition to the general algorithm referenced above, this function will // return the block locator for the latest known tip of the main (best) chain if // the passed hash is not currently known. // // This function is safe for concurrent access. func (b *BlockChain) BlockLocatorFromHash(hash *chainhash.Hash) BlockLocator { b.chainLock.RLock() node := b.index.LookupNode(hash) locator := b.bestChain.blockLocator(node) b.chainLock.RUnlock() return locator } // LatestBlockLocator returns a block locator for the latest known tip of the // main (best) chain. // // This function is safe for concurrent access. func (b *BlockChain) LatestBlockLocator() (BlockLocator, error) { b.chainLock.RLock() locator := b.bestChain.BlockLocator(nil) b.chainLock.RUnlock() return locator, nil } // BlockHeightByHash returns the height of the block with the given hash in the // main chain. // // This function is safe for concurrent access. func (b *BlockChain) BlockHeightByHash(hash *chainhash.Hash) (int32, error) { node := b.index.LookupNode(hash) if node == nil || !b.bestChain.Contains(node) { str := fmt.Sprintf("block %s is not in the main chain", hash) return 0, errNotInMainChain(str) } return node.height, nil } // BlockHashByHeight returns the hash of the block at the given height in the // main chain. // // This function is safe for concurrent access. func (b *BlockChain) BlockHashByHeight(blockHeight int32) (*chainhash.Hash, error) { node := b.bestChain.NodeByHeight(blockHeight) if node == nil { str := fmt.Sprintf("no block at height %d exists", blockHeight) return nil, errNotInMainChain(str) } return &node.hash, nil } // HeightRange returns a range of block hashes for the given start and end // heights. It is inclusive of the start height and exclusive of the end // height. The end height will be limited to the current main chain height. // // This function is safe for concurrent access. func (b *BlockChain) HeightRange(startHeight, endHeight int32) ([]chainhash.Hash, error) { // Ensure requested heights are sane. if startHeight < 0 { return nil, fmt.Errorf("start height of fetch range must not "+ "be less than zero - got %d", startHeight) } if endHeight < startHeight { return nil, fmt.Errorf("end height of fetch range must not "+ "be less than the start height - got start %d, end %d", startHeight, endHeight) } // There is nothing to do when the start and end heights are the same, // so return now to avoid the chain view lock. if startHeight == endHeight { return nil, nil } // Grab a lock on the chain view to prevent it from changing due to a // reorg while building the hashes. b.bestChain.mtx.Lock() defer b.bestChain.mtx.Unlock() // When the requested start height is after the most recent best chain // height, there is nothing to do. latestHeight := b.bestChain.tip().height if startHeight > latestHeight { return nil, nil } // Limit the ending height to the latest height of the chain. if endHeight > latestHeight+1 { endHeight = latestHeight + 1 } // Fetch as many as are available within the specified range. hashes := make([]chainhash.Hash, 0, endHeight-startHeight) for i := startHeight; i < endHeight; i++ { hashes = append(hashes, b.bestChain.nodeByHeight(i).hash) } return hashes, nil } // HeightToHashRange returns a range of block hashes for the given start height // and end hash, inclusive on both ends. The hashes are for all blocks that are // ancestors of endHash with height greater than or equal to startHeight. The // end hash must belong to a block that is known to be valid. // // This function is safe for concurrent access. func (b *BlockChain) HeightToHashRange(startHeight int32, endHash *chainhash.Hash, maxResults int) ([]chainhash.Hash, error) { endNode := b.index.LookupNode(endHash) if endNode == nil { return nil, fmt.Errorf("no known block header with hash %v", endHash) } if !b.index.NodeStatus(endNode).KnownValid() { return nil, fmt.Errorf("block %v is not yet validated", endHash) } endHeight := endNode.height if startHeight < 0 { return nil, fmt.Errorf("start height (%d) is below 0", startHeight) } if startHeight > endHeight { return nil, fmt.Errorf("start height (%d) is past end height (%d)", startHeight, endHeight) } resultsLength := int(endHeight - startHeight + 1) if resultsLength > maxResults { return nil, fmt.Errorf("number of results (%d) would exceed max (%d)", resultsLength, maxResults) } // Walk backwards from endHeight to startHeight, collecting block hashes. node := endNode hashes := make([]chainhash.Hash, resultsLength) for i := resultsLength - 1; i >= 0; i-- { hashes[i] = node.hash node = node.parent } return hashes, nil } // IntervalBlockHashes returns hashes for all blocks that are ancestors of // endHash where the block height is a positive multiple of interval. // // This function is safe for concurrent access. func (b *BlockChain) IntervalBlockHashes(endHash *chainhash.Hash, interval int, ) ([]chainhash.Hash, error) { endNode := b.index.LookupNode(endHash) if endNode == nil { return nil, fmt.Errorf("no known block header with hash %v", endHash) } if !b.index.NodeStatus(endNode).KnownValid() { return nil, fmt.Errorf("block %v is not yet validated", endHash) } endHeight := endNode.height resultsLength := int(endHeight) / interval hashes := make([]chainhash.Hash, resultsLength) b.bestChain.mtx.Lock() defer b.bestChain.mtx.Unlock() blockNode := endNode for index := int(endHeight) / interval; index > 0; index-- { // Use the bestChain chainView for faster lookups once lookup intersects // the best chain. blockHeight := int32(index * interval) if b.bestChain.contains(blockNode) { blockNode = b.bestChain.nodeByHeight(blockHeight) } else { blockNode = blockNode.Ancestor(blockHeight) } hashes[index-1] = blockNode.hash } return hashes, nil } // locateInventory returns the node of the block after the first known block in // the locator along with the number of subsequent nodes needed to either reach // the provided stop hash or the provided max number of entries. // // In addition, there are two special cases: // // - When no locators are provided, the stop hash is treated as a request for // that block, so it will either return the node associated with the stop hash // if it is known, or nil if it is unknown // - When locators are provided, but none of them are known, nodes starting // after the genesis block will be returned // // This is primarily a helper function for the locateBlocks and locateHeaders // functions. // // This function MUST be called with the chain state lock held (for reads). func (b *BlockChain) locateInventory(locator BlockLocator, hashStop *chainhash.Hash, maxEntries uint32) (*blockNode, uint32) { // There are no block locators so a specific block is being requested // as identified by the stop hash. stopNode := b.index.LookupNode(hashStop) if len(locator) == 0 { if stopNode == nil { // No blocks with the stop hash were found so there is // nothing to do. return nil, 0 } return stopNode, 1 } // Find the most recent locator block hash in the main chain. In the // case none of the hashes in the locator are in the main chain, fall // back to the genesis block. startNode := b.bestChain.Genesis() for _, hash := range locator { node := b.index.LookupNode(hash) if node != nil && b.bestChain.Contains(node) { startNode = node break } } // Start at the block after the most recently known block. When there // is no next block it means the most recently known block is the tip of // the best chain, so there is nothing more to do. startNode = b.bestChain.Next(startNode) if startNode == nil { return nil, 0 } // Calculate how many entries are needed. total := uint32((b.bestChain.Tip().height - startNode.height) + 1) if stopNode != nil && b.bestChain.Contains(stopNode) && stopNode.height >= startNode.height { total = uint32((stopNode.height - startNode.height) + 1) } if total > maxEntries { total = maxEntries } return startNode, total } // locateBlocks returns the hashes of the blocks after the first known block in // the locator until the provided stop hash is reached, or up to the provided // max number of block hashes. // // See the comment on the exported function for more details on special cases. // // This function MUST be called with the chain state lock held (for reads). func (b *BlockChain) locateBlocks(locator BlockLocator, hashStop *chainhash.Hash, maxHashes uint32) []chainhash.Hash { // Find the node after the first known block in the locator and the // total number of nodes after it needed while respecting the stop hash // and max entries. node, total := b.locateInventory(locator, hashStop, maxHashes) if total == 0 { return nil } // Populate and return the found hashes. hashes := make([]chainhash.Hash, 0, total) for i := uint32(0); i < total; i++ { hashes = append(hashes, node.hash) node = b.bestChain.Next(node) } return hashes } // LocateBlocks returns the hashes of the blocks after the first known block in // the locator until the provided stop hash is reached, or up to the provided // max number of block hashes. // // In addition, there are two special cases: // // - When no locators are provided, the stop hash is treated as a request for // that block, so it will either return the stop hash itself if it is known, // or nil if it is unknown // - When locators are provided, but none of them are known, hashes starting // after the genesis block will be returned // // This function is safe for concurrent access. func (b *BlockChain) LocateBlocks(locator BlockLocator, hashStop *chainhash.Hash, maxHashes uint32) []chainhash.Hash { b.chainLock.RLock() hashes := b.locateBlocks(locator, hashStop, maxHashes) b.chainLock.RUnlock() return hashes } // locateHeaders returns the headers of the blocks after the first known block // in the locator until the provided stop hash is reached, or up to the provided // max number of block headers. // // See the comment on the exported function for more details on special cases. // // This function MUST be called with the chain state lock held (for reads). func (b *BlockChain) locateHeaders(locator BlockLocator, hashStop *chainhash.Hash, maxHeaders uint32) []wire.BlockHeader { // Find the node after the first known block in the locator and the // total number of nodes after it needed while respecting the stop hash // and max entries. node, total := b.locateInventory(locator, hashStop, maxHeaders) if total == 0 { return nil } // Populate and return the found headers. headers := make([]wire.BlockHeader, 0, total) for i := uint32(0); i < total; i++ { headers = append(headers, node.Header()) node = b.bestChain.Next(node) } return headers } // LocateHeaders returns the headers of the blocks after the first known block // in the locator until the provided stop hash is reached, or up to a max of // wire.MaxBlockHeadersPerMsg headers. // // In addition, there are two special cases: // // - When no locators are provided, the stop hash is treated as a request for // that header, so it will either return the header for the stop hash itself // if it is known, or nil if it is unknown // - When locators are provided, but none of them are known, headers starting // after the genesis block will be returned // // This function is safe for concurrent access. func (b *BlockChain) LocateHeaders(locator BlockLocator, hashStop *chainhash.Hash) []wire.BlockHeader { b.chainLock.RLock() headers := b.locateHeaders(locator, hashStop, wire.MaxBlockHeadersPerMsg) b.chainLock.RUnlock() return headers } // InvalidateBlock invalidates the requested block and all its descedents. If a block // in the best chain is invalidated, the active chain tip will be the parent of the // invalidated block. // // This function is safe for concurrent access. func (b *BlockChain) InvalidateBlock(hash *chainhash.Hash) error { b.chainLock.Lock() defer b.chainLock.Unlock() node := b.index.LookupNode(hash) if node == nil { // Return an error if the block doesn't exist. return fmt.Errorf("Requested block hash of %s is not found "+ "and thus cannot be invalidated.", hash) } if node.height == 0 { return fmt.Errorf("Requested block hash of %s is a at height 0 "+ "and is thus a genesis block and cannot be invalidated.", node.hash) } // Nothing to do if the given block is already invalid. if node.status.KnownInvalid() { return nil } // Set the status of the block being invalidated. b.index.SetStatusFlags(node, statusValidateFailed) b.index.UnsetStatusFlags(node, statusValid) // If the block we're invalidating is not on the best chain, we simply // mark the block and all its descendants as invalid and return. if !b.bestChain.Contains(node) { // Grab all the tips excluding the active tip. tips := b.index.InactiveTips(b.bestChain) for _, tip := range tips { // Continue if the given inactive tip is not a descendant of the block // being invalidated. if !tip.IsAncestor(node) { continue } // Keep going back until we get to the block being invalidated. // For each of the parent, we'll unset valid status and set invalid // ancestor status. for n := tip; n != nil && n != node; n = n.parent { // Continue if it's already invalid. if n.status.KnownInvalid() { continue } b.index.SetStatusFlags(n, statusInvalidAncestor) b.index.UnsetStatusFlags(n, statusValid) } } if writeErr := b.index.flushToDB(); writeErr != nil { return fmt.Errorf("Error flushing block index "+ "changes to disk: %v", writeErr) } // Return since the block being invalidated is on a side branch. // Nothing else left to do. return nil } // If we're here, it means a block from the active chain tip is getting // invalidated. // // Grab all the nodes to detach from the active chain. detachNodes := list.New() for n := b.bestChain.Tip(); n != nil && n != node; n = n.parent { // Continue if it's already invalid. if n.status.KnownInvalid() { continue } // Change the status of the block node. b.index.SetStatusFlags(n, statusInvalidAncestor) b.index.UnsetStatusFlags(n, statusValid) detachNodes.PushBack(n) } // Push back the block node being invalidated. detachNodes.PushBack(node) // Reorg back to the parent of the block being invalidated. // Nothing to attach so just pass an empty list. err := b.reorganizeChain(detachNodes, list.New()) if err != nil { return err } if writeErr := b.index.flushToDB(); writeErr != nil { log.Warnf("Error flushing block index changes to disk: %v", writeErr) } // Grab all the tips. tips := b.index.InactiveTips(b.bestChain) tips = append(tips, b.bestChain.Tip()) // Here we'll check if the invalidation of the block in the active tip // changes the status of the chain tips. If a side branch now has more // worksum, it becomes the active chain tip. var bestTip *blockNode for _, tip := range tips { // Skip invalid tips as they cannot become the active tip. if tip.status.KnownInvalid() { continue } // If we have no best tips, then set this tip as the best tip. if bestTip == nil { bestTip = tip } else { // If there is an existing best tip, then compare it // against the current tip. if tip.workSum.Cmp(bestTip.workSum) == 1 { bestTip = tip } } } // Return if the best tip is the current tip. if bestTip == b.bestChain.Tip() { return nil } // Reorganize to the best tip if a side branch is now the most work tip. detachNodes, attachNodes := b.getReorganizeNodes(bestTip) err = b.reorganizeChain(detachNodes, attachNodes) if writeErr := b.index.flushToDB(); writeErr != nil { log.Warnf("Error flushing block index changes to disk: %v", writeErr) } return err } // ReconsiderBlock reconsiders the validity of the block with the given hash. // // This function is safe for concurrent access. func (b *BlockChain) ReconsiderBlock(hash *chainhash.Hash) error { b.chainLock.Lock() defer b.chainLock.Unlock() log.Infof("Reconsidering block_hash=%v", hash[:]) reconsiderNode := b.index.LookupNode(hash) if reconsiderNode == nil { // Return an error if the block doesn't exist. return fmt.Errorf("requested block hash of %s is not found "+ "and thus cannot be reconsidered", hash) } // Nothing to do if the given block is already valid. if reconsiderNode.status.KnownValid() { log.Infof("block_hash=%x is valid, nothing to reconsider", hash[:]) return nil } // Clear the status of the block being reconsidered. b.index.UnsetStatusFlags(reconsiderNode, statusInvalidAncestor) b.index.UnsetStatusFlags(reconsiderNode, statusValidateFailed) // Grab all the tips. tips := b.index.InactiveTips(b.bestChain) tips = append(tips, b.bestChain.Tip()) log.Debugf("Examining %v inactive chain tips for reconsideration") // Go through all the tips and unset the status for all the descendents of the // block being reconsidered. var reconsiderTip *blockNode for _, tip := range tips { // Continue if the given inactive tip is not a descendant of the block // being invalidated. if !tip.IsAncestor(reconsiderNode) { // Set as the reconsider tip if the block node being reconsidered // is a tip. if tip == reconsiderNode { reconsiderTip = reconsiderNode } continue } // Mark the current tip as the tip being reconsidered. reconsiderTip = tip // Unset the status of all the parents up until it reaches the block // being reconsidered. for n := tip; n != nil && n != reconsiderNode; n = n.parent { b.index.UnsetStatusFlags(n, statusInvalidAncestor) } } // Compare the cumulative work for the branch being reconsidered. bestTipWork := b.bestChain.Tip().workSum if reconsiderTip.workSum.Cmp(bestTipWork) <= 0 { log.Debugf("Tip to reconsider has less cumulative work than current "+ "chain tip: %v vs %v", reconsiderTip.workSum, bestTipWork) return nil } // If the reconsider tip has a higher cumulative work, then reorganize // to it after checking the validity of the nodes. detachNodes, attachNodes := b.getReorganizeNodes(reconsiderTip) // We're checking if the reorganization that'll happen is actually valid. // While this is called in reorganizeChain, we call it beforehand as the error // returned from reorganizeChain doesn't differentiate between actual disconnect/ // connect errors or whether the branch we're trying to fork to is invalid. // // The block status changes here without being flushed so we immediately flush // the blockindex after we call this function. _, _, _, err := b.verifyReorganizationValidity(detachNodes, attachNodes) if writeErr := b.index.flushToDB(); writeErr != nil { log.Warnf("Error flushing block index changes to disk: %v", writeErr) } if err != nil { // If we errored out during the verification of the reorg branch, // it's ok to return nil as we reconsidered the block and determined // that it's invalid. return nil } return b.reorganizeChain(detachNodes, attachNodes) } // IndexManager provides a generic interface that the is called when blocks are // connected and disconnected to and from the tip of the main chain for the // purpose of supporting optional indexes. type IndexManager interface { // Init is invoked during chain initialize in order to allow the index // manager to initialize itself and any indexes it is managing. The // channel parameter specifies a channel the caller can close to signal // that the process should be interrupted. It can be nil if that // behavior is not desired. Init(*BlockChain, <-chan struct{}) error // ConnectBlock is invoked when a new block has been connected to the // main chain. The set of output spent within a block is also passed in // so indexers can access the previous output scripts input spent if // required. ConnectBlock(database.Tx, *btcutil.Block, []SpentTxOut) error // DisconnectBlock is invoked when a block has been disconnected from // the main chain. The set of outputs scripts that were spent within // this block is also returned so indexers can clean up the prior index // state for this block. DisconnectBlock(database.Tx, *btcutil.Block, []SpentTxOut) error } // Config is a descriptor which specifies the blockchain instance configuration. type Config struct { // DB defines the database which houses the blocks and will be used to // store all metadata created by this package such as the utxo set. // // This field is required. DB database.DB // The maximum size in bytes of the UTXO cache. // // This field is required. UtxoCacheMaxSize uint64 // Interrupt specifies a channel the caller can close to signal that // long running operations, such as catching up indexes or performing // database migrations, should be interrupted. // // This field can be nil if the caller does not desire the behavior. Interrupt <-chan struct{} // ChainParams identifies which chain parameters the chain is associated // with. // // This field is required. ChainParams *chaincfg.Params // Checkpoints hold caller-defined checkpoints that should be added to // the default checkpoints in ChainParams. Checkpoints must be sorted // by height. // // This field can be nil if the caller does not wish to specify any // checkpoints. Checkpoints []chaincfg.Checkpoint // TimeSource defines the median time source to use for things such as // block processing and determining whether or not the chain is current. // // The caller is expected to keep a reference to the time source as well // and add time samples from other peers on the network so the local // time is adjusted to be in agreement with other peers. TimeSource MedianTimeSource // SigCache defines a signature cache to use when when validating // signatures. This is typically most useful when individual // transactions are already being validated prior to their inclusion in // a block such as what is usually done via a transaction memory pool. // // This field can be nil if the caller is not interested in using a // signature cache. SigCache *txscript.SigCache // IndexManager defines an index manager to use when initializing the // chain and connecting and disconnecting blocks. // // This field can be nil if the caller does not wish to make use of an // index manager. IndexManager IndexManager // HashCache defines a transaction hash mid-state cache to use when // validating transactions. This cache has the potential to greatly // speed up transaction validation as re-using the pre-calculated // mid-state eliminates the O(N^2) validation complexity due to the // SigHashAll flag. // // This field can be nil if the caller is not interested in using a // signature cache. HashCache *txscript.HashCache // Prune specifies the target database usage (in bytes) the database // will target for with block files. Prune at 0 specifies that no // blocks will be deleted. Prune uint64 } // New returns a BlockChain instance using the provided configuration details. func New(config *Config) (*BlockChain, error) { // Enforce required config fields. if config.DB == nil { return nil, AssertError("blockchain.New database is nil") } if config.ChainParams == nil { return nil, AssertError("blockchain.New chain parameters nil") } if config.TimeSource == nil { return nil, AssertError("blockchain.New timesource is nil") } // Generate a checkpoint by height map from the provided checkpoints // and assert the provided checkpoints are sorted by height as required. var checkpointsByHeight map[int32]*chaincfg.Checkpoint var prevCheckpointHeight int32 if len(config.Checkpoints) > 0 { checkpointsByHeight = make(map[int32]*chaincfg.Checkpoint) for i := range config.Checkpoints { checkpoint := &config.Checkpoints[i] if checkpoint.Height <= prevCheckpointHeight { return nil, AssertError("blockchain.New " + "checkpoints are not sorted by height") } checkpointsByHeight[checkpoint.Height] = checkpoint prevCheckpointHeight = checkpoint.Height } } params := config.ChainParams targetTimespan := int64(params.TargetTimespan / time.Second) targetTimePerBlock := int64(params.TargetTimePerBlock / time.Second) adjustmentFactor := params.RetargetAdjustmentFactor b := BlockChain{ checkpoints: config.Checkpoints, checkpointsByHeight: checkpointsByHeight, db: config.DB, chainParams: params, timeSource: config.TimeSource, sigCache: config.SigCache, indexManager: config.IndexManager, minRetargetTimespan: targetTimespan / adjustmentFactor, maxRetargetTimespan: targetTimespan * adjustmentFactor, blocksPerRetarget: int32(targetTimespan / targetTimePerBlock), index: newBlockIndex(config.DB, params), utxoCache: newUtxoCache(config.DB, config.UtxoCacheMaxSize), hashCache: config.HashCache, bestChain: newChainView(nil), orphans: make(map[chainhash.Hash]*orphanBlock), prevOrphans: make(map[chainhash.Hash][]*orphanBlock), warningCaches: newThresholdCaches(vbNumBits), deploymentCaches: newThresholdCaches(chaincfg.DefinedDeployments), pruneTarget: config.Prune, } // Ensure all the deployments are synchronized with our clock if // needed. for _, deployment := range b.chainParams.Deployments { deploymentStarter := deployment.DeploymentStarter if clockStarter, ok := deploymentStarter.(chaincfg.ClockConsensusDeploymentStarter); ok { clockStarter.SynchronizeClock(&b) } deploymentEnder := deployment.DeploymentEnder if clockEnder, ok := deploymentEnder.(chaincfg.ClockConsensusDeploymentEnder); ok { clockEnder.SynchronizeClock(&b) } } // Initialize the chain state from the passed database. When the db // does not yet contain any chain state, both it and the chain state // will be initialized to contain only the genesis block. if err := b.initChainState(); err != nil { return nil, err } // Perform any upgrades to the various chain-specific buckets as needed. if err := b.maybeUpgradeDbBuckets(config.Interrupt); err != nil { return nil, err } // Initialize and catch up all of the currently active optional indexes // as needed. if config.IndexManager != nil { err := config.IndexManager.Init(&b, config.Interrupt) if err != nil { return nil, err } } // Initialize rule change threshold state caches. if err := b.initThresholdCaches(); err != nil { return nil, err } // Make sure the utxo state is catched up if it was left in an inconsistent // state. bestNode := b.bestChain.Tip() if err := b.InitConsistentState(bestNode, config.Interrupt); err != nil { return nil, err } log.Infof("Chain state (height %d, hash %v, totaltx %d, work %v)", bestNode.height, bestNode.hash, b.stateSnapshot.TotalTxns, bestNode.workSum) return &b, nil } // CachedStateSize returns the total size of the cached state of the blockchain // in bytes. func (b *BlockChain) CachedStateSize() uint64 { b.chainLock.Lock() defer b.chainLock.Unlock() return b.utxoCache.totalMemoryUsage() } ================================================ FILE: blockchain/chain_test.go ================================================ // Copyright (c) 2013-2017 The btcsuite developers // Use of this source code is governed by an ISC // license that can be found in the LICENSE file. package blockchain import ( "fmt" "math/rand" "reflect" "testing" "time" "github.com/btcsuite/btcd/blockchain/internal/testhelper" "github.com/btcsuite/btcd/btcutil" "github.com/btcsuite/btcd/chaincfg" "github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/btcsuite/btcd/wire" ) // TestHaveBlock tests the HaveBlock API to ensure proper functionality. func TestHaveBlock(t *testing.T) { // Load up blocks such that there is a side chain. // (genesis block) -> 1 -> 2 -> 3 -> 4 // \-> 3a testFiles := []string{ "blk_0_to_4.dat.bz2", "blk_3A.dat.bz2", } var blocks []*btcutil.Block for _, file := range testFiles { blockTmp, err := loadBlocks(file) if err != nil { t.Errorf("Error loading file: %v\n", err) return } blocks = append(blocks, blockTmp...) } // Create a new database and chain instance to run tests against. chain, teardownFunc, err := chainSetup("haveblock", &chaincfg.MainNetParams) if err != nil { t.Errorf("Failed to setup chain instance: %v", err) return } defer teardownFunc() // Since we're not dealing with the real block chain, set the coinbase // maturity to 1. chain.TstSetCoinbaseMaturity(1) for i := 1; i < len(blocks); i++ { _, isOrphan, err := chain.ProcessBlock(blocks[i], BFNone) if err != nil { t.Errorf("ProcessBlock fail on block %v: %v\n", i, err) return } if isOrphan { t.Errorf("ProcessBlock incorrectly returned block %v "+ "is an orphan\n", i) return } } // Insert an orphan block. _, isOrphan, err := chain.ProcessBlock(btcutil.NewBlock(&Block100000), BFNone) if err != nil { t.Errorf("Unable to process block: %v", err) return } if !isOrphan { t.Errorf("ProcessBlock indicated block is an not orphan when " + "it should be\n") return } tests := []struct { hash string want bool }{ // Genesis block should be present (in the main chain). {hash: chaincfg.MainNetParams.GenesisHash.String(), want: true}, // Block 3a should be present (on a side chain). {hash: "00000000474284d20067a4d33f6a02284e6ef70764a3a26d6a5b9df52ef663dd", want: true}, // Block 100000 should be present (as an orphan). {hash: "000000000003ba27aa200b1cecaad478d2b00432346c3f1f3986da1afd33e506", want: true}, // Random hashes should not be available. {hash: "123", want: false}, } for i, test := range tests { hash, err := chainhash.NewHashFromStr(test.hash) if err != nil { t.Errorf("NewHashFromStr: %v", err) continue } result, err := chain.HaveBlock(hash) if err != nil { t.Errorf("HaveBlock #%d unexpected error: %v", i, err) return } if result != test.want { t.Errorf("HaveBlock #%d got %v want %v", i, result, test.want) continue } } } // TestCalcSequenceLock tests the LockTimeToSequence function, and the // CalcSequenceLock method of a Chain instance. The tests exercise several // combinations of inputs to the CalcSequenceLock function in order to ensure // the returned SequenceLocks are correct for each test instance. func TestCalcSequenceLock(t *testing.T) { netParams := &chaincfg.SimNetParams // We need to activate CSV in order to test the processing logic, so // manually craft the block version that's used to signal the soft-fork // activation. csvBit := netParams.Deployments[chaincfg.DeploymentCSV].BitNumber blockVersion := int32(0x20000000 | (uint32(1) << csvBit)) // Generate enough synthetic blocks to activate CSV. chain := newFakeChain(netParams) node := chain.bestChain.Tip() blockTime := node.Header().Timestamp numBlocksToActivate := (netParams.MinerConfirmationWindow * 3) for i := uint32(0); i < numBlocksToActivate; i++ { blockTime = blockTime.Add(time.Second) node = newFakeNode(node, blockVersion, 0, blockTime) chain.index.AddNode(node) chain.bestChain.SetTip(node) } // Create a utxo view with a fake utxo for the inputs used in the // transactions created below. This utxo is added such that it has an // age of 4 blocks. targetTx := btcutil.NewTx(&wire.MsgTx{ TxOut: []*wire.TxOut{{ PkScript: nil, Value: 10, }}, }) utxoView := NewUtxoViewpoint() utxoView.AddTxOuts(targetTx, int32(numBlocksToActivate)-4) utxoView.SetBestHash(&node.hash) // Create a utxo that spends the fake utxo created above for use in the // transactions created in the tests. It has an age of 4 blocks. Note // that the sequence lock heights are always calculated from the same // point of view that they were originally calculated from for a given // utxo. That is to say, the height prior to it. utxo := wire.OutPoint{ Hash: *targetTx.Hash(), Index: 0, } prevUtxoHeight := int32(numBlocksToActivate) - 4 // Obtain the median time past from the PoV of the input created above. // The MTP for the input is the MTP from the PoV of the block *prior* // to the one that included it. medianTime := CalcPastMedianTime(node.RelativeAncestor(5)).Unix() // The median time calculated from the PoV of the best block in the // test chain. For unconfirmed inputs, this value will be used since // the MTP will be calculated from the PoV of the yet-to-be-mined // block. nextMedianTime := CalcPastMedianTime(node).Unix() nextBlockHeight := int32(numBlocksToActivate) + 1 // Add an additional transaction which will serve as our unconfirmed // output. unConfTx := &wire.MsgTx{ TxOut: []*wire.TxOut{{ PkScript: nil, Value: 5, }}, } unConfUtxo := wire.OutPoint{ Hash: unConfTx.TxHash(), Index: 0, } // Adding a utxo with a height of 0x7fffffff indicates that the output // is currently unmined. utxoView.AddTxOuts(btcutil.NewTx(unConfTx), 0x7fffffff) tests := []struct { tx *wire.MsgTx view *UtxoViewpoint mempool bool want *SequenceLock }{ // A transaction of version one should disable sequence locks // as the new sequence number semantics only apply to // transactions version 2 or higher. { tx: &wire.MsgTx{ Version: 1, TxIn: []*wire.TxIn{{ PreviousOutPoint: utxo, Sequence: LockTimeToSequence(false, 3), }}, }, view: utxoView, want: &SequenceLock{ Seconds: -1, BlockHeight: -1, }, }, // A transaction with a single input with max sequence number. // This sequence number has the high bit set, so sequence locks // should be disabled. { tx: &wire.MsgTx{ Version: 2, TxIn: []*wire.TxIn{{ PreviousOutPoint: utxo, Sequence: wire.MaxTxInSequenceNum, }}, }, view: utxoView, want: &SequenceLock{ Seconds: -1, BlockHeight: -1, }, }, // A transaction with a single input whose lock time is // expressed in seconds. However, the specified lock time is // below the required floor for time based lock times since // they have time granularity of 512 seconds. As a result, the // seconds lock-time should be just before the median time of // the targeted block. { tx: &wire.MsgTx{ Version: 2, TxIn: []*wire.TxIn{{ PreviousOutPoint: utxo, Sequence: LockTimeToSequence(true, 2), }}, }, view: utxoView, want: &SequenceLock{ Seconds: medianTime - 1, BlockHeight: -1, }, }, // A transaction with a single input whose lock time is // expressed in seconds. The number of seconds should be 1023 // seconds after the median past time of the last block in the // chain. { tx: &wire.MsgTx{ Version: 2, TxIn: []*wire.TxIn{{ PreviousOutPoint: utxo, Sequence: LockTimeToSequence(true, 1024), }}, }, view: utxoView, want: &SequenceLock{ Seconds: medianTime + 1023, BlockHeight: -1, }, }, // A transaction with multiple inputs. The first input has a // lock time expressed in seconds. The second input has a // sequence lock in blocks with a value of 4. The last input // has a sequence number with a value of 5, but has the disable // bit set. So the first lock should be selected as it's the // latest lock that isn't disabled. { tx: &wire.MsgTx{ Version: 2, TxIn: []*wire.TxIn{{ PreviousOutPoint: utxo, Sequence: LockTimeToSequence(true, 2560), }, { PreviousOutPoint: utxo, Sequence: LockTimeToSequence(false, 4), }, { PreviousOutPoint: utxo, Sequence: LockTimeToSequence(false, 5) | wire.SequenceLockTimeDisabled, }}, }, view: utxoView, want: &SequenceLock{ Seconds: medianTime + (5 << wire.SequenceLockTimeGranularity) - 1, BlockHeight: prevUtxoHeight + 3, }, }, // Transaction with a single input. The input's sequence number // encodes a relative lock-time in blocks (3 blocks). The // sequence lock should have a value of -1 for seconds, but a // height of 2 meaning it can be included at height 3. { tx: &wire.MsgTx{ Version: 2, TxIn: []*wire.TxIn{{ PreviousOutPoint: utxo, Sequence: LockTimeToSequence(false, 3), }}, }, view: utxoView, want: &SequenceLock{ Seconds: -1, BlockHeight: prevUtxoHeight + 2, }, }, // A transaction with two inputs with lock times expressed in // seconds. The selected sequence lock value for seconds should // be the time further in the future. { tx: &wire.MsgTx{ Version: 2, TxIn: []*wire.TxIn{{ PreviousOutPoint: utxo, Sequence: LockTimeToSequence(true, 5120), }, { PreviousOutPoint: utxo, Sequence: LockTimeToSequence(true, 2560), }}, }, view: utxoView, want: &SequenceLock{ Seconds: medianTime + (10 << wire.SequenceLockTimeGranularity) - 1, BlockHeight: -1, }, }, // A transaction with two inputs with lock times expressed in // blocks. The selected sequence lock value for blocks should // be the height further in the future, so a height of 10 // indicating it can be included at height 11. { tx: &wire.MsgTx{ Version: 2, TxIn: []*wire.TxIn{{ PreviousOutPoint: utxo, Sequence: LockTimeToSequence(false, 1), }, { PreviousOutPoint: utxo, Sequence: LockTimeToSequence(false, 11), }}, }, view: utxoView, want: &SequenceLock{ Seconds: -1, BlockHeight: prevUtxoHeight + 10, }, }, // A transaction with multiple inputs. Two inputs are time // based, and the other two are block based. The lock lying // further into the future for both inputs should be chosen. { tx: &wire.MsgTx{ Version: 2, TxIn: []*wire.TxIn{{ PreviousOutPoint: utxo, Sequence: LockTimeToSequence(true, 2560), }, { PreviousOutPoint: utxo, Sequence: LockTimeToSequence(true, 6656), }, { PreviousOutPoint: utxo, Sequence: LockTimeToSequence(false, 3), }, { PreviousOutPoint: utxo, Sequence: LockTimeToSequence(false, 9), }}, }, view: utxoView, want: &SequenceLock{ Seconds: medianTime + (13 << wire.SequenceLockTimeGranularity) - 1, BlockHeight: prevUtxoHeight + 8, }, }, // A transaction with a single unconfirmed input. As the input // is confirmed, the height of the input should be interpreted // as the height of the *next* block. So, a 2 block relative // lock means the sequence lock should be for 1 block after the // *next* block height, indicating it can be included 2 blocks // after that. { tx: &wire.MsgTx{ Version: 2, TxIn: []*wire.TxIn{{ PreviousOutPoint: unConfUtxo, Sequence: LockTimeToSequence(false, 2), }}, }, view: utxoView, mempool: true, want: &SequenceLock{ Seconds: -1, BlockHeight: nextBlockHeight + 1, }, }, // A transaction with a single unconfirmed input. The input has // a time based lock, so the lock time should be based off the // MTP of the *next* block. { tx: &wire.MsgTx{ Version: 2, TxIn: []*wire.TxIn{{ PreviousOutPoint: unConfUtxo, Sequence: LockTimeToSequence(true, 1024), }}, }, view: utxoView, mempool: true, want: &SequenceLock{ Seconds: nextMedianTime + 1023, BlockHeight: -1, }, }, } t.Logf("Running %v SequenceLock tests", len(tests)) for i, test := range tests { utilTx := btcutil.NewTx(test.tx) seqLock, err := chain.CalcSequenceLock(utilTx, test.view, test.mempool) if err != nil { t.Fatalf("test #%d, unable to calc sequence lock: %v", i, err) } if seqLock.Seconds != test.want.Seconds { t.Fatalf("test #%d got %v seconds want %v seconds", i, seqLock.Seconds, test.want.Seconds) } if seqLock.BlockHeight != test.want.BlockHeight { t.Fatalf("test #%d got height of %v want height of %v ", i, seqLock.BlockHeight, test.want.BlockHeight) } } } // nodeHashes is a convenience function that returns the hashes for all of the // passed indexes of the provided nodes. It is used to construct expected hash // slices in the tests. func nodeHashes(nodes []*blockNode, indexes ...int) []chainhash.Hash { hashes := make([]chainhash.Hash, 0, len(indexes)) for _, idx := range indexes { hashes = append(hashes, nodes[idx].hash) } return hashes } // nodeHeaders is a convenience function that returns the headers for all of // the passed indexes of the provided nodes. It is used to construct expected // located headers in the tests. func nodeHeaders(nodes []*blockNode, indexes ...int) []wire.BlockHeader { headers := make([]wire.BlockHeader, 0, len(indexes)) for _, idx := range indexes { headers = append(headers, nodes[idx].Header()) } return headers } // TestLocateInventory ensures that locating inventory via the LocateHeaders and // LocateBlocks functions behaves as expected. func TestLocateInventory(t *testing.T) { // Construct a synthetic block chain with a block index consisting of // the following structure. // genesis -> 1 -> 2 -> ... -> 15 -> 16 -> 17 -> 18 // \-> 16a -> 17a tip := tstTip chain := newFakeChain(&chaincfg.MainNetParams) branch0Nodes := chainedNodes(chain.bestChain.Genesis(), 18) branch1Nodes := chainedNodes(branch0Nodes[14], 2) for _, node := range branch0Nodes { chain.index.AddNode(node) } for _, node := range branch1Nodes { chain.index.AddNode(node) } chain.bestChain.SetTip(tip(branch0Nodes)) // Create chain views for different branches of the overall chain to // simulate a local and remote node on different parts of the chain. localView := newChainView(tip(branch0Nodes)) remoteView := newChainView(tip(branch1Nodes)) // Create a chain view for a completely unrelated block chain to // simulate a remote node on a totally different chain. unrelatedBranchNodes := chainedNodes(nil, 5) unrelatedView := newChainView(tip(unrelatedBranchNodes)) tests := []struct { name string locator BlockLocator // locator for requested inventory hashStop chainhash.Hash // stop hash for locator maxAllowed uint32 // max to locate, 0 = wire const headers []wire.BlockHeader // expected located headers hashes []chainhash.Hash // expected located hashes }{ { // Empty block locators and unknown stop hash. No // inventory should be located. name: "no locators, no stop", locator: nil, hashStop: chainhash.Hash{}, headers: nil, hashes: nil, }, { // Empty block locators and stop hash in side chain. // The expected result is the requested block. name: "no locators, stop in side", locator: nil, hashStop: tip(branch1Nodes).hash, headers: nodeHeaders(branch1Nodes, 1), hashes: nodeHashes(branch1Nodes, 1), }, { // Empty block locators and stop hash in main chain. // The expected result is the requested block. name: "no locators, stop in main", locator: nil, hashStop: branch0Nodes[12].hash, headers: nodeHeaders(branch0Nodes, 12), hashes: nodeHashes(branch0Nodes, 12), }, { // Locators based on remote being on side chain and a // stop hash local node doesn't know about. The // expected result is the blocks after the fork point in // the main chain and the stop hash has no effect. name: "remote side chain, unknown stop", locator: remoteView.BlockLocator(nil), hashStop: chainhash.Hash{0x01}, headers: nodeHeaders(branch0Nodes, 15, 16, 17), hashes: nodeHashes(branch0Nodes, 15, 16, 17), }, { // Locators based on remote being on side chain and a // stop hash in side chain. The expected result is the // blocks after the fork point in the main chain and the // stop hash has no effect. name: "remote side chain, stop in side", locator: remoteView.BlockLocator(nil), hashStop: tip(branch1Nodes).hash, headers: nodeHeaders(branch0Nodes, 15, 16, 17), hashes: nodeHashes(branch0Nodes, 15, 16, 17), }, { // Locators based on remote being on side chain and a // stop hash in main chain, but before fork point. The // expected result is the blocks after the fork point in // the main chain and the stop hash has no effect. name: "remote side chain, stop in main before", locator: remoteView.BlockLocator(nil), hashStop: branch0Nodes[13].hash, headers: nodeHeaders(branch0Nodes, 15, 16, 17), hashes: nodeHashes(branch0Nodes, 15, 16, 17), }, { // Locators based on remote being on side chain and a // stop hash in main chain, but exactly at the fork // point. The expected result is the blocks after the // fork point in the main chain and the stop hash has no // effect. name: "remote side chain, stop in main exact", locator: remoteView.BlockLocator(nil), hashStop: branch0Nodes[14].hash, headers: nodeHeaders(branch0Nodes, 15, 16, 17), hashes: nodeHashes(branch0Nodes, 15, 16, 17), }, { // Locators based on remote being on side chain and a // stop hash in main chain just after the fork point. // The expected result is the blocks after the fork // point in the main chain up to and including the stop // hash. name: "remote side chain, stop in main after", locator: remoteView.BlockLocator(nil), hashStop: branch0Nodes[15].hash, headers: nodeHeaders(branch0Nodes, 15), hashes: nodeHashes(branch0Nodes, 15), }, { // Locators based on remote being on side chain and a // stop hash in main chain some time after the fork // point. The expected result is the blocks after the // fork point in the main chain up to and including the // stop hash. name: "remote side chain, stop in main after more", locator: remoteView.BlockLocator(nil), hashStop: branch0Nodes[16].hash, headers: nodeHeaders(branch0Nodes, 15, 16), hashes: nodeHashes(branch0Nodes, 15, 16), }, { // Locators based on remote being on main chain in the // past and a stop hash local node doesn't know about. // The expected result is the blocks after the known // point in the main chain and the stop hash has no // effect. name: "remote main chain past, unknown stop", locator: localView.BlockLocator(branch0Nodes[12]), hashStop: chainhash.Hash{0x01}, headers: nodeHeaders(branch0Nodes, 13, 14, 15, 16, 17), hashes: nodeHashes(branch0Nodes, 13, 14, 15, 16, 17), }, { // Locators based on remote being on main chain in the // past and a stop hash in a side chain. The expected // result is the blocks after the known point in the // main chain and the stop hash has no effect. name: "remote main chain past, stop in side", locator: localView.BlockLocator(branch0Nodes[12]), hashStop: tip(branch1Nodes).hash, headers: nodeHeaders(branch0Nodes, 13, 14, 15, 16, 17), hashes: nodeHashes(branch0Nodes, 13, 14, 15, 16, 17), }, { // Locators based on remote being on main chain in the // past and a stop hash in the main chain before that // point. The expected result is the blocks after the // known point in the main chain and the stop hash has // no effect. name: "remote main chain past, stop in main before", locator: localView.BlockLocator(branch0Nodes[12]), hashStop: branch0Nodes[11].hash, headers: nodeHeaders(branch0Nodes, 13, 14, 15, 16, 17), hashes: nodeHashes(branch0Nodes, 13, 14, 15, 16, 17), }, { // Locators based on remote being on main chain in the // past and a stop hash in the main chain exactly at that // point. The expected result is the blocks after the // known point in the main chain and the stop hash has // no effect. name: "remote main chain past, stop in main exact", locator: localView.BlockLocator(branch0Nodes[12]), hashStop: branch0Nodes[12].hash, headers: nodeHeaders(branch0Nodes, 13, 14, 15, 16, 17), hashes: nodeHashes(branch0Nodes, 13, 14, 15, 16, 17), }, { // Locators based on remote being on main chain in the // past and a stop hash in the main chain just after // that point. The expected result is the blocks after // the known point in the main chain and the stop hash // has no effect. name: "remote main chain past, stop in main after", locator: localView.BlockLocator(branch0Nodes[12]), hashStop: branch0Nodes[13].hash, headers: nodeHeaders(branch0Nodes, 13), hashes: nodeHashes(branch0Nodes, 13), }, { // Locators based on remote being on main chain in the // past and a stop hash in the main chain some time // after that point. The expected result is the blocks // after the known point in the main chain and the stop // hash has no effect. name: "remote main chain past, stop in main after more", locator: localView.BlockLocator(branch0Nodes[12]), hashStop: branch0Nodes[15].hash, headers: nodeHeaders(branch0Nodes, 13, 14, 15), hashes: nodeHashes(branch0Nodes, 13, 14, 15), }, { // Locators based on remote being at exactly the same // point in the main chain and a stop hash local node // doesn't know about. The expected result is no // located inventory. name: "remote main chain same, unknown stop", locator: localView.BlockLocator(nil), hashStop: chainhash.Hash{0x01}, headers: nil, hashes: nil, }, { // Locators based on remote being at exactly the same // point in the main chain and a stop hash at exactly // the same point. The expected result is no located // inventory. name: "remote main chain same, stop same point", locator: localView.BlockLocator(nil), hashStop: tip(branch0Nodes).hash, headers: nil, hashes: nil, }, { // Locators from remote that don't include any blocks // the local node knows. This would happen if the // remote node is on a completely separate chain that // isn't rooted with the same genesis block. The // expected result is the blocks after the genesis // block. name: "remote unrelated chain", locator: unrelatedView.BlockLocator(nil), hashStop: chainhash.Hash{}, headers: nodeHeaders(branch0Nodes, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17), hashes: nodeHashes(branch0Nodes, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17), }, { // Locators from remote for second block in main chain // and no stop hash, but with an overridden max limit. // The expected result is the blocks after the second // block limited by the max. name: "remote genesis", locator: locatorHashes(branch0Nodes, 0), hashStop: chainhash.Hash{}, maxAllowed: 3, headers: nodeHeaders(branch0Nodes, 1, 2, 3), hashes: nodeHashes(branch0Nodes, 1, 2, 3), }, { // Poorly formed locator. // // Locator from remote that only includes a single // block on a side chain the local node knows. The // expected result is the blocks after the genesis // block since even though the block is known, it is on // a side chain and there are no more locators to find // the fork point. name: "weak locator, single known side block", locator: locatorHashes(branch1Nodes, 1), hashStop: chainhash.Hash{}, headers: nodeHeaders(branch0Nodes, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17), hashes: nodeHashes(branch0Nodes, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17), }, { // Poorly formed locator. // // Locator from remote that only includes multiple // blocks on a side chain the local node knows however // none in the main chain. The expected result is the // blocks after the genesis block since even though the // blocks are known, they are all on a side chain and // there are no more locators to find the fork point. name: "weak locator, multiple known side blocks", locator: locatorHashes(branch1Nodes, 1), hashStop: chainhash.Hash{}, headers: nodeHeaders(branch0Nodes, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17), hashes: nodeHashes(branch0Nodes, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17), }, { // Poorly formed locator. // // Locator from remote that only includes multiple // blocks on a side chain the local node knows however // none in the main chain but includes a stop hash in // the main chain. The expected result is the blocks // after the genesis block up to the stop hash since // even though the blocks are known, they are all on a // side chain and there are no more locators to find the // fork point. name: "weak locator, multiple known side blocks, stop in main", locator: locatorHashes(branch1Nodes, 1), hashStop: branch0Nodes[5].hash, headers: nodeHeaders(branch0Nodes, 0, 1, 2, 3, 4, 5), hashes: nodeHashes(branch0Nodes, 0, 1, 2, 3, 4, 5), }, } for _, test := range tests { // Ensure the expected headers are located. var headers []wire.BlockHeader if test.maxAllowed != 0 { // Need to use the unexported function to override the // max allowed for headers. chain.chainLock.RLock() headers = chain.locateHeaders(test.locator, &test.hashStop, test.maxAllowed) chain.chainLock.RUnlock() } else { headers = chain.LocateHeaders(test.locator, &test.hashStop) } if !reflect.DeepEqual(headers, test.headers) { t.Errorf("%s: unexpected headers -- got %v, want %v", test.name, headers, test.headers) continue } // Ensure the expected block hashes are located. maxAllowed := uint32(wire.MaxBlocksPerMsg) if test.maxAllowed != 0 { maxAllowed = test.maxAllowed } hashes := chain.LocateBlocks(test.locator, &test.hashStop, maxAllowed) if !reflect.DeepEqual(hashes, test.hashes) { t.Errorf("%s: unexpected hashes -- got %v, want %v", test.name, hashes, test.hashes) continue } } } // TestHeightToHashRange ensures that fetching a range of block hashes by start // height and end hash works as expected. func TestHeightToHashRange(t *testing.T) { // Construct a synthetic block chain with a block index consisting of // the following structure. // genesis -> 1 -> 2 -> ... -> 15 -> 16 -> 17 -> 18 // \-> 16a -> 17a -> 18a (unvalidated) tip := tstTip chain := newFakeChain(&chaincfg.MainNetParams) branch0Nodes := chainedNodes(chain.bestChain.Genesis(), 18) branch1Nodes := chainedNodes(branch0Nodes[14], 3) for _, node := range branch0Nodes { chain.index.SetStatusFlags(node, statusValid) chain.index.AddNode(node) } for _, node := range branch1Nodes { if node.height < 18 { chain.index.SetStatusFlags(node, statusValid) } chain.index.AddNode(node) } chain.bestChain.SetTip(tip(branch0Nodes)) tests := []struct { name string startHeight int32 // locator for requested inventory endHash chainhash.Hash // stop hash for locator maxResults int // max to locate, 0 = wire const hashes []chainhash.Hash // expected located hashes expectError bool }{ { name: "blocks below tip", startHeight: 11, endHash: branch0Nodes[14].hash, maxResults: 10, hashes: nodeHashes(branch0Nodes, 10, 11, 12, 13, 14), }, { name: "blocks on main chain", startHeight: 15, endHash: branch0Nodes[17].hash, maxResults: 10, hashes: nodeHashes(branch0Nodes, 14, 15, 16, 17), }, { name: "blocks on stale chain", startHeight: 15, endHash: branch1Nodes[1].hash, maxResults: 10, hashes: append(nodeHashes(branch0Nodes, 14), nodeHashes(branch1Nodes, 0, 1)...), }, { name: "invalid start height", startHeight: 19, endHash: branch0Nodes[17].hash, maxResults: 10, expectError: true, }, { name: "too many results", startHeight: 1, endHash: branch0Nodes[17].hash, maxResults: 10, expectError: true, }, { name: "unvalidated block", startHeight: 15, endHash: branch1Nodes[2].hash, maxResults: 10, expectError: true, }, } for _, test := range tests { hashes, err := chain.HeightToHashRange(test.startHeight, &test.endHash, test.maxResults) if err != nil { if !test.expectError { t.Errorf("%s: unexpected error: %v", test.name, err) } continue } if !reflect.DeepEqual(hashes, test.hashes) { t.Errorf("%s: unexpected hashes -- got %v, want %v", test.name, hashes, test.hashes) } } } // TestIntervalBlockHashes ensures that fetching block hashes at specified // intervals by end hash works as expected. func TestIntervalBlockHashes(t *testing.T) { // Construct a synthetic block chain with a block index consisting of // the following structure. // genesis -> 1 -> 2 -> ... -> 15 -> 16 -> 17 -> 18 // \-> 16a -> 17a -> 18a (unvalidated) tip := tstTip chain := newFakeChain(&chaincfg.MainNetParams) branch0Nodes := chainedNodes(chain.bestChain.Genesis(), 18) branch1Nodes := chainedNodes(branch0Nodes[14], 3) for _, node := range branch0Nodes { chain.index.SetStatusFlags(node, statusValid) chain.index.AddNode(node) } for _, node := range branch1Nodes { if node.height < 18 { chain.index.SetStatusFlags(node, statusValid) } chain.index.AddNode(node) } chain.bestChain.SetTip(tip(branch0Nodes)) tests := []struct { name string endHash chainhash.Hash interval int hashes []chainhash.Hash expectError bool }{ { name: "blocks on main chain", endHash: branch0Nodes[17].hash, interval: 8, hashes: nodeHashes(branch0Nodes, 7, 15), }, { name: "blocks on stale chain", endHash: branch1Nodes[1].hash, interval: 8, hashes: append(nodeHashes(branch0Nodes, 7), nodeHashes(branch1Nodes, 0)...), }, { name: "no results", endHash: branch0Nodes[17].hash, interval: 20, hashes: []chainhash.Hash{}, }, { name: "unvalidated block", endHash: branch1Nodes[2].hash, interval: 8, expectError: true, }, } for _, test := range tests { hashes, err := chain.IntervalBlockHashes(&test.endHash, test.interval) if err != nil { if !test.expectError { t.Errorf("%s: unexpected error: %v", test.name, err) } continue } if !reflect.DeepEqual(hashes, test.hashes) { t.Errorf("%s: unexpected hashes -- got %v, want %v", test.name, hashes, test.hashes) } } } func TestChainTips(t *testing.T) { tests := []struct { name string chainTipGen func() (*BlockChain, map[chainhash.Hash]ChainTip) }{ { name: "one active chain tip", chainTipGen: func() (*BlockChain, map[chainhash.Hash]ChainTip) { // Construct a synthetic block chain with a block index consisting of // the following structure. // genesis -> 1 -> 2 -> 3 tip := tstTip chain := newFakeChain(&chaincfg.MainNetParams) branch0Nodes := chainedNodes(chain.bestChain.Genesis(), 3) for _, node := range branch0Nodes { chain.index.SetStatusFlags(node, statusDataStored) chain.index.SetStatusFlags(node, statusValid) chain.index.AddNode(node) } chain.bestChain.SetTip(tip(branch0Nodes)) activeTip := ChainTip{ Height: 3, BlockHash: (tip(branch0Nodes)).hash, BranchLen: 0, Status: StatusActive, } chainTips := make(map[chainhash.Hash]ChainTip) chainTips[activeTip.BlockHash] = activeTip return chain, chainTips }, }, { name: "one active chain tip, one unknown chain tip", chainTipGen: func() (*BlockChain, map[chainhash.Hash]ChainTip) { // Construct a synthetic block chain with a block index consisting of // the following structure. // genesis -> 1 -> 2 -> 3 ... -> 10 -> 11 -> 12 -> 13 (active) // \-> 11a -> 12a (unknown) tip := tstTip chain := newFakeChain(&chaincfg.MainNetParams) branch0Nodes := chainedNodes(chain.bestChain.Genesis(), 13) for _, node := range branch0Nodes { chain.index.SetStatusFlags(node, statusDataStored) chain.index.SetStatusFlags(node, statusValid) chain.index.AddNode(node) } chain.bestChain.SetTip(tip(branch0Nodes)) branch1Nodes := chainedNodes(branch0Nodes[9], 2) for _, node := range branch1Nodes { chain.index.AddNode(node) } activeTip := ChainTip{ Height: 13, BlockHash: (tip(branch0Nodes)).hash, BranchLen: 0, Status: StatusActive, } unknownTip := ChainTip{ Height: 12, BlockHash: (tip(branch1Nodes)).hash, BranchLen: 2, Status: StatusUnknown, } chainTips := make(map[chainhash.Hash]ChainTip) chainTips[activeTip.BlockHash] = activeTip chainTips[unknownTip.BlockHash] = unknownTip return chain, chainTips }, }, { name: "1 inactive tip, 1 invalid tip, 1 active tip", chainTipGen: func() (*BlockChain, map[chainhash.Hash]ChainTip) { // Construct a synthetic block chain with a block index consisting of // the following structure. // genesis -> 1 -> 2 -> 3 (active) // \ -> 1a (valid-fork) // \ -> 1b (invalid) tip := tstTip chain := newFakeChain(&chaincfg.MainNetParams) branch0Nodes := chainedNodes(chain.bestChain.Genesis(), 3) for _, node := range branch0Nodes { chain.index.SetStatusFlags(node, statusDataStored) chain.index.SetStatusFlags(node, statusValid) chain.index.AddNode(node) } chain.bestChain.SetTip(tip(branch0Nodes)) branch1Nodes := chainedNodes(chain.bestChain.Genesis(), 1) for _, node := range branch1Nodes { chain.index.SetStatusFlags(node, statusDataStored) chain.index.SetStatusFlags(node, statusValid) chain.index.AddNode(node) } branch2Nodes := chainedNodes(chain.bestChain.Genesis(), 1) for _, node := range branch2Nodes { chain.index.SetStatusFlags(node, statusDataStored) chain.index.SetStatusFlags(node, statusValidateFailed) chain.index.AddNode(node) } activeTip := ChainTip{ Height: tip(branch0Nodes).height, BlockHash: (tip(branch0Nodes)).hash, BranchLen: 0, Status: StatusActive, } inactiveTip := ChainTip{ Height: tip(branch1Nodes).height, BlockHash: (tip(branch1Nodes)).hash, BranchLen: 1, Status: StatusValidFork, } invalidTip := ChainTip{ Height: tip(branch2Nodes).height, BlockHash: (tip(branch2Nodes)).hash, BranchLen: 1, Status: StatusInvalid, } chainTips := make(map[chainhash.Hash]ChainTip) chainTips[activeTip.BlockHash] = activeTip chainTips[inactiveTip.BlockHash] = inactiveTip chainTips[invalidTip.BlockHash] = invalidTip return chain, chainTips }, }, } for _, test := range tests { chain, expectedChainTips := test.chainTipGen() gotChainTips := chain.ChainTips() if len(gotChainTips) != len(expectedChainTips) { t.Errorf("TestChainTips Failed test %s. Expected %d "+ "chain tips, got %d", test.name, len(expectedChainTips), len(gotChainTips)) } for _, gotChainTip := range gotChainTips { testChainTip, found := expectedChainTips[gotChainTip.BlockHash] if !found { t.Errorf("TestChainTips Failed test %s. Couldn't find an expected "+ "chain tip with height %d, hash %s, branchlen %d, status \"%s\"", test.name, testChainTip.Height, testChainTip.BlockHash.String(), testChainTip.BranchLen, testChainTip.Status.String()) } if !reflect.DeepEqual(testChainTip, gotChainTip) { t.Errorf("TestChainTips Failed test %s. Expected chain tip with "+ "height %d, hash %s, branchlen %d, status \"%s\" but got "+ "height %d, hash %s, branchlen %d, status \"%s\"", test.name, testChainTip.Height, testChainTip.BlockHash.String(), testChainTip.BranchLen, testChainTip.Status.String(), gotChainTip.Height, gotChainTip.BlockHash.String(), gotChainTip.BranchLen, gotChainTip.Status.String()) } switch testChainTip.Status { case StatusActive: if testChainTip.Status.String() != "active" { t.Errorf("TestChainTips Fail: Expected string of \"active\", got \"%s\"", testChainTip.Status.String()) } case StatusInvalid: if testChainTip.Status.String() != "invalid" { t.Errorf("TestChainTips Fail: Expected string of \"invalid\", got \"%s\"", testChainTip.Status.String()) } case StatusValidFork: if testChainTip.Status.String() != "valid-fork" { t.Errorf("TestChainTips Fail: Expected string of \"valid-fork\", got \"%s\"", testChainTip.Status.String()) } case StatusUnknown: if testChainTip.Status.String() != fmt.Sprintf("unknown: %b", testChainTip.Status) { t.Errorf("TestChainTips Fail: Expected string of \"unknown\", got \"%s\"", testChainTip.Status.String()) } } } } } func TestIsAncestor(t *testing.T) { // Construct a synthetic block chain with a block index consisting of // the following structure. // genesis -> 1 -> 2 -> 3 (active) // \ -> 1a (valid-fork) // \ -> 1b (invalid) tip := tstTip chain := newFakeChain(&chaincfg.MainNetParams) branch0Nodes := chainedNodes(chain.bestChain.Genesis(), 3) for _, node := range branch0Nodes { chain.index.SetStatusFlags(node, statusDataStored) chain.index.SetStatusFlags(node, statusValid) chain.index.AddNode(node) } chain.bestChain.SetTip(tip(branch0Nodes)) branch1Nodes := chainedNodes(chain.bestChain.Genesis(), 1) for _, node := range branch1Nodes { chain.index.SetStatusFlags(node, statusDataStored) chain.index.SetStatusFlags(node, statusValid) chain.index.AddNode(node) } branch2Nodes := chainedNodes(chain.bestChain.Genesis(), 1) for _, node := range branch2Nodes { chain.index.SetStatusFlags(node, statusDataStored) chain.index.SetStatusFlags(node, statusValidateFailed) chain.index.AddNode(node) } // Is 1 an ancestor of 3? // // genesis -> 1 -> 2 -> 3 (active) // \ -> 1a (valid-fork) // \ -> 1b (invalid) shouldBeTrue := branch0Nodes[2].IsAncestor(branch0Nodes[0]) if !shouldBeTrue { t.Errorf("TestIsAncestor fail. Node %s is an ancestor of node %s but got false", branch0Nodes[0].hash.String(), branch0Nodes[2].hash.String()) } // Is 1 an ancestor of 2? // // genesis -> 1 -> 2 -> 3 (active) // \ -> 1a (valid-fork) // \ -> 1b (invalid) shouldBeTrue = branch0Nodes[1].IsAncestor(branch0Nodes[0]) if !shouldBeTrue { t.Errorf("TestIsAncestor fail. Node %s is an ancestor of node %s but got false", branch0Nodes[0].hash.String(), branch0Nodes[1].hash.String()) } // Is the genesis an ancestor of 1? // // genesis -> 1 -> 2 -> 3 (active) // \ -> 1a (valid-fork) // \ -> 1b (invalid) shouldBeTrue = branch0Nodes[0].IsAncestor(chain.bestChain.Genesis()) if !shouldBeTrue { t.Errorf("TestIsAncestor fail. The genesis block is an ancestor of all blocks "+ "but got false for node %s", branch0Nodes[0].hash.String()) } // Is the genesis an ancestor of 1a? // // genesis -> 1 -> 2 -> 3 (active) // \ -> 1a (valid-fork) // \ -> 1b (invalid) shouldBeTrue = branch1Nodes[0].IsAncestor(chain.bestChain.Genesis()) if !shouldBeTrue { t.Errorf("TestIsAncestor fail. The genesis block is an ancestor of all blocks "+ "but got false for node %s", branch1Nodes[0].hash.String()) } // Is the genesis an ancestor of 1b? // // genesis -> 1 -> 2 -> 3 (active) // \ -> 1a (valid-fork) // \ -> 1b (invalid) shouldBeTrue = branch2Nodes[0].IsAncestor(chain.bestChain.Genesis()) if !shouldBeTrue { t.Errorf("TestIsAncestor fail. The genesis block is an ancestor of all blocks "+ "but got false for node %s", branch2Nodes[0].hash.String()) } // Is 1 an ancestor of 1a? // // genesis -> 1 -> 2 -> 3 (active) // \ -> 1a (valid-fork) // \ -> 1b (invalid) shouldBeFalse := branch1Nodes[0].IsAncestor(branch0Nodes[0]) if shouldBeFalse { t.Errorf("TestIsAncestor fail. Node %s is in a different branch than "+ "node %s but got true", branch1Nodes[0].hash.String(), branch0Nodes[0].hash.String()) } // Is 1 an ancestor of 1b? // // genesis -> 1 -> 2 -> 3 (active) // \ -> 1a (valid-fork) // \ -> 1b (invalid) shouldBeFalse = branch2Nodes[0].IsAncestor(branch0Nodes[0]) if shouldBeFalse { t.Errorf("TestIsAncestor fail. Node %s is in a different branch than "+ "node %s but got true", branch2Nodes[0].hash.String(), branch0Nodes[0].hash.String()) } // Is 1a an ancestor of 1b? // // genesis -> 1 -> 2 -> 3 (active) // \ -> 1a (valid-fork) // \ -> 1b (invalid) shouldBeFalse = branch2Nodes[0].IsAncestor(branch1Nodes[0]) if shouldBeFalse { t.Errorf("TestIsAncestor fail. Node %s is in a different branch than "+ "node %s but got true", branch2Nodes[0].hash.String(), branch1Nodes[0].hash.String()) } // Is 1 an ancestor of 1? // // genesis -> 1 -> 2 -> 3 (active) // \ -> 1a (valid-fork) // \ -> 1b (invalid) shouldBeFalse = branch0Nodes[0].IsAncestor(branch0Nodes[0]) if shouldBeFalse { t.Errorf("TestIsAncestor fail. Node is not an ancestor of itself but got true for node %s", branch0Nodes[0].hash.String()) } // Is the geneis an ancestor of genesis? // // genesis -> 1 -> 2 -> 3 (active) // \ -> 1a (valid-fork) // \ -> 1b (invalid) shouldBeFalse = chain.bestChain.Genesis().IsAncestor(chain.bestChain.Genesis()) if shouldBeFalse { t.Errorf("TestIsAncestor fail. Node is not an ancestor of itself but got true for node %s", chain.bestChain.Genesis().hash.String()) } // Is a block from another chain an ancestor of 1b? fakeChain := newFakeChain(&chaincfg.TestNet3Params) shouldBeFalse = branch2Nodes[0].IsAncestor(fakeChain.bestChain.Genesis()) if shouldBeFalse { t.Errorf("TestIsAncestor fail. Node %s is in a different chain than "+ "node %s but got true", fakeChain.bestChain.Genesis().hash.String(), branch2Nodes[0].hash.String()) } } // randomSelect selects random amount of random elements from a slice and returns a // new slice. The selected elements are removed. func randomSelect(input []*testhelper.SpendableOut) ( []*testhelper.SpendableOut, []*testhelper.SpendableOut) { selected := []*testhelper.SpendableOut{} // Select random elements from the input slice amount := rand.Intn(len(input)) for i := 0; i < amount; i++ { // Generate a random index randIdx := rand.Intn(len(input)) // Append the selected element to the new slice selected = append(selected, input[randIdx]) // Remove the selected element from the input slice. // This ensures that each selected element is unique. input = append(input[:randIdx], input[randIdx+1:]...) } return input, selected } // addBlocks generates new blocks and adds them to the chain. The newly generated // blocks will spend from the spendable outputs passed in. The returned hases are // the hashes of the newly generated blocks. func addBlocks(count int, chain *BlockChain, prevBlock *btcutil.Block, allSpendableOutputs []*testhelper.SpendableOut) ( []*chainhash.Hash, [][]*testhelper.SpendableOut, error) { blockHashes := make([]*chainhash.Hash, 0, count) spendablesOuts := make([][]*testhelper.SpendableOut, 0, count) // Always spend everything on the first block. This ensures we get unique blocks // every time. The random select may choose not to spend any and that results // in getting the same block. nextSpends := allSpendableOutputs allSpendableOutputs = allSpendableOutputs[:0] for b := 0; b < count; b++ { newBlock, newSpendableOuts, err := addBlock(chain, prevBlock, nextSpends) if err != nil { return nil, nil, err } prevBlock = newBlock blockHashes = append(blockHashes, newBlock.Hash()) spendablesOuts = append(spendablesOuts, newSpendableOuts) allSpendableOutputs = append(allSpendableOutputs, newSpendableOuts...) // Grab utxos to be spent in the next block. allSpendableOutputs, nextSpends = randomSelect(allSpendableOutputs) } return blockHashes, spendablesOuts, nil } func TestInvalidateBlock(t *testing.T) { tests := []struct { name string chainGen func() (*BlockChain, []*chainhash.Hash, func()) }{ { name: "one branch, invalidate once", chainGen: func() (*BlockChain, []*chainhash.Hash, func()) { chain, params, tearDown := utxoCacheTestChain( "TestInvalidateBlock-one-branch-" + "invalidate-once") // Grab the tip of the chain. tip := btcutil.NewBlock(params.GenesisBlock) // Create a chain with 11 blocks. _, _, err := addBlocks(11, chain, tip, []*testhelper.SpendableOut{}) if err != nil { t.Fatal(err) } // Invalidate block 5. block, err := chain.BlockByHeight(5) if err != nil { t.Fatal(err) } invalidateHash := block.Hash() return chain, []*chainhash.Hash{invalidateHash}, tearDown }, }, { name: "invalidate twice", chainGen: func() (*BlockChain, []*chainhash.Hash, func()) { chain, params, tearDown := utxoCacheTestChain("TestInvalidateBlock-invalidate-twice") // Grab the tip of the chain. tip := btcutil.NewBlock(params.GenesisBlock) // Create a chain with 11 blocks. _, spendableOuts, err := addBlocks(11, chain, tip, []*testhelper.SpendableOut{}) //_, _, err := addBlocks(11, chain, tip, []*testhelper.SpendableOut{}) if err != nil { t.Fatal(err) } // Set invalidateHash as block 5. block, err := chain.BlockByHeight(5) if err != nil { t.Fatal(err) } invalidateHash := block.Hash() // Create a side chain with 7 blocks that builds on block 1. b1, err := chain.BlockByHeight(1) if err != nil { t.Fatal(err) } altBlockHashes, _, err := addBlocks(6, chain, b1, spendableOuts[0]) if err != nil { t.Fatal(err) } // Grab block at height 5: // // b2, b3, b4, b5 // 0, 1, 2, 3 invalidateHash2 := altBlockHashes[3] // Sanity checking that we grabbed the correct hash. node := chain.index.LookupNode(invalidateHash) if node == nil || node.height != 5 { t.Fatalf("wanted to grab block at height 5 but got height %v", node.height) } return chain, []*chainhash.Hash{invalidateHash, invalidateHash2}, tearDown }, }, { name: "invalidate a side branch", chainGen: func() (*BlockChain, []*chainhash.Hash, func()) { chain, params, tearDown := utxoCacheTestChain("TestInvalidateBlock-invalidate-side-branch") tip := btcutil.NewBlock(params.GenesisBlock) // Grab the tip of the chain. tip, err := chain.BlockByHash(&chain.bestChain.Tip().hash) if err != nil { t.Fatal(err) } // Create a chain with 11 blocks. _, spendableOuts, err := addBlocks(11, chain, tip, []*testhelper.SpendableOut{}) if err != nil { t.Fatal(err) } // Create a side chain with 7 blocks that builds on block 1. b1, err := chain.BlockByHeight(1) if err != nil { t.Fatal(err) } altBlockHashes, _, err := addBlocks(6, chain, b1, spendableOuts[0]) if err != nil { t.Fatal(err) } // Grab block at height 4: // // b2, b3, b4 // 0, 1, 2 invalidateHash := altBlockHashes[2] // Sanity checking that we grabbed the correct hash. node := chain.index.LookupNode(invalidateHash) if node == nil || node.height != 4 { t.Fatalf("wanted to grab block at height 4 but got height %v", node.height) } return chain, []*chainhash.Hash{invalidateHash}, tearDown }, }, } for _, test := range tests { chain, invalidateHashes, tearDown := test.chainGen() func() { defer tearDown() for _, invalidateHash := range invalidateHashes { chainTipsBefore := chain.ChainTips() // Mark if we're invalidating a block that's a part of the best chain. var bestChainBlock bool node := chain.index.LookupNode(invalidateHash) if chain.bestChain.Contains(node) { bestChainBlock = true } // Actual invalidation. err := chain.InvalidateBlock(invalidateHash) if err != nil { t.Fatal(err) } chainTipsAfter := chain.ChainTips() // Create a map for easy lookup. chainTipMap := make(map[chainhash.Hash]ChainTip, len(chainTipsAfter)) activeTipCount := 0 for _, chainTip := range chainTipsAfter { chainTipMap[chainTip.BlockHash] = chainTip if chainTip.Status == StatusActive { activeTipCount++ } } if activeTipCount != 1 { t.Fatalf("TestInvalidateBlock fail. Expected "+ "1 active chain tip but got %d", activeTipCount) } bestTip := chain.bestChain.Tip() validForkCount := 0 for _, tip := range chainTipsBefore { // If the chaintip was an active tip and we invalidated a block // in the active tip, assert that it's invalid now. if bestChainBlock && tip.Status == StatusActive { gotTip, found := chainTipMap[tip.BlockHash] if !found { t.Fatalf("TestInvalidateBlock fail. Expected "+ "block %s not found in chaintips after "+ "invalidateblock", tip.BlockHash.String()) } if gotTip.Status != StatusInvalid { t.Fatalf("TestInvalidateBlock fail. "+ "Expected block %s to be invalid, got status: %s", gotTip.BlockHash.String(), gotTip.Status) } } if !bestChainBlock && tip.Status != StatusActive { gotTip, found := chainTipMap[tip.BlockHash] if !found { t.Fatalf("TestInvalidateBlock fail. Expected "+ "block %s not found in chaintips after "+ "invalidateblock", tip.BlockHash.String()) } if gotTip.BlockHash == *invalidateHash && gotTip.Status != StatusInvalid { t.Fatalf("TestInvalidateBlock fail. "+ "Expected block %s to be invalid, got status: %s", gotTip.BlockHash.String(), gotTip.Status) } } // If we're not invalidating the branch with an active tip, // we expect the active tip to remain the same. if !bestChainBlock && tip.Status == StatusActive && tip.BlockHash != bestTip.hash { t.Fatalf("TestInvalidateBlock fail. Expected block %s as the tip but got %s", tip.BlockHash.String(), bestTip.hash.String()) } // If this tip is not invalid and not active, it should be // lighter than the current best tip. if tip.Status != StatusActive && tip.Status != StatusInvalid && tip.Height > bestTip.height { tipNode := chain.index.LookupNode(&tip.BlockHash) if bestTip.workSum.Cmp(tipNode.workSum) == -1 { t.Fatalf("TestInvalidateBlock fail. Expected "+ "block %s to be the active tip but block %s "+ "was", tipNode.hash.String(), bestTip.hash.String()) } } if tip.Status == StatusValidFork { validForkCount++ } } // If there are no other valid chain tips besides the active chaintip, // we expect to have one more chain tip after the invalidate. if validForkCount == 0 && len(chainTipsAfter) != len(chainTipsBefore)+1 { t.Fatalf("TestInvalidateBlock fail. Expected %d chaintips but got %d", len(chainTipsBefore)+1, len(chainTipsAfter)) } } // Try to invaliate the already invalidated hash. err := chain.InvalidateBlock(invalidateHashes[0]) if err != nil { t.Fatal(err) } // Try to invaliate a genesis block err = chain.InvalidateBlock(chain.chainParams.GenesisHash) if err == nil { t.Fatalf("TestInvalidateBlock fail. Expected to err when trying to" + "invalidate a genesis block.") } // Try to invaliate a block that doesn't exist. err = chain.InvalidateBlock(chaincfg.MainNetParams.GenesisHash) if err == nil { t.Fatalf("TestInvalidateBlock fail. Expected to err when trying to" + "invalidate a block that doesn't exist.") } }() } } func TestReconsiderBlock(t *testing.T) { tests := []struct { name string chainGen func() (*BlockChain, []*chainhash.Hash, func()) }{ { name: "one branch, invalidate once and revalidate", chainGen: func() (*BlockChain, []*chainhash.Hash, func()) { chain, params, tearDown := utxoCacheTestChain("TestInvalidateBlock-one-branch-invalidate-once") // Create a chain with 101 blocks. tip := btcutil.NewBlock(params.GenesisBlock) _, _, err := addBlocks(101, chain, tip, []*testhelper.SpendableOut{}) if err != nil { t.Fatal(err) } // Invalidate block 5. block, err := chain.BlockByHeight(5) if err != nil { t.Fatal(err) } invalidateHash := block.Hash() return chain, []*chainhash.Hash{invalidateHash}, tearDown }, }, { name: "invalidate the active branch with a side branch present and revalidate", chainGen: func() (*BlockChain, []*chainhash.Hash, func()) { chain, params, tearDown := utxoCacheTestChain("TestReconsiderBlock-invalidate-with-side-branch") // Create a chain with 101 blocks. tip := btcutil.NewBlock(params.GenesisBlock) _, spendableOuts, err := addBlocks(101, chain, tip, []*testhelper.SpendableOut{}) if err != nil { t.Fatal(err) } // Invalidate block 5. block, err := chain.BlockByHeight(5) if err != nil { t.Fatal(err) } invalidateHash := block.Hash() // Create a side chain with 7 blocks that builds on block 1. b1, err := chain.BlockByHeight(1) if err != nil { t.Fatal(err) } _, _, err = addBlocks(6, chain, b1, spendableOuts[0]) if err != nil { t.Fatal(err) } return chain, []*chainhash.Hash{invalidateHash}, tearDown }, }, { name: "invalidate a side branch and revalidate it", chainGen: func() (*BlockChain, []*chainhash.Hash, func()) { chain, params, tearDown := utxoCacheTestChain("TestReconsiderBlock-invalidate-a-side-branch") // Create a chain with 101 blocks. tip := btcutil.NewBlock(params.GenesisBlock) _, spendableOuts, err := addBlocks(101, chain, tip, []*testhelper.SpendableOut{}) if err != nil { t.Fatal(err) } // Create a side chain with 7 blocks that builds on block 1. b1, err := chain.BlockByHeight(1) if err != nil { t.Fatal(err) } altBlockHashes, _, err := addBlocks(6, chain, b1, spendableOuts[0]) if err != nil { t.Fatal(err) } // Grab block at height 4: // // b2, b3, b4, b5 // 0, 1, 2, 3 invalidateHash := altBlockHashes[2] return chain, []*chainhash.Hash{invalidateHash}, tearDown }, }, { name: "reconsider an invalid side branch with a higher work", chainGen: func() (*BlockChain, []*chainhash.Hash, func()) { chain, params, tearDown := utxoCacheTestChain("TestReconsiderBlock-reconsider-an-invalid-side-branch-higher") tip := btcutil.NewBlock(params.GenesisBlock) _, spendableOuts, err := addBlocks(6, chain, tip, []*testhelper.SpendableOut{}) if err != nil { t.Fatal(err) } // Select utxos to be spent from the best block and // modify the amount so that the block will be invalid. nextSpends, _ := randomSelect(spendableOuts[len(spendableOuts)-1]) nextSpends[0].Amount += testhelper.LowFee // Make an invalid block that best on top of the current tip. bestBlock, err := chain.BlockByHash(&chain.BestSnapshot().Hash) if err != nil { t.Fatal(err) } invalidBlock, _, _ := newBlock(chain, bestBlock, nextSpends) invalidateHash := invalidBlock.Hash() // The block validation will fail here and we'll mark the // block as invalid in the block index. chain.ProcessBlock(invalidBlock, BFNone) // Modify the amount again so it's valid. nextSpends[0].Amount -= testhelper.LowFee return chain, []*chainhash.Hash{invalidateHash}, tearDown }, }, { name: "reconsider an invalid side branch with a lower work", chainGen: func() (*BlockChain, []*chainhash.Hash, func()) { chain, params, tearDown := utxoCacheTestChain("TestReconsiderBlock-reconsider-an-invalid-side-branch-lower") tip := btcutil.NewBlock(params.GenesisBlock) _, spendableOuts, err := addBlocks(6, chain, tip, []*testhelper.SpendableOut{}) if err != nil { t.Fatal(err) } // Select utxos to be spent from the best block and // modify the amount so that the block will be invalid. nextSpends, _ := randomSelect(spendableOuts[len(spendableOuts)-1]) nextSpends[0].Amount += testhelper.LowFee // Make an invalid block that best on top of the current tip. bestBlock, err := chain.BlockByHash(&chain.BestSnapshot().Hash) if err != nil { t.Fatal(err) } invalidBlock, _, _ := newBlock(chain, bestBlock, nextSpends) invalidateHash := invalidBlock.Hash() // The block validation will fail here and we'll mark the // block as invalid in the block index. chain.ProcessBlock(invalidBlock, BFNone) // Modify the amount again so it's valid. nextSpends[0].Amount -= testhelper.LowFee // Add more blocks to make the invalid block a // side chain and not the most pow. _, _, err = addBlocks(3, chain, bestBlock, []*testhelper.SpendableOut{}) if err != nil { t.Fatal(err) } return chain, []*chainhash.Hash{invalidateHash}, tearDown }, }, } for _, test := range tests { chain, invalidateHashes, tearDown := test.chainGen() func() { defer tearDown() for _, invalidateHash := range invalidateHashes { // Cache the chain tips before the invalidate. Since we'll reconsider // the invalidated block, we should come back to these tips in the end. tips := chain.ChainTips() expectedChainTips := make(map[chainhash.Hash]ChainTip, len(tips)) for _, tip := range tips { expectedChainTips[tip.BlockHash] = tip } // Invalidation. err := chain.InvalidateBlock(invalidateHash) if err != nil { t.Fatal(err) } // Reconsideration. err = chain.ReconsiderBlock(invalidateHash) if err != nil { t.Fatal(err) } // Compare the tips aginst the tips we've cached. gotChainTips := chain.ChainTips() for _, gotChainTip := range gotChainTips { testChainTip, found := expectedChainTips[gotChainTip.BlockHash] if !found { t.Errorf("TestReconsiderBlock Failed test \"%s\". Couldn't find an expected "+ "chain tip with height %d, hash %s, branchlen %d, status \"%s\"", test.name, testChainTip.Height, testChainTip.BlockHash.String(), testChainTip.BranchLen, testChainTip.Status.String()) } // If the invalid side branch is a lower work, we'll never // actually process the block again until the branch becomes // a greater work chain so it'll show up as valid-fork. if test.name == "reconsider an invalid side branch with a lower work" && testChainTip.BlockHash == *invalidateHash { testChainTip.Status = StatusValidFork } if !reflect.DeepEqual(testChainTip, gotChainTip) { t.Errorf("TestReconsiderBlock Failed test \"%s\". Expected chain tip with "+ "height %d, hash %s, branchlen %d, status \"%s\" but got "+ "height %d, hash %s, branchlen %d, status \"%s\"", test.name, testChainTip.Height, testChainTip.BlockHash.String(), testChainTip.BranchLen, testChainTip.Status.String(), gotChainTip.Height, gotChainTip.BlockHash.String(), gotChainTip.BranchLen, gotChainTip.Status.String()) } } } }() } } ================================================ FILE: blockchain/chainio.go ================================================ // Copyright (c) 2015-2017 The btcsuite developers // Use of this source code is governed by an ISC // license that can be found in the LICENSE file. package blockchain import ( "bytes" "encoding/binary" "fmt" "math/big" "sync" "time" "github.com/btcsuite/btcd/btcutil" "github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/btcsuite/btcd/database" "github.com/btcsuite/btcd/wire" ) const ( // blockHdrSize is the size of a block header. This is simply the // constant from wire and is only provided here for convenience since // wire.MaxBlockHeaderPayload is quite long. blockHdrSize = wire.MaxBlockHeaderPayload // latestUtxoSetBucketVersion is the current version of the utxo set // bucket that is used to track all unspent outputs. latestUtxoSetBucketVersion = 2 // latestSpendJournalBucketVersion is the current version of the spend // journal bucket that is used to track all spent transactions for use // in reorgs. latestSpendJournalBucketVersion = 1 ) var ( // blockIndexBucketName is the name of the db bucket used to house to the // block headers and contextual information. blockIndexBucketName = []byte("blockheaderidx") // hashIndexBucketName is the name of the db bucket used to house to the // block hash -> block height index. hashIndexBucketName = []byte("hashidx") // heightIndexBucketName is the name of the db bucket used to house to // the block height -> block hash index. heightIndexBucketName = []byte("heightidx") // chainStateKeyName is the name of the db key used to store the best // chain state. chainStateKeyName = []byte("chainstate") // utxoStateConsistencyKeyName is the name of the db key used to store the // consistency status of the utxo state. utxoStateConsistencyKeyName = []byte("utxostateconsistency") // spendJournalVersionKeyName is the name of the db key used to store // the version of the spend journal currently in the database. spendJournalVersionKeyName = []byte("spendjournalversion") // spendJournalBucketName is the name of the db bucket used to house // transactions outputs that are spent in each block. spendJournalBucketName = []byte("spendjournal") // utxoSetVersionKeyName is the name of the db key used to store the // version of the utxo set currently in the database. utxoSetVersionKeyName = []byte("utxosetversion") // utxoSetBucketName is the name of the db bucket used to house the // unspent transaction output set. utxoSetBucketName = []byte("utxosetv2") // byteOrder is the preferred byte order used for serializing numeric // fields for storage in the database. byteOrder = binary.LittleEndian ) // errNotInMainChain signifies that a block hash or height that is not in the // main chain was requested. type errNotInMainChain string // Error implements the error interface. func (e errNotInMainChain) Error() string { return string(e) } // isNotInMainChainErr returns whether or not the passed error is an // errNotInMainChain error. func isNotInMainChainErr(err error) bool { _, ok := err.(errNotInMainChain) return ok } // errDeserialize signifies that a problem was encountered when deserializing // data. type errDeserialize string // Error implements the error interface. func (e errDeserialize) Error() string { return string(e) } // isDeserializeErr returns whether or not the passed error is an errDeserialize // error. func isDeserializeErr(err error) bool { _, ok := err.(errDeserialize) return ok } // isDbBucketNotFoundErr returns whether or not the passed error is a // database.Error with an error code of database.ErrBucketNotFound. func isDbBucketNotFoundErr(err error) bool { dbErr, ok := err.(database.Error) return ok && dbErr.ErrorCode == database.ErrBucketNotFound } // dbFetchVersion fetches an individual version with the given key from the // metadata bucket. It is primarily used to track versions on entities such as // buckets. It returns zero if the provided key does not exist. func dbFetchVersion(dbTx database.Tx, key []byte) uint32 { serialized := dbTx.Metadata().Get(key) if serialized == nil { return 0 } return byteOrder.Uint32(serialized) } // dbPutVersion uses an existing database transaction to update the provided // key in the metadata bucket to the given version. It is primarily used to // track versions on entities such as buckets. func dbPutVersion(dbTx database.Tx, key []byte, version uint32) error { var serialized [4]byte byteOrder.PutUint32(serialized[:], version) return dbTx.Metadata().Put(key, serialized[:]) } // dbFetchOrCreateVersion uses an existing database transaction to attempt to // fetch the provided key from the metadata bucket as a version and in the case // it doesn't exist, it adds the entry with the provided default version and // returns that. This is useful during upgrades to automatically handle loading // and adding version keys as necessary. func dbFetchOrCreateVersion(dbTx database.Tx, key []byte, defaultVersion uint32) (uint32, error) { version := dbFetchVersion(dbTx, key) if version == 0 { version = defaultVersion err := dbPutVersion(dbTx, key, version) if err != nil { return 0, err } } return version, nil } // ----------------------------------------------------------------------------- // The transaction spend journal consists of an entry for each block connected // to the main chain which contains the transaction outputs the block spends // serialized such that the order is the reverse of the order they were spent. // // This is required because reorganizing the chain necessarily entails // disconnecting blocks to get back to the point of the fork which implies // unspending all of the transaction outputs that each block previously spent. // Since the utxo set, by definition, only contains unspent transaction outputs, // the spent transaction outputs must be resurrected from somewhere. There is // more than one way this could be done, however this is the most straight // forward method that does not require having a transaction index and unpruned // blockchain. // // NOTE: This format is NOT self describing. The additional details such as // the number of entries (transaction inputs) are expected to come from the // block itself and the utxo set (for legacy entries). The rationale in doing // this is to save space. This is also the reason the spent outputs are // serialized in the reverse order they are spent because later transactions are // allowed to spend outputs from earlier ones in the same block. // // The reserved field below used to keep track of the version of the containing // transaction when the height in the header code was non-zero, however the // height is always non-zero now, but keeping the extra reserved field allows // backwards compatibility. // // The serialized format is: // // [
],... // // Field Type Size // header code VLQ variable // reserved byte 1 // compressed txout // compressed amount VLQ variable // compressed script []byte variable // // The serialized header code format is: // bit 0 - containing transaction is a coinbase // bits 1-x - height of the block that contains the spent txout // // Example 1: // From block 170 in main blockchain. // // 1300320511db93e1dcdb8a016b49840f8c53bc1eb68a382e97b1482ecad7b148a6909a5c // <><><------------------------------------------------------------------> // | | | // | reserved compressed txout // header code // // - header code: 0x13 (coinbase, height 9) // - reserved: 0x00 // - compressed txout 0: // - 0x32: VLQ-encoded compressed amount for 5000000000 (50 BTC) // - 0x05: special script type pay-to-pubkey // - 0x11...5c: x-coordinate of the pubkey // // Example 2: // Adapted from block 100025 in main blockchain. // // 8b99700091f20f006edbc6c4d31bae9f1ccc38538a114bf42de65e868b99700086c64700b2fb57eadf61e106a100a7445a8c3f67898841ec // <----><><----------------------------------------------><----><><----------------------------------------------> // | | | | | | // | reserved compressed txout | reserved compressed txout // header code header code // // - Last spent output: // - header code: 0x8b9970 (not coinbase, height 100024) // - reserved: 0x00 // - compressed txout: // - 0x91f20f: VLQ-encoded compressed amount for 34405000000 (344.05 BTC) // - 0x00: special script type pay-to-pubkey-hash // - 0x6e...86: pubkey hash // - Second to last spent output: // - header code: 0x8b9970 (not coinbase, height 100024) // - reserved: 0x00 // - compressed txout: // - 0x86c647: VLQ-encoded compressed amount for 13761000000 (137.61 BTC) // - 0x00: special script type pay-to-pubkey-hash // - 0xb2...ec: pubkey hash // ----------------------------------------------------------------------------- // SpentTxOut contains a spent transaction output and potentially additional // contextual information such as whether or not it was contained in a coinbase // transaction, the version of the transaction it was contained in, and which // block height the containing transaction was included in. As described in // the comments above, the additional contextual information will only be valid // when this spent txout is spending the last unspent output of the containing // transaction. type SpentTxOut struct { // Amount is the amount of the output. Amount int64 // PkScript is the public key script for the output. PkScript []byte // Height is the height of the block containing the creating tx. Height int32 // Denotes if the creating tx is a coinbase. IsCoinBase bool } // FetchSpendJournal attempts to retrieve the spend journal, or the set of // outputs spent for the target block. This provides a view of all the outputs // that will be consumed once the target block is connected to the end of the // main chain. // // This function is safe for concurrent access. func (b *BlockChain) FetchSpendJournal(targetBlock *btcutil.Block) ([]SpentTxOut, error) { b.chainLock.RLock() defer b.chainLock.RUnlock() var spendEntries []SpentTxOut err := b.db.View(func(dbTx database.Tx) error { var err error spendEntries, err = dbFetchSpendJournalEntry(dbTx, targetBlock) return err }) if err != nil { return nil, err } return spendEntries, nil } // spentTxOutHeaderCode returns the calculated header code to be used when // serializing the provided stxo entry. func spentTxOutHeaderCode(stxo *SpentTxOut) uint64 { // As described in the serialization format comments, the header code // encodes the height shifted over one bit and the coinbase flag in the // lowest bit. headerCode := uint64(stxo.Height) << 1 if stxo.IsCoinBase { headerCode |= 0x01 } return headerCode } // spentTxOutSerializeSize returns the number of bytes it would take to // serialize the passed stxo according to the format described above. func spentTxOutSerializeSize(stxo *SpentTxOut) int { size := serializeSizeVLQ(spentTxOutHeaderCode(stxo)) if stxo.Height > 0 { // The legacy v1 spend journal format conditionally tracked the // containing transaction version when the height was non-zero, // so this is required for backwards compat. size += serializeSizeVLQ(0) } return size + compressedTxOutSize(uint64(stxo.Amount), stxo.PkScript) } // putSpentTxOut serializes the passed stxo according to the format described // above directly into the passed target byte slice. The target byte slice must // be at least large enough to handle the number of bytes returned by the // SpentTxOutSerializeSize function or it will panic. func putSpentTxOut(target []byte, stxo *SpentTxOut) int { headerCode := spentTxOutHeaderCode(stxo) offset := putVLQ(target, headerCode) if stxo.Height > 0 { // The legacy v1 spend journal format conditionally tracked the // containing transaction version when the height was non-zero, // so this is required for backwards compat. offset += putVLQ(target[offset:], 0) } return offset + putCompressedTxOut(target[offset:], uint64(stxo.Amount), stxo.PkScript) } // decodeSpentTxOut decodes the passed serialized stxo entry, possibly followed // by other data, into the passed stxo struct. It returns the number of bytes // read. func decodeSpentTxOut(serialized []byte, stxo *SpentTxOut) (int, error) { // Ensure there are bytes to decode. if len(serialized) == 0 { return 0, errDeserialize("no serialized bytes") } // Deserialize the header code. code, offset := deserializeVLQ(serialized) if offset >= len(serialized) { return offset, errDeserialize("unexpected end of data after " + "header code") } // Decode the header code. // // Bit 0 indicates containing transaction is a coinbase. // Bits 1-x encode height of containing transaction. stxo.IsCoinBase = code&0x01 != 0 stxo.Height = int32(code >> 1) if stxo.Height > 0 { // The legacy v1 spend journal format conditionally tracked the // containing transaction version when the height was non-zero, // so this is required for backwards compat. _, bytesRead := deserializeVLQ(serialized[offset:]) offset += bytesRead if offset >= len(serialized) { return offset, errDeserialize("unexpected end of data " + "after reserved") } } // Decode the compressed txout. amount, pkScript, bytesRead, err := decodeCompressedTxOut( serialized[offset:]) offset += bytesRead if err != nil { return offset, errDeserialize(fmt.Sprintf("unable to decode "+ "txout: %v", err)) } stxo.Amount = int64(amount) stxo.PkScript = pkScript return offset, nil } // deserializeSpendJournalEntry decodes the passed serialized byte slice into a // slice of spent txouts according to the format described in detail above. // // Since the serialization format is not self describing, as noted in the // format comments, this function also requires the transactions that spend the // txouts. func deserializeSpendJournalEntry(serialized []byte, txns []*wire.MsgTx) ([]SpentTxOut, error) { // Calculate the total number of stxos. var numStxos int for _, tx := range txns { numStxos += len(tx.TxIn) } // When a block has no spent txouts there is nothing to serialize. if len(serialized) == 0 { // Ensure the block actually has no stxos. This should never // happen unless there is database corruption or an empty entry // erroneously made its way into the database. if numStxos != 0 { return nil, AssertError(fmt.Sprintf("mismatched spend "+ "journal serialization - no serialization for "+ "expected %d stxos", numStxos)) } return nil, nil } // Loop backwards through all transactions so everything is read in // reverse order to match the serialization order. stxoIdx := numStxos - 1 offset := 0 stxos := make([]SpentTxOut, numStxos) for txIdx := len(txns) - 1; txIdx > -1; txIdx-- { tx := txns[txIdx] // Loop backwards through all of the transaction inputs and read // the associated stxo. for txInIdx := len(tx.TxIn) - 1; txInIdx > -1; txInIdx-- { txIn := tx.TxIn[txInIdx] stxo := &stxos[stxoIdx] stxoIdx-- n, err := decodeSpentTxOut(serialized[offset:], stxo) offset += n if err != nil { return nil, errDeserialize(fmt.Sprintf("unable "+ "to decode stxo for %v: %v", txIn.PreviousOutPoint, err)) } } } return stxos, nil } // serializeSpendJournalEntry serializes all of the passed spent txouts into a // single byte slice according to the format described in detail above. func serializeSpendJournalEntry(stxos []SpentTxOut) []byte { if len(stxos) == 0 { return nil } // Calculate the size needed to serialize the entire journal entry. var size int for i := range stxos { size += spentTxOutSerializeSize(&stxos[i]) } serialized := make([]byte, size) // Serialize each individual stxo directly into the slice in reverse // order one after the other. var offset int for i := len(stxos) - 1; i > -1; i-- { offset += putSpentTxOut(serialized[offset:], &stxos[i]) } return serialized } // dbFetchSpendJournalEntry fetches the spend journal entry for the passed block // and deserializes it into a slice of spent txout entries. // // NOTE: Legacy entries will not have the coinbase flag or height set unless it // was the final output spend in the containing transaction. It is up to the // caller to handle this properly by looking the information up in the utxo set. func dbFetchSpendJournalEntry(dbTx database.Tx, block *btcutil.Block) ([]SpentTxOut, error) { // Exclude the coinbase transaction since it can't spend anything. spendBucket := dbTx.Metadata().Bucket(spendJournalBucketName) serialized := spendBucket.Get(block.Hash()[:]) blockTxns := block.MsgBlock().Transactions[1:] stxos, err := deserializeSpendJournalEntry(serialized, blockTxns) if err != nil { // Ensure any deserialization errors are returned as database // corruption errors. if isDeserializeErr(err) { return nil, database.Error{ ErrorCode: database.ErrCorruption, Description: fmt.Sprintf("corrupt spend "+ "information for %v: %v", block.Hash(), err), } } return nil, err } return stxos, nil } // dbPutSpendJournalEntry uses an existing database transaction to update the // spend journal entry for the given block hash using the provided slice of // spent txouts. The spent txouts slice must contain an entry for every txout // the transactions in the block spend in the order they are spent. func dbPutSpendJournalEntry(dbTx database.Tx, blockHash *chainhash.Hash, stxos []SpentTxOut) error { spendBucket := dbTx.Metadata().Bucket(spendJournalBucketName) serialized := serializeSpendJournalEntry(stxos) return spendBucket.Put(blockHash[:], serialized) } // dbRemoveSpendJournalEntry uses an existing database transaction to remove the // spend journal entry for the passed block hash. func dbRemoveSpendJournalEntry(dbTx database.Tx, blockHash *chainhash.Hash) error { spendBucket := dbTx.Metadata().Bucket(spendJournalBucketName) return spendBucket.Delete(blockHash[:]) } // dbPruneSpendJournalEntry uses an existing database transaction to remove all // the spend journal entries for the pruned blocks. func dbPruneSpendJournalEntry(dbTx database.Tx, blockHashes []chainhash.Hash) error { spendBucket := dbTx.Metadata().Bucket(spendJournalBucketName) for _, blockHash := range blockHashes { err := spendBucket.Delete(blockHash[:]) if err != nil { return err } } return nil } // ----------------------------------------------------------------------------- // The unspent transaction output (utxo) set consists of an entry for each // unspent output using a format that is optimized to reduce space using domain // specific compression algorithms. This format is a slightly modified version // of the format used in Bitcoin Core. // // Each entry is keyed by an outpoint as specified below. It is important to // note that the key encoding uses a VLQ, which employs an MSB encoding so // iteration of utxos when doing byte-wise comparisons will produce them in // order. // // The serialized key format is: // // // Field Type Size // hash chainhash.Hash chainhash.HashSize // output index VLQ variable // // The serialized value format is: // //
// // Field Type Size // header code VLQ variable // compressed txout // compressed amount VLQ variable // compressed script []byte variable // // The serialized header code format is: // bit 0 - containing transaction is a coinbase // bits 1-x - height of the block that contains the unspent txout // // Example 1: // From tx in main blockchain: // Blk 1, 0e3e2357e806b6cdb1f70b54c3a3a17b6714ee1f0e68bebb44a74b1efd512098:0 // // 03320496b538e853519c726a2c91e61ec11600ae1390813a627c66fb8be7947be63c52 // <><------------------------------------------------------------------> // | | // header code compressed txout // // - header code: 0x03 (coinbase, height 1) // - compressed txout: // - 0x32: VLQ-encoded compressed amount for 5000000000 (50 BTC) // - 0x04: special script type pay-to-pubkey // - 0x96...52: x-coordinate of the pubkey // // Example 2: // From tx in main blockchain: // Blk 113931, 4a16969aa4764dd7507fc1de7f0baa4850a246de90c45e59a3207f9a26b5036f:2 // // 8cf316800900b8025be1b3efc63b0ad48e7f9f10e87544528d58 // <----><------------------------------------------> // | | // header code compressed txout // // - header code: 0x8cf316 (not coinbase, height 113931) // - compressed txout: // - 0x8009: VLQ-encoded compressed amount for 15000000 (0.15 BTC) // - 0x00: special script type pay-to-pubkey-hash // - 0xb8...58: pubkey hash // // Example 3: // From tx in main blockchain: // Blk 338156, 1b02d1c8cfef60a189017b9a420c682cf4a0028175f2f563209e4ff61c8c3620:22 // // a8a2588ba5b9e763011dd46a006572d820e448e12d2bbb38640bc718e6 // <----><--------------------------------------------------> // | | // header code compressed txout // // - header code: 0xa8a258 (not coinbase, height 338156) // - compressed txout: // - 0x8ba5b9e763: VLQ-encoded compressed amount for 366875659 (3.66875659 BTC) // - 0x01: special script type pay-to-script-hash // - 0x1d...e6: script hash // ----------------------------------------------------------------------------- // maxUint32VLQSerializeSize is the maximum number of bytes a max uint32 takes // to serialize as a VLQ. var maxUint32VLQSerializeSize = serializeSizeVLQ(1<<32 - 1) // outpointKeyPool defines a concurrent safe free list of byte slices used to // provide temporary buffers for outpoint database keys. var outpointKeyPool = sync.Pool{ New: func() interface{} { b := make([]byte, chainhash.HashSize+maxUint32VLQSerializeSize) return &b // Pointer to slice to avoid boxing alloc. }, } // outpointKey returns a key suitable for use as a database key in the utxo set // while making use of a free list. A new buffer is allocated if there are not // already any available on the free list. The returned byte slice should be // returned to the free list by using the recycleOutpointKey function when the // caller is done with it _unless_ the slice will need to live for longer than // the caller can calculate such as when used to write to the database. func outpointKey(outpoint wire.OutPoint) *[]byte { // A VLQ employs an MSB encoding, so they are useful not only to reduce // the amount of storage space, but also so iteration of utxos when // doing byte-wise comparisons will produce them in order. key := outpointKeyPool.Get().(*[]byte) idx := uint64(outpoint.Index) *key = (*key)[:chainhash.HashSize+serializeSizeVLQ(idx)] copy(*key, outpoint.Hash[:]) putVLQ((*key)[chainhash.HashSize:], idx) return key } // recycleOutpointKey puts the provided byte slice, which should have been // obtained via the outpointKey function, back on the free list. func recycleOutpointKey(key *[]byte) { outpointKeyPool.Put(key) } // utxoEntryHeaderCode returns the calculated header code to be used when // serializing the provided utxo entry. func utxoEntryHeaderCode(entry *UtxoEntry) (uint64, error) { if entry.IsSpent() { return 0, AssertError("attempt to serialize spent utxo header") } // As described in the serialization format comments, the header code // encodes the height shifted over one bit and the coinbase flag in the // lowest bit. headerCode := uint64(entry.BlockHeight()) << 1 if entry.IsCoinBase() { headerCode |= 0x01 } return headerCode, nil } // serializeUtxoEntry returns the entry serialized to a format that is suitable // for long-term storage. The format is described in detail above. func serializeUtxoEntry(entry *UtxoEntry) ([]byte, error) { // Spent outputs have no serialization. if entry.IsSpent() { return nil, nil } // Encode the header code. headerCode, err := utxoEntryHeaderCode(entry) if err != nil { return nil, err } // Calculate the size needed to serialize the entry. size := serializeSizeVLQ(headerCode) + compressedTxOutSize(uint64(entry.Amount()), entry.PkScript()) // Serialize the header code followed by the compressed unspent // transaction output. serialized := make([]byte, size) offset := putVLQ(serialized, headerCode) offset += putCompressedTxOut(serialized[offset:], uint64(entry.Amount()), entry.PkScript()) return serialized, nil } // deserializeUtxoEntry decodes a utxo entry from the passed serialized byte // slice into a new UtxoEntry using a format that is suitable for long-term // storage. The format is described in detail above. func deserializeUtxoEntry(serialized []byte) (*UtxoEntry, error) { // Deserialize the header code. code, offset := deserializeVLQ(serialized) if offset >= len(serialized) { return nil, errDeserialize("unexpected end of data after header") } // Decode the header code. // // Bit 0 indicates whether the containing transaction is a coinbase. // Bits 1-x encode height of containing transaction. isCoinBase := code&0x01 != 0 blockHeight := int32(code >> 1) // Decode the compressed unspent transaction output. amount, pkScript, _, err := decodeCompressedTxOut(serialized[offset:]) if err != nil { return nil, errDeserialize(fmt.Sprintf("unable to decode "+ "utxo: %v", err)) } entry := &UtxoEntry{ amount: int64(amount), pkScript: pkScript, blockHeight: blockHeight, packedFlags: 0, } if isCoinBase { entry.packedFlags |= tfCoinBase } return entry, nil } // dbFetchUtxoEntryByHash attempts to find and fetch a utxo for the given hash. // It uses a cursor and seek to try and do this as efficiently as possible. // // When there are no entries for the provided hash, nil will be returned for the // both the entry and the error. func dbFetchUtxoEntryByHash(dbTx database.Tx, hash *chainhash.Hash) (*UtxoEntry, error) { // Attempt to find an entry by seeking for the hash along with a zero // index. Due to the fact the keys are serialized as , // where the index uses an MSB encoding, if there are any entries for // the hash at all, one will be found. cursor := dbTx.Metadata().Bucket(utxoSetBucketName).Cursor() key := outpointKey(wire.OutPoint{Hash: *hash, Index: 0}) ok := cursor.Seek(*key) recycleOutpointKey(key) if !ok { return nil, nil } // An entry was found, but it could just be an entry with the next // highest hash after the requested one, so make sure the hashes // actually match. cursorKey := cursor.Key() if len(cursorKey) < chainhash.HashSize { return nil, nil } if !bytes.Equal(hash[:], cursorKey[:chainhash.HashSize]) { return nil, nil } return deserializeUtxoEntry(cursor.Value()) } // dbFetchUtxoEntry uses an existing database transaction to fetch the specified // transaction output from the utxo set. // // When there is no entry for the provided output, nil will be returned for both // the entry and the error. func dbFetchUtxoEntry(dbTx database.Tx, utxoBucket database.Bucket, outpoint wire.OutPoint) (*UtxoEntry, error) { // Fetch the unspent transaction output information for the passed // transaction output. Return now when there is no entry. key := outpointKey(outpoint) serializedUtxo := utxoBucket.Get(*key) recycleOutpointKey(key) if serializedUtxo == nil { return nil, nil } // A non-nil zero-length entry means there is an entry in the database // for a spent transaction output which should never be the case. if len(serializedUtxo) == 0 { return nil, AssertError(fmt.Sprintf("database contains entry "+ "for spent tx output %v", outpoint)) } // Deserialize the utxo entry and return it. entry, err := deserializeUtxoEntry(serializedUtxo) if err != nil { // Ensure any deserialization errors are returned as database // corruption errors. if isDeserializeErr(err) { return nil, database.Error{ ErrorCode: database.ErrCorruption, Description: fmt.Sprintf("corrupt utxo entry "+ "for %v: %v", outpoint, err), } } return nil, err } return entry, nil } // dbPutUtxoView uses an existing database transaction to update the utxo set // in the database based on the provided utxo view contents and state. In // particular, only the entries that have been marked as modified are written // to the database. func dbPutUtxoView(dbTx database.Tx, view *UtxoViewpoint) error { // Return early if the view is nil. if view == nil { return nil } utxoBucket := dbTx.Metadata().Bucket(utxoSetBucketName) for outpoint, entry := range view.entries { // No need to update the database if the entry was not modified. if entry == nil || !entry.isModified() { continue } // Remove the utxo entry if it is spent. if entry.IsSpent() { err := dbDeleteUtxoEntry(utxoBucket, outpoint) if err != nil { return err } } else { err := dbPutUtxoEntry(utxoBucket, outpoint, entry) if err != nil { return err } } } return nil } // dbDeleteUtxoEntry uses an existing database transaction to delete the utxo // entry from the database. func dbDeleteUtxoEntry(utxoBucket database.Bucket, outpoint wire.OutPoint) error { key := outpointKey(outpoint) err := utxoBucket.Delete(*key) recycleOutpointKey(key) return err } // dbPutUtxoEntry uses an existing database transaction to update the utxo entry // in the database. func dbPutUtxoEntry(utxoBucket database.Bucket, outpoint wire.OutPoint, entry *UtxoEntry) error { if entry == nil || entry.IsSpent() { return AssertError("trying to store nil or spent entry") } // Serialize and store the utxo entry. serialized, err := serializeUtxoEntry(entry) if err != nil { return err } key := outpointKey(outpoint) err = utxoBucket.Put(*key, serialized) if err != nil { return err } // NOTE: The key is intentionally not recycled here since the // database interface contract prohibits modifications. It will // be garbage collected normally when the database is done with // it. return nil } // ----------------------------------------------------------------------------- // The block index consists of two buckets with an entry for every block in the // main chain. One bucket is for the hash to height mapping and the other is // for the height to hash mapping. // // The serialized format for values in the hash to height bucket is: // // // Field Type Size // height uint32 4 bytes // // The serialized format for values in the height to hash bucket is: // // // Field Type Size // hash chainhash.Hash chainhash.HashSize // ----------------------------------------------------------------------------- // dbPutBlockIndex uses an existing database transaction to update or add the // block index entries for the hash to height and height to hash mappings for // the provided values. func dbPutBlockIndex(dbTx database.Tx, hash *chainhash.Hash, height int32) error { // Serialize the height for use in the index entries. var serializedHeight [4]byte byteOrder.PutUint32(serializedHeight[:], uint32(height)) // Add the block hash to height mapping to the index. meta := dbTx.Metadata() hashIndex := meta.Bucket(hashIndexBucketName) if err := hashIndex.Put(hash[:], serializedHeight[:]); err != nil { return err } // Add the block height to hash mapping to the index. heightIndex := meta.Bucket(heightIndexBucketName) return heightIndex.Put(serializedHeight[:], hash[:]) } // dbRemoveBlockIndex uses an existing database transaction remove block index // entries from the hash to height and height to hash mappings for the provided // values. func dbRemoveBlockIndex(dbTx database.Tx, hash *chainhash.Hash, height int32) error { // Remove the block hash to height mapping. meta := dbTx.Metadata() hashIndex := meta.Bucket(hashIndexBucketName) if err := hashIndex.Delete(hash[:]); err != nil { return err } // Remove the block height to hash mapping. var serializedHeight [4]byte byteOrder.PutUint32(serializedHeight[:], uint32(height)) heightIndex := meta.Bucket(heightIndexBucketName) return heightIndex.Delete(serializedHeight[:]) } // dbFetchHeightByHash uses an existing database transaction to retrieve the // height for the provided hash from the index. func dbFetchHeightByHash(dbTx database.Tx, hash *chainhash.Hash) (int32, error) { meta := dbTx.Metadata() hashIndex := meta.Bucket(hashIndexBucketName) serializedHeight := hashIndex.Get(hash[:]) if serializedHeight == nil { str := fmt.Sprintf("block %s is not in the main chain", hash) return 0, errNotInMainChain(str) } return int32(byteOrder.Uint32(serializedHeight)), nil } // dbFetchHashByHeight uses an existing database transaction to retrieve the // hash for the provided height from the index. func dbFetchHashByHeight(dbTx database.Tx, height int32) (*chainhash.Hash, error) { var serializedHeight [4]byte byteOrder.PutUint32(serializedHeight[:], uint32(height)) meta := dbTx.Metadata() heightIndex := meta.Bucket(heightIndexBucketName) hashBytes := heightIndex.Get(serializedHeight[:]) if hashBytes == nil { str := fmt.Sprintf("no block at height %d exists", height) return nil, errNotInMainChain(str) } var hash chainhash.Hash copy(hash[:], hashBytes) return &hash, nil } // ----------------------------------------------------------------------------- // The best chain state consists of the best block hash and height, the total // number of transactions up to and including those in the best block, and the // accumulated work sum up to and including the best block. // // The serialized format is: // // // // Field Type Size // block hash chainhash.Hash chainhash.HashSize // block height uint32 4 bytes // total txns uint64 8 bytes // work sum length uint32 4 bytes // work sum big.Int work sum length // ----------------------------------------------------------------------------- // bestChainState represents the data to be stored the database for the current // best chain state. type bestChainState struct { hash chainhash.Hash height uint32 totalTxns uint64 workSum *big.Int } // serializeBestChainState returns the serialization of the passed block best // chain state. This is data to be stored in the chain state bucket. func serializeBestChainState(state bestChainState) []byte { // Calculate the full size needed to serialize the chain state. workSumBytes := state.workSum.Bytes() workSumBytesLen := uint32(len(workSumBytes)) serializedLen := chainhash.HashSize + 4 + 8 + 4 + workSumBytesLen // Serialize the chain state. serializedData := make([]byte, serializedLen) copy(serializedData[0:chainhash.HashSize], state.hash[:]) offset := uint32(chainhash.HashSize) byteOrder.PutUint32(serializedData[offset:], state.height) offset += 4 byteOrder.PutUint64(serializedData[offset:], state.totalTxns) offset += 8 byteOrder.PutUint32(serializedData[offset:], workSumBytesLen) offset += 4 copy(serializedData[offset:], workSumBytes) return serializedData } // deserializeBestChainState deserializes the passed serialized best chain // state. This is data stored in the chain state bucket and is updated after // every block is connected or disconnected form the main chain. // block. func deserializeBestChainState(serializedData []byte) (bestChainState, error) { // Ensure the serialized data has enough bytes to properly deserialize // the hash, height, total transactions, and work sum length. if len(serializedData) < chainhash.HashSize+16 { return bestChainState{}, database.Error{ ErrorCode: database.ErrCorruption, Description: "corrupt best chain state", } } state := bestChainState{} copy(state.hash[:], serializedData[0:chainhash.HashSize]) offset := uint32(chainhash.HashSize) state.height = byteOrder.Uint32(serializedData[offset : offset+4]) offset += 4 state.totalTxns = byteOrder.Uint64(serializedData[offset : offset+8]) offset += 8 workSumBytesLen := byteOrder.Uint32(serializedData[offset : offset+4]) offset += 4 // Ensure the serialized data has enough bytes to deserialize the work // sum. if uint32(len(serializedData[offset:])) < workSumBytesLen { return bestChainState{}, database.Error{ ErrorCode: database.ErrCorruption, Description: "corrupt best chain state", } } workSumBytes := serializedData[offset : offset+workSumBytesLen] state.workSum = new(big.Int).SetBytes(workSumBytes) return state, nil } // dbPutBestState uses an existing database transaction to update the best chain // state with the given parameters. func dbPutBestState(dbTx database.Tx, snapshot *BestState, workSum *big.Int) error { // Serialize the current best chain state. serializedData := serializeBestChainState(bestChainState{ hash: snapshot.Hash, height: uint32(snapshot.Height), totalTxns: snapshot.TotalTxns, workSum: workSum, }) // Store the current best chain state into the database. return dbTx.Metadata().Put(chainStateKeyName, serializedData) } // dbPutUtxoStateConsistency uses an existing database transaction to // update the utxo state consistency status with the given parameters. func dbPutUtxoStateConsistency(dbTx database.Tx, hash *chainhash.Hash) error { // Store the utxo state consistency status into the database. return dbTx.Metadata().Put(utxoStateConsistencyKeyName, hash[:]) } // dbFetchUtxoStateConsistency uses an existing database transaction to retrieve // the utxo state consistency status from the database. The code is 0 when // nothing was found. func dbFetchUtxoStateConsistency(dbTx database.Tx) []byte { // Fetch the serialized data from the database. statusBytes := dbTx.Metadata().Get(utxoStateConsistencyKeyName) if statusBytes != nil { result := make([]byte, len(statusBytes)) copy(result, statusBytes) return result } return nil } // createChainState initializes both the database and the chain state to the // genesis block. This includes creating the necessary buckets and inserting // the genesis block, so it must only be called on an uninitialized database. func (b *BlockChain) createChainState() error { // Create a new node from the genesis block and set it as the best node. genesisBlock := btcutil.NewBlock(b.chainParams.GenesisBlock) genesisBlock.SetHeight(0) header := &genesisBlock.MsgBlock().Header node := newBlockNode(header, nil) node.status = statusDataStored | statusValid b.bestChain.SetTip(node) // Add the new node to the index which is used for faster lookups. b.index.addNode(node) // Initialize the state related to the best block. Since it is the // genesis block, use its timestamp for the median time. numTxns := uint64(len(genesisBlock.MsgBlock().Transactions)) blockSize := uint64(genesisBlock.MsgBlock().SerializeSize()) blockWeight := uint64(GetBlockWeight(genesisBlock)) b.stateSnapshot = newBestState(node, blockSize, blockWeight, numTxns, numTxns, time.Unix(node.timestamp, 0)) // Create the initial the database chain state including creating the // necessary index buckets and inserting the genesis block. err := b.db.Update(func(dbTx database.Tx) error { meta := dbTx.Metadata() // Create the bucket that houses the block index data. _, err := meta.CreateBucket(blockIndexBucketName) if err != nil { return err } // Create the bucket that houses the chain block hash to height // index. _, err = meta.CreateBucket(hashIndexBucketName) if err != nil { return err } // Create the bucket that houses the chain block height to hash // index. _, err = meta.CreateBucket(heightIndexBucketName) if err != nil { return err } // Create the bucket that houses the spend journal data and // store its version. _, err = meta.CreateBucket(spendJournalBucketName) if err != nil { return err } err = dbPutVersion(dbTx, utxoSetVersionKeyName, latestUtxoSetBucketVersion) if err != nil { return err } // Create the bucket that houses the utxo set and store its // version. Note that the genesis block coinbase transaction is // intentionally not inserted here since it is not spendable by // consensus rules. _, err = meta.CreateBucket(utxoSetBucketName) if err != nil { return err } err = dbPutVersion(dbTx, spendJournalVersionKeyName, latestSpendJournalBucketVersion) if err != nil { return err } // Save the genesis block to the block index database. err = dbStoreBlockNode(dbTx, node) if err != nil { return err } // Add the genesis block hash to height and height to hash // mappings to the index. err = dbPutBlockIndex(dbTx, &node.hash, node.height) if err != nil { return err } // Store the current best chain state into the database. err = dbPutBestState(dbTx, b.stateSnapshot, node.workSum) if err != nil { return err } // Store the genesis block into the database. return dbStoreBlock(dbTx, genesisBlock) }) return err } // initChainState attempts to load and initialize the chain state from the // database. When the db does not yet contain any chain state, both it and the // chain state are initialized to the genesis block. func (b *BlockChain) initChainState() error { // Determine the state of the chain database. We may need to initialize // everything from scratch or upgrade certain buckets. var initialized, hasBlockIndex bool err := b.db.View(func(dbTx database.Tx) error { initialized = dbTx.Metadata().Get(chainStateKeyName) != nil hasBlockIndex = dbTx.Metadata().Bucket(blockIndexBucketName) != nil return nil }) if err != nil { return err } if !initialized { // At this point the database has not already been initialized, so // initialize both it and the chain state to the genesis block. return b.createChainState() } if !hasBlockIndex { err := migrateBlockIndex(b.db) if err != nil { return nil } } // Attempt to load the chain state from the database. err = b.db.View(func(dbTx database.Tx) error { // Fetch the stored chain state from the database metadata. // When it doesn't exist, it means the database hasn't been // initialized for use with chain yet, so break out now to allow // that to happen under a writable database transaction. serializedData := dbTx.Metadata().Get(chainStateKeyName) log.Tracef("Serialized chain state: %x", serializedData) state, err := deserializeBestChainState(serializedData) if err != nil { return err } // Load all of the headers from the data for the known best // chain and construct the block index accordingly. Since the // number of nodes are already known, perform a single alloc // for them versus a whole bunch of little ones to reduce // pressure on the GC. log.Infof("Loading block index...") blockIndexBucket := dbTx.Metadata().Bucket(blockIndexBucketName) var i int32 var lastNode *blockNode cursor := blockIndexBucket.Cursor() for ok := cursor.First(); ok; ok = cursor.Next() { header, status, err := deserializeBlockRow(cursor.Value()) if err != nil { return err } // Determine the parent block node. Since we iterate block headers // in order of height, if the blocks are mostly linear there is a // very good chance the previous header processed is the parent. var parent *blockNode if lastNode == nil { blockHash := header.BlockHash() if !blockHash.IsEqual(b.chainParams.GenesisHash) { return AssertError(fmt.Sprintf("initChainState: Expected "+ "first entry in block index to be genesis block, "+ "found %s", blockHash)) } } else if header.PrevBlock == lastNode.hash { // Since we iterate block headers in order of height, if the // blocks are mostly linear there is a very good chance the // previous header processed is the parent. parent = lastNode } else { parent = b.index.LookupNode(&header.PrevBlock) if parent == nil { return AssertError(fmt.Sprintf("initChainState: Could "+ "not find parent for block %s", header.BlockHash())) } } // Initialize the block node for the block, connect it, // and add it to the block index. node := new(blockNode) initBlockNode(node, header, parent) node.status = status b.index.addNode(node) lastNode = node i++ } // Set the best chain view to the stored best state. tip := b.index.LookupNode(&state.hash) if tip == nil { return AssertError(fmt.Sprintf("initChainState: cannot find "+ "chain tip %s in block index", state.hash)) } b.bestChain.SetTip(tip) // Load the raw block bytes for the best block. blockBytes, err := dbTx.FetchBlock(&state.hash) if err != nil { return err } var block wire.MsgBlock err = block.Deserialize(bytes.NewReader(blockBytes)) if err != nil { return err } // As a final consistency check, we'll run through all the // nodes which are ancestors of the current chain tip, and mark // them as valid if they aren't already marked as such. This // is a safe assumption as all the block before the current tip // are valid by definition. for iterNode := tip; iterNode != nil; iterNode = iterNode.parent { // If this isn't already marked as valid in the index, then // we'll mark it as valid now to ensure consistency once // we're up and running. if !iterNode.status.KnownValid() { log.Infof("Block %v (height=%v) ancestor of "+ "chain tip not marked as valid, "+ "upgrading to valid for consistency", iterNode.hash, iterNode.height) b.index.SetStatusFlags(iterNode, statusValid) } } // Initialize the state related to the best block. blockSize := uint64(len(blockBytes)) blockWeight := uint64(GetBlockWeight(btcutil.NewBlock(&block))) numTxns := uint64(len(block.Transactions)) b.stateSnapshot = newBestState(tip, blockSize, blockWeight, numTxns, state.totalTxns, CalcPastMedianTime(tip)) return nil }) if err != nil { return err } // As we might have updated the index after it was loaded, we'll // attempt to flush the index to the DB. This will only result in a // write if the elements are dirty, so it'll usually be a noop. return b.index.flushToDB() } // deserializeBlockRow parses a value in the block index bucket into a block // header and block status bitfield. func deserializeBlockRow(blockRow []byte) (*wire.BlockHeader, blockStatus, error) { buffer := bytes.NewReader(blockRow) var header wire.BlockHeader err := header.Deserialize(buffer) if err != nil { return nil, statusNone, err } statusByte, err := buffer.ReadByte() if err != nil { return nil, statusNone, err } return &header, blockStatus(statusByte), nil } // dbFetchHeaderByHash uses an existing database transaction to retrieve the // block header for the provided hash. func dbFetchHeaderByHash(dbTx database.Tx, hash *chainhash.Hash) (*wire.BlockHeader, error) { headerBytes, err := dbTx.FetchBlockHeader(hash) if err != nil { return nil, err } var header wire.BlockHeader err = header.Deserialize(bytes.NewReader(headerBytes)) if err != nil { return nil, err } return &header, nil } // dbFetchHeaderByHeight uses an existing database transaction to retrieve the // block header for the provided height. func dbFetchHeaderByHeight(dbTx database.Tx, height int32) (*wire.BlockHeader, error) { hash, err := dbFetchHashByHeight(dbTx, height) if err != nil { return nil, err } return dbFetchHeaderByHash(dbTx, hash) } // dbFetchBlockByNode uses an existing database transaction to retrieve the // raw block for the provided node, deserialize it, and return a btcutil.Block // with the height set. func dbFetchBlockByNode(dbTx database.Tx, node *blockNode) (*btcutil.Block, error) { // Load the raw block bytes from the database. blockBytes, err := dbTx.FetchBlock(&node.hash) if err != nil { return nil, err } // Create the encapsulated block and set the height appropriately. block, err := btcutil.NewBlockFromBytes(blockBytes) if err != nil { return nil, err } block.SetHeight(node.height) return block, nil } // dbStoreBlockNode stores the block header and validation status to the block // index bucket. This overwrites the current entry if there exists one. func dbStoreBlockNode(dbTx database.Tx, node *blockNode) error { // Serialize block data to be stored. w := bytes.NewBuffer(make([]byte, 0, blockHdrSize+1)) header := node.Header() err := header.Serialize(w) if err != nil { return err } err = w.WriteByte(byte(node.status)) if err != nil { return err } value := w.Bytes() // Write block header data to block index bucket. blockIndexBucket := dbTx.Metadata().Bucket(blockIndexBucketName) key := blockIndexKey(&node.hash, uint32(node.height)) return blockIndexBucket.Put(key, value) } // dbStoreBlock stores the provided block in the database if it is not already // there. The full block data is written to ffldb. func dbStoreBlock(dbTx database.Tx, block *btcutil.Block) error { hasBlock, err := dbTx.HasBlock(block.Hash()) if err != nil { return err } if hasBlock { return nil } return dbTx.StoreBlock(block) } // blockIndexKey generates the binary key for an entry in the block index // bucket. The key is composed of the block height encoded as a big-endian // 32-bit unsigned int followed by the 32 byte block hash. func blockIndexKey(blockHash *chainhash.Hash, blockHeight uint32) []byte { indexKey := make([]byte, chainhash.HashSize+4) binary.BigEndian.PutUint32(indexKey[0:4], blockHeight) copy(indexKey[4:chainhash.HashSize+4], blockHash[:]) return indexKey } // BlockByHeight returns the block at the given height in the main chain. // // This function is safe for concurrent access. func (b *BlockChain) BlockByHeight(blockHeight int32) (*btcutil.Block, error) { // Lookup the block height in the best chain. node := b.bestChain.NodeByHeight(blockHeight) if node == nil { str := fmt.Sprintf("no block at height %d exists", blockHeight) return nil, errNotInMainChain(str) } // Load the block from the database and return it. var block *btcutil.Block err := b.db.View(func(dbTx database.Tx) error { var err error block, err = dbFetchBlockByNode(dbTx, node) return err }) return block, err } // BlockByHash returns the block from the main chain with the given hash with // the appropriate chain height set. // // This function is safe for concurrent access. func (b *BlockChain) BlockByHash(hash *chainhash.Hash) (*btcutil.Block, error) { // Lookup the block hash in block index and ensure it is in the best // chain. node := b.index.LookupNode(hash) if node == nil || !b.bestChain.Contains(node) { str := fmt.Sprintf("block %s is not in the main chain", hash) return nil, errNotInMainChain(str) } // Load the block from the database and return it. var block *btcutil.Block err := b.db.View(func(dbTx database.Tx) error { var err error block, err = dbFetchBlockByNode(dbTx, node) return err }) return block, err } ================================================ FILE: blockchain/chainio_test.go ================================================ // Copyright (c) 2015-2016 The btcsuite developers // Use of this source code is governed by an ISC // license that can be found in the LICENSE file. package blockchain import ( "bytes" "errors" "math/big" "reflect" "testing" "github.com/btcsuite/btcd/database" "github.com/btcsuite/btcd/wire" ) // TestErrNotInMainChain ensures the functions related to errNotInMainChain work // as expected. func TestErrNotInMainChain(t *testing.T) { errStr := "no block at height 1 exists" err := error(errNotInMainChain(errStr)) // Ensure the stringized output for the error is as expected. if err.Error() != errStr { t.Fatalf("errNotInMainChain returned unexpected error string - "+ "got %q, want %q", err.Error(), errStr) } // Ensure error is detected as the correct type. if !isNotInMainChainErr(err) { t.Fatalf("isNotInMainChainErr did not detect as expected type") } err = errors.New("something else") if isNotInMainChainErr(err) { t.Fatalf("isNotInMainChainErr detected incorrect type") } } // TestStxoSerialization ensures serializing and deserializing spent transaction // output entries works as expected. func TestStxoSerialization(t *testing.T) { t.Parallel() tests := []struct { name string stxo SpentTxOut serialized []byte }{ // From block 170 in main blockchain. { name: "Spends last output of coinbase", stxo: SpentTxOut{ Amount: 5000000000, PkScript: hexToBytes("410411db93e1dcdb8a016b49840f8c53bc1eb68a382e97b1482ecad7b148a6909a5cb2e0eaddfb84ccf9744464f82e160bfa9b8b64f9d4c03f999b8643f656b412a3ac"), IsCoinBase: true, Height: 9, }, serialized: hexToBytes("1300320511db93e1dcdb8a016b49840f8c53bc1eb68a382e97b1482ecad7b148a6909a5c"), }, // Adapted from block 100025 in main blockchain. { name: "Spends last output of non coinbase", stxo: SpentTxOut{ Amount: 13761000000, PkScript: hexToBytes("76a914b2fb57eadf61e106a100a7445a8c3f67898841ec88ac"), IsCoinBase: false, Height: 100024, }, serialized: hexToBytes("8b99700086c64700b2fb57eadf61e106a100a7445a8c3f67898841ec"), }, // Adapted from block 100025 in main blockchain. { name: "Does not spend last output, legacy format", stxo: SpentTxOut{ Amount: 34405000000, PkScript: hexToBytes("76a9146edbc6c4d31bae9f1ccc38538a114bf42de65e8688ac"), }, serialized: hexToBytes("0091f20f006edbc6c4d31bae9f1ccc38538a114bf42de65e86"), }, } for _, test := range tests { // Ensure the function to calculate the serialized size without // actually serializing it is calculated properly. gotSize := spentTxOutSerializeSize(&test.stxo) if gotSize != len(test.serialized) { t.Errorf("SpentTxOutSerializeSize (%s): did not get "+ "expected size - got %d, want %d", test.name, gotSize, len(test.serialized)) continue } // Ensure the stxo serializes to the expected value. gotSerialized := make([]byte, gotSize) gotBytesWritten := putSpentTxOut(gotSerialized, &test.stxo) if !bytes.Equal(gotSerialized, test.serialized) { t.Errorf("putSpentTxOut (%s): did not get expected "+ "bytes - got %x, want %x", test.name, gotSerialized, test.serialized) continue } if gotBytesWritten != len(test.serialized) { t.Errorf("putSpentTxOut (%s): did not get expected "+ "number of bytes written - got %d, want %d", test.name, gotBytesWritten, len(test.serialized)) continue } // Ensure the serialized bytes are decoded back to the expected // stxo. var gotStxo SpentTxOut gotBytesRead, err := decodeSpentTxOut(test.serialized, &gotStxo) if err != nil { t.Errorf("decodeSpentTxOut (%s): unexpected error: %v", test.name, err) continue } if !reflect.DeepEqual(gotStxo, test.stxo) { t.Errorf("decodeSpentTxOut (%s) mismatched entries - "+ "got %v, want %v", test.name, gotStxo, test.stxo) continue } if gotBytesRead != len(test.serialized) { t.Errorf("decodeSpentTxOut (%s): did not get expected "+ "number of bytes read - got %d, want %d", test.name, gotBytesRead, len(test.serialized)) continue } } } // TestStxoDecodeErrors performs negative tests against decoding spent // transaction outputs to ensure error paths work as expected. func TestStxoDecodeErrors(t *testing.T) { t.Parallel() tests := []struct { name string stxo SpentTxOut serialized []byte bytesRead int // Expected number of bytes read. errType error }{ { name: "nothing serialized", stxo: SpentTxOut{}, serialized: hexToBytes(""), errType: errDeserialize(""), bytesRead: 0, }, { name: "no data after header code w/o reserved", stxo: SpentTxOut{}, serialized: hexToBytes("00"), errType: errDeserialize(""), bytesRead: 1, }, { name: "no data after header code with reserved", stxo: SpentTxOut{}, serialized: hexToBytes("13"), errType: errDeserialize(""), bytesRead: 1, }, { name: "no data after reserved", stxo: SpentTxOut{}, serialized: hexToBytes("1300"), errType: errDeserialize(""), bytesRead: 2, }, { name: "incomplete compressed txout", stxo: SpentTxOut{}, serialized: hexToBytes("1332"), errType: errDeserialize(""), bytesRead: 2, }, } for _, test := range tests { // Ensure the expected error type is returned. gotBytesRead, err := decodeSpentTxOut(test.serialized, &test.stxo) if reflect.TypeOf(err) != reflect.TypeOf(test.errType) { t.Errorf("decodeSpentTxOut (%s): expected error type "+ "does not match - got %T, want %T", test.name, err, test.errType) continue } // Ensure the expected number of bytes read is returned. if gotBytesRead != test.bytesRead { t.Errorf("decodeSpentTxOut (%s): unexpected number of "+ "bytes read - got %d, want %d", test.name, gotBytesRead, test.bytesRead) continue } } } // TestSpendJournalSerialization ensures serializing and deserializing spend // journal entries works as expected. func TestSpendJournalSerialization(t *testing.T) { t.Parallel() tests := []struct { name string entry []SpentTxOut blockTxns []*wire.MsgTx serialized []byte }{ // From block 2 in main blockchain. { name: "No spends", entry: nil, blockTxns: nil, serialized: nil, }, // From block 170 in main blockchain. { name: "One tx with one input spends last output of coinbase", entry: []SpentTxOut{{ Amount: 5000000000, PkScript: hexToBytes("410411db93e1dcdb8a016b49840f8c53bc1eb68a382e97b1482ecad7b148a6909a5cb2e0eaddfb84ccf9744464f82e160bfa9b8b64f9d4c03f999b8643f656b412a3ac"), IsCoinBase: true, Height: 9, }}, blockTxns: []*wire.MsgTx{{ // Coinbase omitted. Version: 1, TxIn: []*wire.TxIn{{ PreviousOutPoint: wire.OutPoint{ Hash: *newHashFromStr("0437cd7f8525ceed2324359c2d0ba26006d92d856a9c20fa0241106ee5a597c9"), Index: 0, }, SignatureScript: hexToBytes("47304402204e45e16932b8af514961a1d3a1a25fdf3f4f7732e9d624c6c61548ab5fb8cd410220181522ec8eca07de4860a4acdd12909d831cc56cbbac4622082221a8768d1d0901"), Sequence: 0xffffffff, }}, TxOut: []*wire.TxOut{{ Value: 1000000000, PkScript: hexToBytes("4104ae1a62fe09c5f51b13905f07f06b99a2f7159b2225f374cd378d71302fa28414e7aab37397f554a7df5f142c21c1b7303b8a0626f1baded5c72a704f7e6cd84cac"), }, { Value: 4000000000, PkScript: hexToBytes("410411db93e1dcdb8a016b49840f8c53bc1eb68a382e97b1482ecad7b148a6909a5cb2e0eaddfb84ccf9744464f82e160bfa9b8b64f9d4c03f999b8643f656b412a3ac"), }}, LockTime: 0, }}, serialized: hexToBytes("1300320511db93e1dcdb8a016b49840f8c53bc1eb68a382e97b1482ecad7b148a6909a5c"), }, // Adapted from block 100025 in main blockchain. { name: "Two txns when one spends last output, one doesn't", entry: []SpentTxOut{{ Amount: 34405000000, PkScript: hexToBytes("76a9146edbc6c4d31bae9f1ccc38538a114bf42de65e8688ac"), IsCoinBase: false, Height: 100024, }, { Amount: 13761000000, PkScript: hexToBytes("76a914b2fb57eadf61e106a100a7445a8c3f67898841ec88ac"), IsCoinBase: false, Height: 100024, }}, blockTxns: []*wire.MsgTx{{ // Coinbase omitted. Version: 1, TxIn: []*wire.TxIn{{ PreviousOutPoint: wire.OutPoint{ Hash: *newHashFromStr("c0ed017828e59ad5ed3cf70ee7c6fb0f426433047462477dc7a5d470f987a537"), Index: 1, }, SignatureScript: hexToBytes("493046022100c167eead9840da4a033c9a56470d7794a9bb1605b377ebe5688499b39f94be59022100fb6345cab4324f9ea0b9ee9169337534834638d818129778370f7d378ee4a325014104d962cac5390f12ddb7539507065d0def320d68c040f2e73337c3a1aaaab7195cb5c4d02e0959624d534f3c10c3cf3d73ca5065ebd62ae986b04c6d090d32627c"), Sequence: 0xffffffff, }}, TxOut: []*wire.TxOut{{ Value: 5000000, PkScript: hexToBytes("76a914f419b8db4ba65f3b6fcc233acb762ca6f51c23d488ac"), }, { Value: 34400000000, PkScript: hexToBytes("76a914cadf4fc336ab3c6a4610b75f31ba0676b7f663d288ac"), }}, LockTime: 0, }, { Version: 1, TxIn: []*wire.TxIn{{ PreviousOutPoint: wire.OutPoint{ Hash: *newHashFromStr("92fbe1d4be82f765dfabc9559d4620864b05cc897c4db0e29adac92d294e52b7"), Index: 0, }, SignatureScript: hexToBytes("483045022100e256743154c097465cf13e89955e1c9ff2e55c46051b627751dee0144183157e02201d8d4f02cde8496aae66768f94d35ce54465bd4ae8836004992d3216a93a13f00141049d23ce8686fe9b802a7a938e8952174d35dd2c2089d4112001ed8089023ab4f93a3c9fcd5bfeaa9727858bf640dc1b1c05ec3b434bb59837f8640e8810e87742"), Sequence: 0xffffffff, }}, TxOut: []*wire.TxOut{{ Value: 5000000, PkScript: hexToBytes("76a914a983ad7c92c38fc0e2025212e9f972204c6e687088ac"), }, { Value: 13756000000, PkScript: hexToBytes("76a914a6ebd69952ab486a7a300bfffdcb395dc7d47c2388ac"), }}, LockTime: 0, }}, serialized: hexToBytes("8b99700086c64700b2fb57eadf61e106a100a7445a8c3f67898841ec8b99700091f20f006edbc6c4d31bae9f1ccc38538a114bf42de65e86"), }, } for i, test := range tests { // Ensure the journal entry serializes to the expected value. gotBytes := serializeSpendJournalEntry(test.entry) if !bytes.Equal(gotBytes, test.serialized) { t.Errorf("serializeSpendJournalEntry #%d (%s): "+ "mismatched bytes - got %x, want %x", i, test.name, gotBytes, test.serialized) continue } // Deserialize to a spend journal entry. gotEntry, err := deserializeSpendJournalEntry(test.serialized, test.blockTxns) if err != nil { t.Errorf("deserializeSpendJournalEntry #%d (%s) "+ "unexpected error: %v", i, test.name, err) continue } // Ensure that the deserialized spend journal entry has the // correct properties. if !reflect.DeepEqual(gotEntry, test.entry) { t.Errorf("deserializeSpendJournalEntry #%d (%s) "+ "mismatched entries - got %v, want %v", i, test.name, gotEntry, test.entry) continue } } } // TestSpendJournalErrors performs negative tests against deserializing spend // journal entries to ensure error paths work as expected. func TestSpendJournalErrors(t *testing.T) { t.Parallel() tests := []struct { name string blockTxns []*wire.MsgTx serialized []byte errType error }{ // Adapted from block 170 in main blockchain. { name: "Force assertion due to missing stxos", blockTxns: []*wire.MsgTx{{ // Coinbase omitted. Version: 1, TxIn: []*wire.TxIn{{ PreviousOutPoint: wire.OutPoint{ Hash: *newHashFromStr("0437cd7f8525ceed2324359c2d0ba26006d92d856a9c20fa0241106ee5a597c9"), Index: 0, }, SignatureScript: hexToBytes("47304402204e45e16932b8af514961a1d3a1a25fdf3f4f7732e9d624c6c61548ab5fb8cd410220181522ec8eca07de4860a4acdd12909d831cc56cbbac4622082221a8768d1d0901"), Sequence: 0xffffffff, }}, LockTime: 0, }}, serialized: hexToBytes(""), errType: AssertError(""), }, { name: "Force deserialization error in stxos", blockTxns: []*wire.MsgTx{{ // Coinbase omitted. Version: 1, TxIn: []*wire.TxIn{{ PreviousOutPoint: wire.OutPoint{ Hash: *newHashFromStr("0437cd7f8525ceed2324359c2d0ba26006d92d856a9c20fa0241106ee5a597c9"), Index: 0, }, SignatureScript: hexToBytes("47304402204e45e16932b8af514961a1d3a1a25fdf3f4f7732e9d624c6c61548ab5fb8cd410220181522ec8eca07de4860a4acdd12909d831cc56cbbac4622082221a8768d1d0901"), Sequence: 0xffffffff, }}, LockTime: 0, }}, serialized: hexToBytes("1301320511db93e1dcdb8a016b49840f8c53bc1eb68a382e97b1482ecad7b148a6909a"), errType: errDeserialize(""), }, } for _, test := range tests { // Ensure the expected error type is returned and the returned // slice is nil. stxos, err := deserializeSpendJournalEntry(test.serialized, test.blockTxns) if reflect.TypeOf(err) != reflect.TypeOf(test.errType) { t.Errorf("deserializeSpendJournalEntry (%s): expected "+ "error type does not match - got %T, want %T", test.name, err, test.errType) continue } if stxos != nil { t.Errorf("deserializeSpendJournalEntry (%s): returned "+ "slice of spent transaction outputs is not nil", test.name) continue } } } // TestUtxoSerialization ensures serializing and deserializing unspent // transaction output entries works as expected. func TestUtxoSerialization(t *testing.T) { t.Parallel() tests := []struct { name string entry *UtxoEntry serialized []byte }{ // From tx in main blockchain: // 0e3e2357e806b6cdb1f70b54c3a3a17b6714ee1f0e68bebb44a74b1efd512098:0 { name: "height 1, coinbase", entry: &UtxoEntry{ amount: 5000000000, pkScript: hexToBytes("410496b538e853519c726a2c91e61ec11600ae1390813a627c66fb8be7947be63c52da7589379515d4e0a604f8141781e62294721166bf621e73a82cbf2342c858eeac"), blockHeight: 1, packedFlags: tfCoinBase, }, serialized: hexToBytes("03320496b538e853519c726a2c91e61ec11600ae1390813a627c66fb8be7947be63c52"), }, // From tx in main blockchain: // 0e3e2357e806b6cdb1f70b54c3a3a17b6714ee1f0e68bebb44a74b1efd512098:0 { name: "height 1, coinbase, spent", entry: &UtxoEntry{ amount: 5000000000, pkScript: hexToBytes("410496b538e853519c726a2c91e61ec11600ae1390813a627c66fb8be7947be63c52da7589379515d4e0a604f8141781e62294721166bf621e73a82cbf2342c858eeac"), blockHeight: 1, packedFlags: tfCoinBase | tfSpent, }, serialized: nil, }, // From tx in main blockchain: // 8131ffb0a2c945ecaf9b9063e59558784f9c3a74741ce6ae2a18d0571dac15bb:1 { name: "height 100001, not coinbase", entry: &UtxoEntry{ amount: 1000000, pkScript: hexToBytes("76a914ee8bd501094a7d5ca318da2506de35e1cb025ddc88ac"), blockHeight: 100001, packedFlags: 0, }, serialized: hexToBytes("8b99420700ee8bd501094a7d5ca318da2506de35e1cb025ddc"), }, // From tx in main blockchain: // 8131ffb0a2c945ecaf9b9063e59558784f9c3a74741ce6ae2a18d0571dac15bb:1 { name: "height 100001, not coinbase, spent", entry: &UtxoEntry{ amount: 1000000, pkScript: hexToBytes("76a914ee8bd501094a7d5ca318da2506de35e1cb025ddc88ac"), blockHeight: 100001, packedFlags: tfSpent, }, serialized: nil, }, } for i, test := range tests { // Ensure the utxo entry serializes to the expected value. gotBytes, err := serializeUtxoEntry(test.entry) if err != nil { t.Errorf("serializeUtxoEntry #%d (%s) unexpected "+ "error: %v", i, test.name, err) continue } if !bytes.Equal(gotBytes, test.serialized) { t.Errorf("serializeUtxoEntry #%d (%s): mismatched "+ "bytes - got %x, want %x", i, test.name, gotBytes, test.serialized) continue } // Don't try to deserialize if the test entry was spent since it // will have a nil serialization. if test.entry.IsSpent() { continue } // Deserialize to a utxo entry. utxoEntry, err := deserializeUtxoEntry(test.serialized) if err != nil { t.Errorf("deserializeUtxoEntry #%d (%s) unexpected "+ "error: %v", i, test.name, err) continue } // The deserialized entry must not be marked spent since unspent // entries are not serialized. if utxoEntry.IsSpent() { t.Errorf("deserializeUtxoEntry #%d (%s) output should "+ "not be marked spent", i, test.name) continue } // Ensure the deserialized entry has the same properties as the // ones in the test entry. if utxoEntry.Amount() != test.entry.Amount() { t.Errorf("deserializeUtxoEntry #%d (%s) mismatched "+ "amounts: got %d, want %d", i, test.name, utxoEntry.Amount(), test.entry.Amount()) continue } if !bytes.Equal(utxoEntry.PkScript(), test.entry.PkScript()) { t.Errorf("deserializeUtxoEntry #%d (%s) mismatched "+ "scripts: got %x, want %x", i, test.name, utxoEntry.PkScript(), test.entry.PkScript()) continue } if utxoEntry.BlockHeight() != test.entry.BlockHeight() { t.Errorf("deserializeUtxoEntry #%d (%s) mismatched "+ "block height: got %d, want %d", i, test.name, utxoEntry.BlockHeight(), test.entry.BlockHeight()) continue } if utxoEntry.IsCoinBase() != test.entry.IsCoinBase() { t.Errorf("deserializeUtxoEntry #%d (%s) mismatched "+ "coinbase flag: got %v, want %v", i, test.name, utxoEntry.IsCoinBase(), test.entry.IsCoinBase()) continue } } } // TestUtxoEntryHeaderCodeErrors performs negative tests against unspent // transaction output header codes to ensure error paths work as expected. func TestUtxoEntryHeaderCodeErrors(t *testing.T) { t.Parallel() tests := []struct { name string entry *UtxoEntry code uint64 errType error }{ { name: "Force assertion due to spent output", entry: &UtxoEntry{packedFlags: tfSpent}, errType: AssertError(""), }, } for _, test := range tests { // Ensure the expected error type is returned and the code is 0. code, err := utxoEntryHeaderCode(test.entry) if reflect.TypeOf(err) != reflect.TypeOf(test.errType) { t.Errorf("utxoEntryHeaderCode (%s): expected error "+ "type does not match - got %T, want %T", test.name, err, test.errType) continue } if code != 0 { t.Errorf("utxoEntryHeaderCode (%s): unexpected code "+ "on error - got %d, want 0", test.name, code) continue } } } // TestUtxoEntryDeserializeErrors performs negative tests against deserializing // unspent transaction outputs to ensure error paths work as expected. func TestUtxoEntryDeserializeErrors(t *testing.T) { t.Parallel() tests := []struct { name string serialized []byte errType error }{ { name: "no data after header code", serialized: hexToBytes("02"), errType: errDeserialize(""), }, { name: "incomplete compressed txout", serialized: hexToBytes("0232"), errType: errDeserialize(""), }, } for _, test := range tests { // Ensure the expected error type is returned and the returned // entry is nil. entry, err := deserializeUtxoEntry(test.serialized) if reflect.TypeOf(err) != reflect.TypeOf(test.errType) { t.Errorf("deserializeUtxoEntry (%s): expected error "+ "type does not match - got %T, want %T", test.name, err, test.errType) continue } if entry != nil { t.Errorf("deserializeUtxoEntry (%s): returned entry "+ "is not nil", test.name) continue } } } // TestBestChainStateSerialization ensures serializing and deserializing the // best chain state works as expected. func TestBestChainStateSerialization(t *testing.T) { t.Parallel() workSum := new(big.Int) tests := []struct { name string state bestChainState serialized []byte }{ { name: "genesis", state: bestChainState{ hash: *newHashFromStr("000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f"), height: 0, totalTxns: 1, workSum: func() *big.Int { workSum.Add(workSum, CalcWork(486604799)) return new(big.Int).Set(workSum) }(), // 0x0100010001 }, serialized: hexToBytes("6fe28c0ab6f1b372c1a6a246ae63f74f931e8365e15a089c68d6190000000000000000000100000000000000050000000100010001"), }, { name: "block 1", state: bestChainState{ hash: *newHashFromStr("00000000839a8e6886ab5951d76f411475428afc90947ee320161bbf18eb6048"), height: 1, totalTxns: 2, workSum: func() *big.Int { workSum.Add(workSum, CalcWork(486604799)) return new(big.Int).Set(workSum) }(), // 0x0200020002 }, serialized: hexToBytes("4860eb18bf1b1620e37e9490fc8a427514416fd75159ab86688e9a8300000000010000000200000000000000050000000200020002"), }, } for i, test := range tests { // Ensure the state serializes to the expected value. gotBytes := serializeBestChainState(test.state) if !bytes.Equal(gotBytes, test.serialized) { t.Errorf("serializeBestChainState #%d (%s): mismatched "+ "bytes - got %x, want %x", i, test.name, gotBytes, test.serialized) continue } // Ensure the serialized bytes are decoded back to the expected // state. state, err := deserializeBestChainState(test.serialized) if err != nil { t.Errorf("deserializeBestChainState #%d (%s) "+ "unexpected error: %v", i, test.name, err) continue } if !reflect.DeepEqual(state, test.state) { t.Errorf("deserializeBestChainState #%d (%s) "+ "mismatched state - got %v, want %v", i, test.name, state, test.state) continue } } } // TestBestChainStateDeserializeErrors performs negative tests against // deserializing the chain state to ensure error paths work as expected. func TestBestChainStateDeserializeErrors(t *testing.T) { t.Parallel() tests := []struct { name string serialized []byte errType error }{ { name: "nothing serialized", serialized: hexToBytes(""), errType: database.Error{ErrorCode: database.ErrCorruption}, }, { name: "short data in hash", serialized: hexToBytes("0000"), errType: database.Error{ErrorCode: database.ErrCorruption}, }, { name: "short data in work sum", serialized: hexToBytes("6fe28c0ab6f1b372c1a6a246ae63f74f931e8365e15a089c68d61900000000000000000001000000000000000500000001000100"), errType: database.Error{ErrorCode: database.ErrCorruption}, }, } for _, test := range tests { // Ensure the expected error type and code is returned. _, err := deserializeBestChainState(test.serialized) if reflect.TypeOf(err) != reflect.TypeOf(test.errType) { t.Errorf("deserializeBestChainState (%s): expected "+ "error type does not match - got %T, want %T", test.name, err, test.errType) continue } if derr, ok := err.(database.Error); ok { tderr := test.errType.(database.Error) if derr.ErrorCode != tderr.ErrorCode { t.Errorf("deserializeBestChainState (%s): "+ "wrong error code got: %v, want: %v", test.name, derr.ErrorCode, tderr.ErrorCode) continue } } } } ================================================ FILE: blockchain/chainview.go ================================================ // Copyright (c) 2017 The btcsuite developers // Use of this source code is governed by an ISC // license that can be found in the LICENSE file. package blockchain import ( "sync" ) // approxNodesPerWeek is an approximation of the number of new blocks there are // in a week on average. const approxNodesPerWeek = 6 * 24 * 7 // log2FloorMasks defines the masks to use when quickly calculating // floor(log2(x)) in a constant log2(32) = 5 steps, where x is a uint32, using // shifts. They are derived from (2^(2^x) - 1) * (2^(2^x)), for x in 4..0. var log2FloorMasks = []uint32{0xffff0000, 0xff00, 0xf0, 0xc, 0x2} // fastLog2Floor calculates and returns floor(log2(x)) in a constant 5 steps. func fastLog2Floor(n uint32) uint8 { rv := uint8(0) exponent := uint8(16) for i := 0; i < 5; i++ { if n&log2FloorMasks[i] != 0 { rv += exponent n >>= exponent } exponent >>= 1 } return rv } // chainView provides a flat view of a specific branch of the block chain from // its tip back to the genesis block and provides various convenience functions // for comparing chains. // // For example, assume a block chain with a side chain as depicted below: // // genesis -> 1 -> 2 -> 3 -> 4 -> 5 -> 6 -> 7 -> 8 // \-> 4a -> 5a -> 6a // // The chain view for the branch ending in 6a consists of: // // genesis -> 1 -> 2 -> 3 -> 4a -> 5a -> 6a type chainView struct { mtx sync.Mutex nodes []*blockNode } // newChainView returns a new chain view for the given tip block node. Passing // nil as the tip will result in a chain view that is not initialized. The tip // can be updated at any time via the setTip function. func newChainView(tip *blockNode) *chainView { // The mutex is intentionally not held since this is a constructor. var c chainView c.setTip(tip) return &c } // genesis returns the genesis block for the chain view. This only differs from // the exported version in that it is up to the caller to ensure the lock is // held. // // This function MUST be called with the view mutex locked (for reads). func (c *chainView) genesis() *blockNode { if len(c.nodes) == 0 { return nil } return c.nodes[0] } // Genesis returns the genesis block for the chain view. // // This function is safe for concurrent access. func (c *chainView) Genesis() *blockNode { c.mtx.Lock() genesis := c.genesis() c.mtx.Unlock() return genesis } // tip returns the current tip block node for the chain view. It will return // nil if there is no tip. This only differs from the exported version in that // it is up to the caller to ensure the lock is held. // // This function MUST be called with the view mutex locked (for reads). func (c *chainView) tip() *blockNode { if len(c.nodes) == 0 { return nil } return c.nodes[len(c.nodes)-1] } // Tip returns the current tip block node for the chain view. It will return // nil if there is no tip. // // This function is safe for concurrent access. func (c *chainView) Tip() *blockNode { c.mtx.Lock() tip := c.tip() c.mtx.Unlock() return tip } // setTip sets the chain view to use the provided block node as the current tip // and ensures the view is consistent by populating it with the nodes obtained // by walking backwards all the way to genesis block as necessary. Further // calls will only perform the minimum work needed, so switching between chain // tips is efficient. This only differs from the exported version in that it is // up to the caller to ensure the lock is held. // // This function MUST be called with the view mutex locked (for writes). func (c *chainView) setTip(node *blockNode) { if node == nil { // Keep the backing array around for potential future use. c.nodes = c.nodes[:0] return } // Create or resize the slice that will hold the block nodes to the // provided tip height. When creating the slice, it is created with // some additional capacity for the underlying array as append would do // in order to reduce overhead when extending the chain later. As long // as the underlying array already has enough capacity, simply expand or // contract the slice accordingly. The additional capacity is chosen // such that the array should only have to be extended about once a // week. needed := node.height + 1 if int32(cap(c.nodes)) < needed { nodes := make([]*blockNode, needed, needed+approxNodesPerWeek) copy(nodes, c.nodes) c.nodes = nodes } else { prevLen := int32(len(c.nodes)) c.nodes = c.nodes[0:needed] for i := prevLen; i < needed; i++ { c.nodes[i] = nil } } for node != nil && c.nodes[node.height] != node { c.nodes[node.height] = node node = node.parent } } // SetTip sets the chain view to use the provided block node as the current tip // and ensures the view is consistent by populating it with the nodes obtained // by walking backwards all the way to genesis block as necessary. Further // calls will only perform the minimum work needed, so switching between chain // tips is efficient. // // This function is safe for concurrent access. func (c *chainView) SetTip(node *blockNode) { c.mtx.Lock() c.setTip(node) c.mtx.Unlock() } // height returns the height of the tip of the chain view. It will return -1 if // there is no tip (which only happens if the chain view has not been // initialized). This only differs from the exported version in that it is up // to the caller to ensure the lock is held. // // This function MUST be called with the view mutex locked (for reads). func (c *chainView) height() int32 { return int32(len(c.nodes) - 1) } // Height returns the height of the tip of the chain view. It will return -1 if // there is no tip (which only happens if the chain view has not been // initialized). // // This function is safe for concurrent access. func (c *chainView) Height() int32 { c.mtx.Lock() height := c.height() c.mtx.Unlock() return height } // nodeByHeight returns the block node at the specified height. Nil will be // returned if the height does not exist. This only differs from the exported // version in that it is up to the caller to ensure the lock is held. // // This function MUST be called with the view mutex locked (for reads). func (c *chainView) nodeByHeight(height int32) *blockNode { if height < 0 || height >= int32(len(c.nodes)) { return nil } return c.nodes[height] } // NodeByHeight returns the block node at the specified height. Nil will be // returned if the height does not exist. // // This function is safe for concurrent access. func (c *chainView) NodeByHeight(height int32) *blockNode { c.mtx.Lock() node := c.nodeByHeight(height) c.mtx.Unlock() return node } // Equals returns whether or not two chain views are the same. Uninitialized // views (tip set to nil) are considered equal. // // This function is safe for concurrent access. func (c *chainView) Equals(other *chainView) bool { c.mtx.Lock() other.mtx.Lock() equals := len(c.nodes) == len(other.nodes) && c.tip() == other.tip() other.mtx.Unlock() c.mtx.Unlock() return equals } // contains returns whether or not the chain view contains the passed block // node. This only differs from the exported version in that it is up to the // caller to ensure the lock is held. // // This function MUST be called with the view mutex locked (for reads). func (c *chainView) contains(node *blockNode) bool { return c.nodeByHeight(node.height) == node } // Contains returns whether or not the chain view contains the passed block // node. // // This function is safe for concurrent access. func (c *chainView) Contains(node *blockNode) bool { c.mtx.Lock() contains := c.contains(node) c.mtx.Unlock() return contains } // next returns the successor to the provided node for the chain view. It will // return nil if there is no successor or the provided node is not part of the // view. This only differs from the exported version in that it is up to the // caller to ensure the lock is held. // // See the comment on the exported function for more details. // // This function MUST be called with the view mutex locked (for reads). func (c *chainView) next(node *blockNode) *blockNode { if node == nil || !c.contains(node) { return nil } return c.nodeByHeight(node.height + 1) } // Next returns the successor to the provided node for the chain view. It will // return nil if there is no successfor or the provided node is not part of the // view. // // For example, assume a block chain with a side chain as depicted below: // // genesis -> 1 -> 2 -> 3 -> 4 -> 5 -> 6 -> 7 -> 8 // \-> 4a -> 5a -> 6a // // Further, assume the view is for the longer chain depicted above. That is to // say it consists of: // // genesis -> 1 -> 2 -> 3 -> 4 -> 5 -> 6 -> 7 -> 8 // // Invoking this function with block node 5 would return block node 6 while // invoking it with block node 5a would return nil since that node is not part // of the view. // // This function is safe for concurrent access. func (c *chainView) Next(node *blockNode) *blockNode { c.mtx.Lock() next := c.next(node) c.mtx.Unlock() return next } // findFork returns the final common block between the provided node and the // the chain view. It will return nil if there is no common block. This only // differs from the exported version in that it is up to the caller to ensure // the lock is held. // // See the exported FindFork comments for more details. // // This function MUST be called with the view mutex locked (for reads). func (c *chainView) findFork(node *blockNode) *blockNode { // No fork point for node that doesn't exist. if node == nil { return nil } // When the height of the passed node is higher than the height of the // tip of the current chain view, walk backwards through the nodes of // the other chain until the heights match (or there or no more nodes in // which case there is no common node between the two). // // NOTE: This isn't strictly necessary as the following section will // find the node as well, however, it is more efficient to avoid the // contains check since it is already known that the common node can't // possibly be past the end of the current chain view. It also allows // this code to take advantage of any potential future optimizations to // the Ancestor function such as using an O(log n) skip list. chainHeight := c.height() if node.height > chainHeight { node = node.Ancestor(chainHeight) } // Walk the other chain backwards as long as the current one does not // contain the node or there are no more nodes in which case there is no // common node between the two. for node != nil && !c.contains(node) { node = node.parent } return node } // FindFork returns the final common block between the provided node and the // the chain view. It will return nil if there is no common block. // // For example, assume a block chain with a side chain as depicted below: // // genesis -> 1 -> 2 -> ... -> 5 -> 6 -> 7 -> 8 // \-> 6a -> 7a // // Further, assume the view is for the longer chain depicted above. That is to // say it consists of: // // genesis -> 1 -> 2 -> ... -> 5 -> 6 -> 7 -> 8. // // Invoking this function with block node 7a would return block node 5 while // invoking it with block node 7 would return itself since it is already part of // the branch formed by the view. // // This function is safe for concurrent access. func (c *chainView) FindFork(node *blockNode) *blockNode { c.mtx.Lock() fork := c.findFork(node) c.mtx.Unlock() return fork } // blockLocator returns a block locator for the passed block node. The passed // node can be nil in which case the block locator for the current tip // associated with the view will be returned. This only differs from the // exported version in that it is up to the caller to ensure the lock is held. // // See the exported BlockLocator function comments for more details. // // This function MUST be called with the view mutex locked (for reads). func (c *chainView) blockLocator(node *blockNode) BlockLocator { // Use the current tip if requested. if node == nil { node = c.tip() } if node == nil { return nil } // Calculate the max number of entries that will ultimately be in the // block locator. See the description of the algorithm for how these // numbers are derived. var maxEntries uint8 if node.height <= 12 { maxEntries = uint8(node.height) + 1 } else { // Requested hash itself + previous 10 entries + genesis block. // Then floor(log2(height-10)) entries for the skip portion. adjustedHeight := uint32(node.height) - 10 maxEntries = 12 + fastLog2Floor(adjustedHeight) } locator := make(BlockLocator, 0, maxEntries) step := int32(1) for node != nil { locator = append(locator, &node.hash) // Nothing more to add once the genesis block has been added. if node.height == 0 { break } // Calculate height of previous node to include ensuring the // final node is the genesis block. height := node.height - step if height < 0 { height = 0 } // When the node is in the current chain view, all of its // ancestors must be too, so use a much faster O(1) lookup in // that case. Otherwise, fall back to walking backwards through // the nodes of the other chain to the correct ancestor. if c.contains(node) { node = c.nodes[height] } else { node = node.Ancestor(height) } // Once 11 entries have been included, start doubling the // distance between included hashes. if len(locator) > 10 { step *= 2 } } return locator } // BlockLocator returns a block locator for the passed block node. The passed // node can be nil in which case the block locator for the current tip // associated with the view will be returned. // // See the BlockLocator type for details on the algorithm used to create a block // locator. // // This function is safe for concurrent access. func (c *chainView) BlockLocator(node *blockNode) BlockLocator { c.mtx.Lock() locator := c.blockLocator(node) c.mtx.Unlock() return locator } ================================================ FILE: blockchain/chainview_test.go ================================================ // Copyright (c) 2017 The btcsuite developers // Use of this source code is governed by an ISC // license that can be found in the LICENSE file. package blockchain import ( "fmt" "math/rand" "reflect" "testing" "github.com/btcsuite/btcd/wire" ) // testNoncePrng provides a deterministic prng for the nonce in generated fake // nodes. The ensures that the node have unique hashes. var testNoncePrng = rand.New(rand.NewSource(0)) // chainedNodes returns the specified number of nodes constructed such that each // subsequent node points to the previous one to create a chain. The first node // will point to the passed parent which can be nil if desired. func chainedNodes(parent *blockNode, numNodes int) []*blockNode { nodes := make([]*blockNode, numNodes) tip := parent for i := 0; i < numNodes; i++ { // This is invalid, but all that is needed is enough to get the // synthetic tests to work. header := wire.BlockHeader{Nonce: testNoncePrng.Uint32()} if tip != nil { header.PrevBlock = tip.hash } nodes[i] = newBlockNode(&header, tip) tip = nodes[i] } return nodes } // String returns the block node as a human-readable name. func (node blockNode) String() string { return fmt.Sprintf("%s(%d)", node.hash, node.height) } // tstTip is a convenience function to grab the tip of a chain of block nodes // created via chainedNodes. func tstTip(nodes []*blockNode) *blockNode { return nodes[len(nodes)-1] } // locatorHashes is a convenience function that returns the hashes for all of // the passed indexes of the provided nodes. It is used to construct expected // block locators in the tests. func locatorHashes(nodes []*blockNode, indexes ...int) BlockLocator { hashes := make(BlockLocator, 0, len(indexes)) for _, idx := range indexes { hashes = append(hashes, &nodes[idx].hash) } return hashes } // zipLocators is a convenience function that returns a single block locator // given a variable number of them and is used in the tests. func zipLocators(locators ...BlockLocator) BlockLocator { var hashes BlockLocator for _, locator := range locators { hashes = append(hashes, locator...) } return hashes } // TestChainView ensures all of the exported functionality of chain views works // as intended with the exception of some special cases which are handled in // other tests. func TestChainView(t *testing.T) { // Construct a synthetic block index consisting of the following // structure. // 0 -> 1 -> 2 -> 3 -> 4 // \-> 2a -> 3a -> 4a -> 5a -> 6a -> 7a -> ... -> 26a // \-> 3a'-> 4a' -> 5a' branch0Nodes := chainedNodes(nil, 5) branch1Nodes := chainedNodes(branch0Nodes[1], 25) branch2Nodes := chainedNodes(branch1Nodes[0], 3) tip := tstTip tests := []struct { name string view *chainView // active view genesis *blockNode // expected genesis block of active view tip *blockNode // expected tip of active view side *chainView // side chain view sideTip *blockNode // expected tip of side chain view fork *blockNode // expected fork node contains []*blockNode // expected nodes in active view noContains []*blockNode // expected nodes NOT in active view equal *chainView // view expected equal to active view unequal *chainView // view expected NOT equal to active locator BlockLocator // expected locator for active view tip }{ { // Create a view for branch 0 as the active chain and // another view for branch 1 as the side chain. name: "chain0-chain1", view: newChainView(tip(branch0Nodes)), genesis: branch0Nodes[0], tip: tip(branch0Nodes), side: newChainView(tip(branch1Nodes)), sideTip: tip(branch1Nodes), fork: branch0Nodes[1], contains: branch0Nodes, noContains: branch1Nodes, equal: newChainView(tip(branch0Nodes)), unequal: newChainView(tip(branch1Nodes)), locator: locatorHashes(branch0Nodes, 4, 3, 2, 1, 0), }, { // Create a view for branch 1 as the active chain and // another view for branch 2 as the side chain. name: "chain1-chain2", view: newChainView(tip(branch1Nodes)), genesis: branch0Nodes[0], tip: tip(branch1Nodes), side: newChainView(tip(branch2Nodes)), sideTip: tip(branch2Nodes), fork: branch1Nodes[0], contains: branch1Nodes, noContains: branch2Nodes, equal: newChainView(tip(branch1Nodes)), unequal: newChainView(tip(branch2Nodes)), locator: zipLocators( locatorHashes(branch1Nodes, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 11, 7), locatorHashes(branch0Nodes, 1, 0)), }, { // Create a view for branch 2 as the active chain and // another view for branch 0 as the side chain. name: "chain2-chain0", view: newChainView(tip(branch2Nodes)), genesis: branch0Nodes[0], tip: tip(branch2Nodes), side: newChainView(tip(branch0Nodes)), sideTip: tip(branch0Nodes), fork: branch0Nodes[1], contains: branch2Nodes, noContains: branch0Nodes[2:], equal: newChainView(tip(branch2Nodes)), unequal: newChainView(tip(branch0Nodes)), locator: zipLocators( locatorHashes(branch2Nodes, 2, 1, 0), locatorHashes(branch1Nodes, 0), locatorHashes(branch0Nodes, 1, 0)), }, } testLoop: for _, test := range tests { // Ensure the active and side chain heights are the expected // values. if test.view.Height() != test.tip.height { t.Errorf("%s: unexpected active view height -- got "+ "%d, want %d", test.name, test.view.Height(), test.tip.height) continue } if test.side.Height() != test.sideTip.height { t.Errorf("%s: unexpected side view height -- got %d, "+ "want %d", test.name, test.side.Height(), test.sideTip.height) continue } // Ensure the active and side chain genesis block is the // expected value. if test.view.Genesis() != test.genesis { t.Errorf("%s: unexpected active view genesis -- got "+ "%v, want %v", test.name, test.view.Genesis(), test.genesis) continue } if test.side.Genesis() != test.genesis { t.Errorf("%s: unexpected side view genesis -- got %v, "+ "want %v", test.name, test.view.Genesis(), test.genesis) continue } // Ensure the active and side chain tips are the expected nodes. if test.view.Tip() != test.tip { t.Errorf("%s: unexpected active view tip -- got %v, "+ "want %v", test.name, test.view.Tip(), test.tip) continue } if test.side.Tip() != test.sideTip { t.Errorf("%s: unexpected active view tip -- got %v, "+ "want %v", test.name, test.side.Tip(), test.sideTip) continue } // Ensure that regardless of the order the two chains are // compared they both return the expected fork point. forkNode := test.view.FindFork(test.side.Tip()) if forkNode != test.fork { t.Errorf("%s: unexpected fork node (view, side) -- "+ "got %v, want %v", test.name, forkNode, test.fork) continue } forkNode = test.side.FindFork(test.view.Tip()) if forkNode != test.fork { t.Errorf("%s: unexpected fork node (side, view) -- "+ "got %v, want %v", test.name, forkNode, test.fork) continue } // Ensure that the fork point for a node that is already part // of the chain view is the node itself. forkNode = test.view.FindFork(test.view.Tip()) if forkNode != test.view.Tip() { t.Errorf("%s: unexpected fork node (view, tip) -- "+ "got %v, want %v", test.name, forkNode, test.view.Tip()) continue } // Ensure all expected nodes are contained in the active view. for _, node := range test.contains { if !test.view.Contains(node) { t.Errorf("%s: expected %v in active view", test.name, node) continue testLoop } } // Ensure all nodes from side chain view are NOT contained in // the active view. for _, node := range test.noContains { if test.view.Contains(node) { t.Errorf("%s: unexpected %v in active view", test.name, node) continue testLoop } } // Ensure equality of different views into the same chain works // as intended. if !test.view.Equals(test.equal) { t.Errorf("%s: unexpected unequal views", test.name) continue } if test.view.Equals(test.unequal) { t.Errorf("%s: unexpected equal views", test.name) continue } // Ensure all nodes contained in the view return the expected // next node. for i, node := range test.contains { // Final node expects nil for the next node. var expected *blockNode if i < len(test.contains)-1 { expected = test.contains[i+1] } if next := test.view.Next(node); next != expected { t.Errorf("%s: unexpected next node -- got %v, "+ "want %v", test.name, next, expected) continue testLoop } } // Ensure nodes that are not contained in the view do not // produce a successor node. for _, node := range test.noContains { if next := test.view.Next(node); next != nil { t.Errorf("%s: unexpected next node -- got %v, "+ "want nil", test.name, next) continue testLoop } } // Ensure all nodes contained in the view can be retrieved by // height. for _, wantNode := range test.contains { node := test.view.NodeByHeight(wantNode.height) if node != wantNode { t.Errorf("%s: unexpected node for height %d -- "+ "got %v, want %v", test.name, wantNode.height, node, wantNode) continue testLoop } } // Ensure the block locator for the tip of the active view // consists of the expected hashes. locator := test.view.BlockLocator(test.view.tip()) if !reflect.DeepEqual(locator, test.locator) { t.Errorf("%s: unexpected locator -- got %v, want %v", test.name, locator, test.locator) continue } } } // TestChainViewForkCorners ensures that finding the fork between two chains // works in some corner cases such as when the two chains have completely // unrelated histories. func TestChainViewForkCorners(t *testing.T) { // Construct two unrelated single branch synthetic block indexes. branchNodes := chainedNodes(nil, 5) unrelatedBranchNodes := chainedNodes(nil, 7) // Create chain views for the two unrelated histories. view1 := newChainView(tstTip(branchNodes)) view2 := newChainView(tstTip(unrelatedBranchNodes)) // Ensure attempting to find a fork point with a node that doesn't exist // doesn't produce a node. if fork := view1.FindFork(nil); fork != nil { t.Fatalf("FindFork: unexpected fork -- got %v, want nil", fork) } // Ensure attempting to find a fork point in two chain views with // totally unrelated histories doesn't produce a node. for _, node := range branchNodes { if fork := view2.FindFork(node); fork != nil { t.Fatalf("FindFork: unexpected fork -- got %v, want nil", fork) } } for _, node := range unrelatedBranchNodes { if fork := view1.FindFork(node); fork != nil { t.Fatalf("FindFork: unexpected fork -- got %v, want nil", fork) } } } // TestChainViewSetTip ensures changing the tip works as intended including // capacity changes. func TestChainViewSetTip(t *testing.T) { // Construct a synthetic block index consisting of the following // structure. // 0 -> 1 -> 2 -> 3 -> 4 // \-> 2a -> 3a -> 4a -> 5a -> 6a -> 7a -> ... -> 26a branch0Nodes := chainedNodes(nil, 5) branch1Nodes := chainedNodes(branch0Nodes[1], 25) tip := tstTip tests := []struct { name string view *chainView // active view tips []*blockNode // tips to set contains [][]*blockNode // expected nodes in view for each tip }{ { // Create an empty view and set the tip to increasingly // longer chains. name: "increasing", view: newChainView(nil), tips: []*blockNode{tip(branch0Nodes), tip(branch1Nodes)}, contains: [][]*blockNode{branch0Nodes, branch1Nodes}, }, { // Create a view with a longer chain and set the tip to // increasingly shorter chains. name: "decreasing", view: newChainView(tip(branch1Nodes)), tips: []*blockNode{tip(branch0Nodes), nil}, contains: [][]*blockNode{branch0Nodes, nil}, }, { // Create a view with a shorter chain and set the tip to // a longer chain followed by setting it back to the // shorter chain. name: "small-large-small", view: newChainView(tip(branch0Nodes)), tips: []*blockNode{tip(branch1Nodes), tip(branch0Nodes)}, contains: [][]*blockNode{branch1Nodes, branch0Nodes}, }, { // Create a view with a longer chain and set the tip to // a smaller chain followed by setting it back to the // longer chain. name: "large-small-large", view: newChainView(tip(branch1Nodes)), tips: []*blockNode{tip(branch0Nodes), tip(branch1Nodes)}, contains: [][]*blockNode{branch0Nodes, branch1Nodes}, }, } testLoop: for _, test := range tests { for i, tip := range test.tips { // Ensure the view tip is the expected node. test.view.SetTip(tip) if test.view.Tip() != tip { t.Errorf("%s: unexpected view tip -- got %v, "+ "want %v", test.name, test.view.Tip(), tip) continue testLoop } // Ensure all expected nodes are contained in the view. for _, node := range test.contains[i] { if !test.view.Contains(node) { t.Errorf("%s: expected %v in active view", test.name, node) continue testLoop } } } } } // TestChainViewNil ensures that creating and accessing a nil chain view behaves // as expected. func TestChainViewNil(t *testing.T) { // Ensure two unininitialized views are considered equal. view := newChainView(nil) if !view.Equals(newChainView(nil)) { t.Fatal("uninitialized nil views unequal") } // Ensure the genesis of an uninitialized view does not produce a node. if genesis := view.Genesis(); genesis != nil { t.Fatalf("Genesis: unexpected genesis -- got %v, want nil", genesis) } // Ensure the tip of an uninitialized view does not produce a node. if tip := view.Tip(); tip != nil { t.Fatalf("Tip: unexpected tip -- got %v, want nil", tip) } // Ensure the height of an uninitialized view is the expected value. if height := view.Height(); height != -1 { t.Fatalf("Height: unexpected height -- got %d, want -1", height) } // Ensure attempting to get a node for a height that does not exist does // not produce a node. if node := view.NodeByHeight(10); node != nil { t.Fatalf("NodeByHeight: unexpected node -- got %v, want nil", node) } // Ensure an uninitialized view does not report it contains nodes. fakeNode := chainedNodes(nil, 1)[0] if view.Contains(fakeNode) { t.Fatalf("Contains: view claims it contains node %v", fakeNode) } // Ensure the next node for a node that does not exist does not produce // a node. if next := view.Next(nil); next != nil { t.Fatalf("Next: unexpected next node -- got %v, want nil", next) } // Ensure the next node for a node that exists does not produce a node. if next := view.Next(fakeNode); next != nil { t.Fatalf("Next: unexpected next node -- got %v, want nil", next) } // Ensure attempting to find a fork point with a node that doesn't exist // doesn't produce a node. if fork := view.FindFork(nil); fork != nil { t.Fatalf("FindFork: unexpected fork -- got %v, want nil", fork) } // Ensure attempting to get a block locator for the tip doesn't produce // one since the tip is nil. if locator := view.BlockLocator(nil); locator != nil { t.Fatalf("BlockLocator: unexpected locator -- got %v, want nil", locator) } // Ensure attempting to get a block locator for a node that exists still // works as intended. branchNodes := chainedNodes(nil, 50) wantLocator := locatorHashes(branchNodes, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 36, 32, 24, 8, 0) locator := view.BlockLocator(tstTip(branchNodes)) if !reflect.DeepEqual(locator, wantLocator) { t.Fatalf("BlockLocator: unexpected locator -- got %v, want %v", locator, wantLocator) } } ================================================ FILE: blockchain/checkpoints.go ================================================ // Copyright (c) 2013-2016 The btcsuite developers // Use of this source code is governed by an ISC // license that can be found in the LICENSE file. package blockchain import ( "fmt" "time" "github.com/btcsuite/btcd/btcutil" "github.com/btcsuite/btcd/chaincfg" "github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/btcsuite/btcd/txscript" ) // CheckpointConfirmations is the number of blocks before the end of the current // best block chain that a good checkpoint candidate must be. const CheckpointConfirmations = 2016 // newHashFromStr converts the passed big-endian hex string into a // chainhash.Hash. It only differs from the one available in chainhash in that // it ignores the error since it will only (and must only) be called with // hard-coded, and therefore known good, hashes. func newHashFromStr(hexStr string) *chainhash.Hash { hash, _ := chainhash.NewHashFromStr(hexStr) return hash } // Checkpoints returns a slice of checkpoints (regardless of whether they are // already known). When there are no checkpoints for the chain, it will return // nil. // // This function is safe for concurrent access. func (b *BlockChain) Checkpoints() []chaincfg.Checkpoint { return b.checkpoints } // HasCheckpoints returns whether this BlockChain has checkpoints defined. // // This function is safe for concurrent access. func (b *BlockChain) HasCheckpoints() bool { return len(b.checkpoints) > 0 } // LatestCheckpoint returns the most recent checkpoint (regardless of whether it // is already known). When there are no defined checkpoints for the active chain // instance, it will return nil. // // This function is safe for concurrent access. func (b *BlockChain) LatestCheckpoint() *chaincfg.Checkpoint { if !b.HasCheckpoints() { return nil } return &b.checkpoints[len(b.checkpoints)-1] } // verifyCheckpoint returns whether the passed block height and hash combination // match the checkpoint data. It also returns true if there is no checkpoint // data for the passed block height. func (b *BlockChain) verifyCheckpoint(height int32, hash *chainhash.Hash) bool { if !b.HasCheckpoints() { return true } // Nothing to check if there is no checkpoint data for the block height. checkpoint, exists := b.checkpointsByHeight[height] if !exists { return true } if !checkpoint.Hash.IsEqual(hash) { return false } log.Infof("Verified checkpoint at height %d/block %s", checkpoint.Height, checkpoint.Hash) return true } // findPreviousCheckpoint finds the most recent checkpoint that is already // available in the downloaded portion of the block chain and returns the // associated block node. It returns nil if a checkpoint can't be found (this // should really only happen for blocks before the first checkpoint). // // This function MUST be called with the chain lock held (for reads). func (b *BlockChain) findPreviousCheckpoint() (*blockNode, error) { if !b.HasCheckpoints() { return nil, nil } // Perform the initial search to find and cache the latest known // checkpoint if the best chain is not known yet or we haven't already // previously searched. checkpoints := b.checkpoints numCheckpoints := len(checkpoints) if b.checkpointNode == nil && b.nextCheckpoint == nil { // Loop backwards through the available checkpoints to find one // that is already available. for i := numCheckpoints - 1; i >= 0; i-- { node := b.index.LookupNode(checkpoints[i].Hash) if node == nil || !b.bestChain.Contains(node) { continue } // Checkpoint found. Cache it for future lookups and // set the next expected checkpoint accordingly. b.checkpointNode = node if i < numCheckpoints-1 { b.nextCheckpoint = &checkpoints[i+1] } return b.checkpointNode, nil } // No known latest checkpoint. This will only happen on blocks // before the first known checkpoint. So, set the next expected // checkpoint to the first checkpoint and return the fact there // is no latest known checkpoint block. b.nextCheckpoint = &checkpoints[0] return nil, nil } // At this point we've already searched for the latest known checkpoint, // so when there is no next checkpoint, the current checkpoint lockin // will always be the latest known checkpoint. if b.nextCheckpoint == nil { return b.checkpointNode, nil } // When there is a next checkpoint and the height of the current best // chain does not exceed it, the current checkpoint lockin is still // the latest known checkpoint. if b.bestChain.Tip().height < b.nextCheckpoint.Height { return b.checkpointNode, nil } // We've reached or exceeded the next checkpoint height. Note that // once a checkpoint lockin has been reached, forks are prevented from // any blocks before the checkpoint, so we don't have to worry about the // checkpoint going away out from under us due to a chain reorganize. // Cache the latest known checkpoint for future lookups. Note that if // this lookup fails something is very wrong since the chain has already // passed the checkpoint which was verified as accurate before inserting // it. checkpointNode := b.index.LookupNode(b.nextCheckpoint.Hash) if checkpointNode == nil { return nil, AssertError(fmt.Sprintf("findPreviousCheckpoint "+ "failed lookup of known good block node %s", b.nextCheckpoint.Hash)) } b.checkpointNode = checkpointNode // Set the next expected checkpoint. checkpointIndex := -1 for i := numCheckpoints - 1; i >= 0; i-- { if checkpoints[i].Hash.IsEqual(b.nextCheckpoint.Hash) { checkpointIndex = i break } } b.nextCheckpoint = nil if checkpointIndex != -1 && checkpointIndex < numCheckpoints-1 { b.nextCheckpoint = &checkpoints[checkpointIndex+1] } return b.checkpointNode, nil } // isNonstandardTransaction determines whether a transaction contains any // scripts which are not one of the standard types. func isNonstandardTransaction(tx *btcutil.Tx) bool { // Check all of the output public key scripts for non-standard scripts. for _, txOut := range tx.MsgTx().TxOut { scriptClass := txscript.GetScriptClass(txOut.PkScript) if scriptClass == txscript.NonStandardTy { return true } } return false } // IsCheckpointCandidate returns whether or not the passed block is a good // checkpoint candidate. // // The factors used to determine a good checkpoint are: // - The block must be in the main chain // - The block must be at least 'CheckpointConfirmations' blocks prior to the // current end of the main chain // - The timestamps for the blocks before and after the checkpoint must have // timestamps which are also before and after the checkpoint, respectively // (due to the median time allowance this is not always the case) // - The block must not contain any strange transaction such as those with // nonstandard scripts // // The intent is that candidates are reviewed by a developer to make the final // decision and then manually added to the list of checkpoints for a network. // // This function is safe for concurrent access. func (b *BlockChain) IsCheckpointCandidate(block *btcutil.Block) (bool, error) { b.chainLock.RLock() defer b.chainLock.RUnlock() // A checkpoint must be in the main chain. node := b.index.LookupNode(block.Hash()) if node == nil || !b.bestChain.Contains(node) { return false, nil } // Ensure the height of the passed block and the entry for the block in // the main chain match. This should always be the case unless the // caller provided an invalid block. if node.height != block.Height() { return false, fmt.Errorf("passed block height of %d does not "+ "match the main chain height of %d", block.Height(), node.height) } // A checkpoint must be at least CheckpointConfirmations blocks // before the end of the main chain. mainChainHeight := b.bestChain.Tip().height if node.height > (mainChainHeight - CheckpointConfirmations) { return false, nil } // A checkpoint must be have at least one block after it. // // This should always succeed since the check above already made sure it // is CheckpointConfirmations back, but be safe in case the constant // changes. nextNode := b.bestChain.Next(node) if nextNode == nil { return false, nil } // A checkpoint must be have at least one block before it. if node.parent == nil { return false, nil } // A checkpoint must have timestamps for the block and the blocks on // either side of it in order (due to the median time allowance this is // not always the case). prevTime := time.Unix(node.parent.timestamp, 0) curTime := block.MsgBlock().Header.Timestamp nextTime := time.Unix(nextNode.timestamp, 0) if prevTime.After(curTime) || nextTime.Before(curTime) { return false, nil } // A checkpoint must have transactions that only contain standard // scripts. for _, tx := range block.Transactions() { if isNonstandardTransaction(tx) { return false, nil } } // All of the checks passed, so the block is a candidate. return true, nil } ================================================ FILE: blockchain/common_test.go ================================================ // Copyright (c) 2013-2017 The btcsuite developers // Use of this source code is governed by an ISC // license that can be found in the LICENSE file. package blockchain import ( "compress/bzip2" "encoding/binary" "fmt" "io" "os" "path/filepath" "strings" "time" "github.com/btcsuite/btcd/blockchain/internal/testhelper" "github.com/btcsuite/btcd/btcutil" "github.com/btcsuite/btcd/chaincfg" "github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/btcsuite/btcd/database" _ "github.com/btcsuite/btcd/database/ffldb" "github.com/btcsuite/btcd/txscript" "github.com/btcsuite/btcd/wire" ) const ( // testDbType is the database backend type to use for the tests. testDbType = "ffldb" // testDbRoot is the root directory used to create all test databases. testDbRoot = "testdbs" // blockDataNet is the expected network in the test block data. blockDataNet = wire.MainNet ) // filesExists returns whether or not the named file or directory exists. func fileExists(name string) bool { if _, err := os.Stat(name); err != nil { if os.IsNotExist(err) { return false } } return true } // isSupportedDbType returns whether or not the passed database type is // currently supported. func isSupportedDbType(dbType string) bool { supportedDrivers := database.SupportedDrivers() for _, driver := range supportedDrivers { if dbType == driver { return true } } return false } // loadBlocks reads files containing bitcoin block data (gzipped but otherwise // in the format bitcoind writes) from disk and returns them as an array of // btcutil.Block. This is largely borrowed from the test code in btcdb. func loadBlocks(filename string) (blocks []*btcutil.Block, err error) { filename = filepath.Join("testdata/", filename) var network = wire.MainNet var dr io.Reader var fi io.ReadCloser fi, err = os.Open(filename) if err != nil { return } if strings.HasSuffix(filename, ".bz2") { dr = bzip2.NewReader(fi) } else { dr = fi } defer fi.Close() var block *btcutil.Block err = nil for height := int64(1); err == nil; height++ { var rintbuf uint32 err = binary.Read(dr, binary.LittleEndian, &rintbuf) if err == io.EOF { // hit end of file at expected offset: no warning height-- err = nil break } if err != nil { break } if rintbuf != uint32(network) { break } err = binary.Read(dr, binary.LittleEndian, &rintbuf) blocklen := rintbuf rbytes := make([]byte, blocklen) // read block dr.Read(rbytes) block, err = btcutil.NewBlockFromBytes(rbytes) if err != nil { return } blocks = append(blocks, block) } return } // chainSetup is used to create a new db and chain instance with the genesis // block already inserted. In addition to the new chain instance, it returns // a teardown function the caller should invoke when done testing to clean up. func chainSetup(dbName string, params *chaincfg.Params) (*BlockChain, func(), error) { if !isSupportedDbType(testDbType) { return nil, nil, fmt.Errorf("unsupported db type %v", testDbType) } // Handle memory database specially since it doesn't need the disk // specific handling. var db database.DB var teardown func() if testDbType == "memdb" { ndb, err := database.Create(testDbType) if err != nil { return nil, nil, fmt.Errorf("error creating db: %v", err) } db = ndb // Setup a teardown function for cleaning up. This function is // returned to the caller to be invoked when it is done testing. teardown = func() { db.Close() } } else { // Create the root directory for test databases. if !fileExists(testDbRoot) { if err := os.MkdirAll(testDbRoot, 0700); err != nil { err := fmt.Errorf("unable to create test db "+ "root: %v", err) return nil, nil, err } } // Create a new database to store the accepted blocks into. dbPath := filepath.Join(testDbRoot, dbName) _ = os.RemoveAll(dbPath) ndb, err := database.Create(testDbType, dbPath, blockDataNet) if err != nil { return nil, nil, fmt.Errorf("error creating db: %v", err) } db = ndb // Setup a teardown function for cleaning up. This function is // returned to the caller to be invoked when it is done testing. teardown = func() { db.Close() os.RemoveAll(dbPath) os.RemoveAll(testDbRoot) } } // Copy the chain params to ensure any modifications the tests do to // the chain parameters do not affect the global instance. paramsCopy := *params // Create the main chain instance. chain, err := New(&Config{ DB: db, ChainParams: ¶msCopy, Checkpoints: nil, TimeSource: NewMedianTime(), SigCache: txscript.NewSigCache(1000), }) if err != nil { teardown() err := fmt.Errorf("failed to create chain instance: %v", err) return nil, nil, err } return chain, teardown, nil } // loadUtxoView returns a utxo view loaded from a file. func loadUtxoView(filename string) (*UtxoViewpoint, error) { // The utxostore file format is: // // // The output index and serialized utxo len are little endian uint32s // and the serialized utxo uses the format described in chainio.go. filename = filepath.Join("testdata", filename) fi, err := os.Open(filename) if err != nil { return nil, err } // Choose read based on whether the file is compressed or not. var r io.Reader if strings.HasSuffix(filename, ".bz2") { r = bzip2.NewReader(fi) } else { r = fi } defer fi.Close() view := NewUtxoViewpoint() for { // Hash of the utxo entry. var hash chainhash.Hash _, err := io.ReadAtLeast(r, hash[:], len(hash[:])) if err != nil { // Expected EOF at the right offset. if err == io.EOF { break } return nil, err } // Output index of the utxo entry. var index uint32 err = binary.Read(r, binary.LittleEndian, &index) if err != nil { return nil, err } // Num of serialized utxo entry bytes. var numBytes uint32 err = binary.Read(r, binary.LittleEndian, &numBytes) if err != nil { return nil, err } // Serialized utxo entry. serialized := make([]byte, numBytes) _, err = io.ReadAtLeast(r, serialized, int(numBytes)) if err != nil { return nil, err } // Deserialize it and add it to the view. entry, err := deserializeUtxoEntry(serialized) if err != nil { return nil, err } view.Entries()[wire.OutPoint{Hash: hash, Index: index}] = entry } return view, nil } // convertUtxoStore reads a utxostore from the legacy format and writes it back // out using the latest format. It is only useful for converting utxostore data // used in the tests, which has already been done. However, the code is left // available for future reference. func convertUtxoStore(r io.Reader, w io.Writer) error { // The old utxostore file format was: // // // The serialized utxo len was a little endian uint32 and the serialized // utxo uses the format described in upgrade.go. littleEndian := binary.LittleEndian for { // Hash of the utxo entry. var hash chainhash.Hash _, err := io.ReadAtLeast(r, hash[:], len(hash[:])) if err != nil { // Expected EOF at the right offset. if err == io.EOF { break } return err } // Num of serialized utxo entry bytes. var numBytes uint32 err = binary.Read(r, littleEndian, &numBytes) if err != nil { return err } // Serialized utxo entry. serialized := make([]byte, numBytes) _, err = io.ReadAtLeast(r, serialized, int(numBytes)) if err != nil { return err } // Deserialize the entry. entries, err := deserializeUtxoEntryV0(serialized) if err != nil { return err } // Loop through all of the utxos and write them out in the new // format. for outputIdx, entry := range entries { // Reserialize the entries using the new format. serialized, err := serializeUtxoEntry(entry) if err != nil { return err } // Write the hash of the utxo entry. _, err = w.Write(hash[:]) if err != nil { return err } // Write the output index of the utxo entry. err = binary.Write(w, littleEndian, outputIdx) if err != nil { return err } // Write num of serialized utxo entry bytes. err = binary.Write(w, littleEndian, uint32(len(serialized))) if err != nil { return err } // Write the serialized utxo. _, err = w.Write(serialized) if err != nil { return err } } } return nil } // TstSetCoinbaseMaturity makes the ability to set the coinbase maturity // available when running tests. func (b *BlockChain) TstSetCoinbaseMaturity(maturity uint16) { b.chainParams.CoinbaseMaturity = maturity } // newFakeChain returns a chain that is usable for synthetic tests. It is // important to note that this chain has no database associated with it, so // it is not usable with all functions and the tests must take care when making // use of it. func newFakeChain(params *chaincfg.Params) *BlockChain { // Create a genesis block node and block index index populated with it // for use when creating the fake chain below. node := newBlockNode(¶ms.GenesisBlock.Header, nil) index := newBlockIndex(nil, params) index.AddNode(node) targetTimespan := int64(params.TargetTimespan / time.Second) targetTimePerBlock := int64(params.TargetTimePerBlock / time.Second) adjustmentFactor := params.RetargetAdjustmentFactor b := &BlockChain{ chainParams: params, timeSource: NewMedianTime(), minRetargetTimespan: targetTimespan / adjustmentFactor, maxRetargetTimespan: targetTimespan * adjustmentFactor, blocksPerRetarget: int32(targetTimespan / targetTimePerBlock), index: index, bestChain: newChainView(node), warningCaches: newThresholdCaches(vbNumBits), deploymentCaches: newThresholdCaches(chaincfg.DefinedDeployments), } for _, deployment := range params.Deployments { deploymentStarter := deployment.DeploymentStarter if clockStarter, ok := deploymentStarter.(chaincfg.ClockConsensusDeploymentStarter); ok { clockStarter.SynchronizeClock(b) } deploymentEnder := deployment.DeploymentEnder if clockEnder, ok := deploymentEnder.(chaincfg.ClockConsensusDeploymentEnder); ok { clockEnder.SynchronizeClock(b) } } return b } // newFakeNode creates a block node connected to the passed parent with the // provided fields populated and fake values for the other fields. func newFakeNode(parent *blockNode, blockVersion int32, bits uint32, timestamp time.Time) *blockNode { // Make up a header and create a block node from it. header := &wire.BlockHeader{ Version: blockVersion, PrevBlock: parent.hash, Bits: bits, Timestamp: timestamp, } return newBlockNode(header, parent) } // addBlock adds a block to the blockchain that succeeds the previous block. // The blocks spends all the provided spendable outputs. The new block and // the new spendable outputs created in the block are returned. func addBlock(chain *BlockChain, prev *btcutil.Block, spends []*testhelper.SpendableOut) ( *btcutil.Block, []*testhelper.SpendableOut, error) { block, outs, err := newBlock(chain, prev, spends) if err != nil { return nil, nil, err } _, _, err = chain.ProcessBlock(block, BFNone) if err != nil { return nil, nil, err } return block, outs, nil } // calcMerkleRoot creates a merkle tree from the slice of transactions and // returns the root of the tree. func calcMerkleRoot(txns []*wire.MsgTx) chainhash.Hash { if len(txns) == 0 { return chainhash.Hash{} } utilTxns := make([]*btcutil.Tx, 0, len(txns)) for _, tx := range txns { utilTxns = append(utilTxns, btcutil.NewTx(tx)) } return CalcMerkleRoot(utilTxns, false) } // newBlock creates a block to the blockchain that succeeds the previous block. // The blocks spends all the provided spendable outputs. The new block and the // newly spendable outputs created in the block are returned. func newBlock(chain *BlockChain, prev *btcutil.Block, spends []*testhelper.SpendableOut) (*btcutil.Block, []*testhelper.SpendableOut, error) { blockHeight := prev.Height() + 1 txns := make([]*wire.MsgTx, 0, 1+len(spends)) // Create and add coinbase tx. cb := testhelper.CreateCoinbaseTx(blockHeight, CalcBlockSubsidy(blockHeight, chain.chainParams)) txns = append(txns, cb) // Spend all txs to be spent. for _, spend := range spends { cb.TxOut[0].Value += int64(testhelper.LowFee) spendTx := testhelper.CreateSpendTx(spend, testhelper.LowFee) txns = append(txns, spendTx) } // Use a timestamp that is one second after the previous block unless // this is the first block in which case the current time is used. var ts time.Time if blockHeight == 1 { ts = time.Unix(time.Now().Unix(), 0) } else { ts = prev.MsgBlock().Header.Timestamp.Add(time.Second) } // Create the block. The nonce will be solved in the below code in // SolveBlock. block := btcutil.NewBlock(&wire.MsgBlock{ Header: wire.BlockHeader{ Version: 1, PrevBlock: *prev.Hash(), MerkleRoot: calcMerkleRoot(txns), Bits: chain.chainParams.PowLimitBits, Timestamp: ts, Nonce: 0, // To be solved. }, Transactions: txns, }) block.SetHeight(blockHeight) // Solve the block. if !testhelper.SolveBlock(&block.MsgBlock().Header) { return nil, nil, fmt.Errorf("Unable to solve block at height %d", blockHeight) } // Create spendable outs to return. outs := make([]*testhelper.SpendableOut, len(txns)) for i, tx := range txns { out := testhelper.MakeSpendableOutForTx(tx, 0) outs[i] = &out } return block, outs, nil } ================================================ FILE: blockchain/compress.go ================================================ // Copyright (c) 2015-2016 The btcsuite developers // Use of this source code is governed by an ISC // license that can be found in the LICENSE file. package blockchain import ( "github.com/btcsuite/btcd/btcec/v2" "github.com/btcsuite/btcd/txscript" ) // ----------------------------------------------------------------------------- // A variable length quantity (VLQ) is an encoding that uses an arbitrary number // of binary octets to represent an arbitrarily large integer. The scheme // employs a most significant byte (MSB) base-128 encoding where the high bit in // each byte indicates whether or not the byte is the final one. In addition, // to ensure there are no redundant encodings, an offset is subtracted every // time a group of 7 bits is shifted out. Therefore each integer can be // represented in exactly one way, and each representation stands for exactly // one integer. // // Another nice property of this encoding is that it provides a compact // representation of values that are typically used to indicate sizes. For // example, the values 0 - 127 are represented with a single byte, 128 - 16511 // with two bytes, and 16512 - 2113663 with three bytes. // // While the encoding allows arbitrarily large integers, it is artificially // limited in this code to an unsigned 64-bit integer for efficiency purposes. // // Example encodings: // 0 -> [0x00] // 127 -> [0x7f] * Max 1-byte value // 128 -> [0x80 0x00] // 129 -> [0x80 0x01] // 255 -> [0x80 0x7f] // 256 -> [0x81 0x00] // 16511 -> [0xff 0x7f] * Max 2-byte value // 16512 -> [0x80 0x80 0x00] // 32895 -> [0x80 0xff 0x7f] // 2113663 -> [0xff 0xff 0x7f] * Max 3-byte value // 270549119 -> [0xff 0xff 0xff 0x7f] * Max 4-byte value // 2^64-1 -> [0x80 0xfe 0xfe 0xfe 0xfe 0xfe 0xfe 0xfe 0xfe 0x7f] // // References: // https://en.wikipedia.org/wiki/Variable-length_quantity // http://www.codecodex.com/wiki/Variable-Length_Integers // ----------------------------------------------------------------------------- // serializeSizeVLQ returns the number of bytes it would take to serialize the // passed number as a variable-length quantity according to the format described // above. func serializeSizeVLQ(n uint64) int { size := 1 for ; n > 0x7f; n = (n >> 7) - 1 { size++ } return size } // putVLQ serializes the provided number to a variable-length quantity according // to the format described above and returns the number of bytes of the encoded // value. The result is placed directly into the passed byte slice which must // be at least large enough to handle the number of bytes returned by the // serializeSizeVLQ function or it will panic. func putVLQ(target []byte, n uint64) int { offset := 0 for ; ; offset++ { // The high bit is set when another byte follows. highBitMask := byte(0x80) if offset == 0 { highBitMask = 0x00 } target[offset] = byte(n&0x7f) | highBitMask if n <= 0x7f { break } n = (n >> 7) - 1 } // Reverse the bytes so it is MSB-encoded. for i, j := 0, offset; i < j; i, j = i+1, j-1 { target[i], target[j] = target[j], target[i] } return offset + 1 } // deserializeVLQ deserializes the provided variable-length quantity according // to the format described above. It also returns the number of bytes // deserialized. func deserializeVLQ(serialized []byte) (uint64, int) { var n uint64 var size int for _, val := range serialized { size++ n = (n << 7) | uint64(val&0x7f) if val&0x80 != 0x80 { break } n++ } return n, size } // ----------------------------------------------------------------------------- // In order to reduce the size of stored scripts, a domain specific compression // algorithm is used which recognizes standard scripts and stores them using // less bytes than the original script. The compression algorithm used here was // obtained from Bitcoin Core, so all credits for the algorithm go to it. // // The general serialized format is: // //