Bitcoin ABC
0.26.3
P2P Digital Currency
Loading...
Searching...
No Matches
src
avalanche
compactproofs.cpp
Go to the documentation of this file.
1
// Copyright (c) 2022 The Bitcoin developers
2
// Distributed under the MIT software license, see the accompanying
3
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4
5
#include <
avalanche/compactproofs.h
>
6
7
#include <
avalanche/proofid.h
>
8
#include <
crypto/siphash.h
>
9
10
namespace
avalanche
{
11
12
CompactProofs::CompactProofs
(
13
const
RadixTree<const Proof, ProofRadixTreeAdapter>
&
proofs
)
14
:
CompactProofs
() {
15
proofs
.forEachLeaf([&](
auto
pLeaf
) {
16
shortproofids
.push_back(
getShortID
(
pLeaf
->getId()));
17
return
true
;
18
});
19
}
20
21
uint64_t
CompactProofs::getShortID
(
const
ProofId
&proofid)
const
{
22
static_assert
(
SHORTPROOFIDS_LENGTH
== 6,
23
"shortproofids calculation assumes 6-byte shortproofids"
);
24
return
SipHashUint256
(
shortproofidk0
,
shortproofidk1
, proofid) &
25
0xffffffffffffL;
26
}
27
28
}
// namespace avalanche
avalanche::CompactProofs
Definition
compactproofs.h:54
avalanche::CompactProofs::CompactProofs
CompactProofs()
Definition
compactproofs.h:63
avalanche::CompactProofs::getShortID
uint64_t getShortID(const ProofId &proofid) const
Definition
compactproofs.cpp:21
avalanche::CompactProofs::shortproofids
std::vector< uint64_t > shortproofids
Definition
compactproofs.h:57
avalanche::CompactProofs::shortproofidk1
uint64_t shortproofidk1
Definition
compactproofs.h:56
avalanche::CompactProofs::shortproofidk0
uint64_t shortproofidk0
Definition
compactproofs.h:56
avalanche::CompactProofs::SHORTPROOFIDS_LENGTH
static constexpr int SHORTPROOFIDS_LENGTH
Definition
compactproofs.h:61
compactproofs.h
avalanche
Definition
avalanche.h:13
proofid.h
GetRand
T GetRand(T nMax=std::numeric_limits< T >::max()) noexcept
Generate a uniform random integer of type T in the range [0..nMax) nMax defaults to std::numeric_limi...
Definition
random.h:85
SipHashUint256
uint64_t SipHashUint256(uint64_t k0, uint64_t k1, const uint256 &val)
Optimized SipHash-2-4 implementation for uint256.
Definition
siphash.cpp:99
siphash.h
RadixTree
This is a radix tree storing values identified by a unique key.
Definition
radix.h:40
avalanche::ProofId
Definition
proofid.h:17
Generated on Fri Dec 27 2024 02:38:13 for Bitcoin ABC by
1.9.8