mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-06-04 10:12:28 +02:00
refactor: Unify asmap version calculation and naming
Calculate the asmap version only in one place: A dedicated function in util/asmap. The version was also referred to as asmap checksum in several places. To avoid confusion call it asmap version everywhere.
This commit is contained in:
@@ -5,9 +5,11 @@
|
||||
#include <util/asmap.h>
|
||||
|
||||
#include <clientversion.h>
|
||||
#include <hash.h>
|
||||
#include <logging.h>
|
||||
#include <serialize.h>
|
||||
#include <streams.h>
|
||||
#include <uint256.h>
|
||||
#include <util/fs.h>
|
||||
|
||||
#include <algorithm>
|
||||
@@ -223,3 +225,12 @@ std::vector<std::byte> DecodeAsmap(fs::path path)
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
uint256 AsmapVersion(const std::vector<std::byte>& data)
|
||||
{
|
||||
if (data.empty()) return {};
|
||||
|
||||
HashWriter asmap_hasher;
|
||||
asmap_hasher << data;
|
||||
return asmap_hasher.GetHash();
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#ifndef BITCOIN_UTIL_ASMAP_H
|
||||
#define BITCOIN_UTIL_ASMAP_H
|
||||
|
||||
#include <uint256.h>
|
||||
#include <util/fs.h>
|
||||
|
||||
#include <cstddef>
|
||||
@@ -17,5 +18,7 @@ bool SanityCheckASMap(const std::vector<std::byte>& asmap, int bits);
|
||||
|
||||
/** Read asmap from provided binary file */
|
||||
std::vector<std::byte> DecodeAsmap(fs::path path);
|
||||
/** Calculate the asmap version, a checksum identifying the asmap being used. */
|
||||
uint256 AsmapVersion(const std::vector<std::byte>& data);
|
||||
|
||||
#endif // BITCOIN_UTIL_ASMAP_H
|
||||
|
||||
Reference in New Issue
Block a user