dcrd/internal/netsync
Ryan Staudt 2c07da6e8e multi: Update UtxoBackend to use leveldb directly.
This updates the UtxoBackend implementation to use leveldb directly
rather than using the database package.  This results in reduced memory
usage and improved processing time since it avoids the overhead of
things that the database package provides, such as caching with periodic
flushing, that are not needed for the UtxoBackend since it has its own
caching layer (UtxoCache).

An overview of the changes is as follows:

- Introduce simple UTXO key sets to be used for constructing prefixes of
  database keys rather than using the "buckets" concept that the
  database package uses
  - All keys in the UTXO backend now start with a serialized prefix
    consisting of the key set (1 byte) and version of that key set (1
    byte)
- Add migration to move all keys in the UTXO backend from buckets to the
  newly defined key sets
- Add Get function to the UtxoBackend interface and corresponding
  implementation in LevelDbUtxoBackend to allow for directly retrieving
  the value for a given key
- Add NewIterator function to the UtxoBackend interface and
  corresponding implementation in LevelDbUtxoBackend to allow for
  iterating over the key/value pairs in the UtxoBackend
- Add Update function to the UtxoBackend interface and corresponding
  implementation in LevelDbUtxoBackend to allow for directly updating
  values in the UtxoBackend in the context of a transaction
- Update LevelDbUtxoBackend to use an underlying leveldb.DB instance
  rather than a database.DB instance
- Update all LevelDbUtxoBackend methods to use the Get, NewIterator, and
  Update functions rather than the database package functions
- Update all database queries to use keys with the new key set prefixes
  rather than bucketized keys
- Update dbFetchUtxoBackendInfo to check the legacy bucket for database
  info if it doesn't exist in the new location
- Update upgrade logic to use the UtxoBackend interface rather than the
  concrete LevelDbUtxoBackend type
- Update all tests to create leveldb.DB databases instead of database.DB
  databases for the UtxoBackend
2021-07-30 16:20:26 -05:00
..
doc.go netsync: Add package documentation. 2020-12-15 13:26:57 -06:00
interface.go netsync/server: Update peer heights directly. 2021-01-07 17:15:36 -06:00
log.go multi: Add chain verify progress percentage. 2021-01-21 23:30:35 -06:00
manager.go multi: Update UtxoBackend to use leveldb directly. 2021-07-30 16:20:26 -05:00
README.md netsync: Add package documentation. 2020-12-15 13:26:57 -06:00

netsync

Build Status ISC License Doc

Package netsync implements a concurrency safe block syncing protocol.

Overview

The provided implementation of SyncManager communicates with connected peers to perform an initial block download, keep the chain in sync, and announce new blocks connected to the chain. Currently the sync manager selects a single sync peer that it downloads all blocks from until it is up to date with the longest chain the sync peer is aware of.

License

Package netsync is licensed under the copyfree ISC License.