[NOD-1320] Flush UTXOs to disk (#902)

* [NOD-1320] Flush UTXOs to disk.

* [NOD-1320] Minor improvements and fixes.

* FullUTXOSet: change size type from int64 to uint64.
* Rename FullUTXOSet.size to FullUTXOSet.estimatedSize
* Fill NewFullUTXOSetFromContext with db context on virtual block
  creation.
* Typo fixes.

* [NOD-1320] Stylystic fixes.

* [NOD-1320] Update tests. Improvements and fixes.

* Update blockdag/dag tests: prepare DB for tests.
* Update blockdag/utxoset tests: prepare DB for tests.
* Update blockdag/test_utils utils.
* Update blockdag/common tests.
* FullUTXOSet: remove embedded utxoCollection type. Rename
  utxoCollection to utxoCache.
* Fix blockdag/block_utxo genesisPastUTXO func.
* Minor fixes and improvements.
This commit is contained in:
Kirill
2020-09-27 13:16:11 +03:00
committed by GitHub
parent f8d0f7f67a
commit aea3baf897
13 changed files with 251 additions and 89 deletions

View File

@@ -36,6 +36,18 @@ func RemoveFromUTXOSet(context Context, outpointKey []byte) error {
return accessor.Delete(key)
}
// GetFromUTXOSet return the given outpoint from the
// database's UTXO set.
func GetFromUTXOSet(context Context, outpointKey []byte) ([]byte, error) {
accessor, err := context.accessor()
if err != nil {
return nil, err
}
key := utxoKey(outpointKey)
return accessor.Get(key)
}
// UTXOSetCursor opens a cursor over all the UTXO entries
// that have been previously added to the database.
func UTXOSetCursor(context Context) (database.Cursor, error) {