Bitcoin ABC
0.30.5
P2P Digital Currency
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
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< const Proof, ProofRadixTreeAdapter >
RadixTree::forEachLeaf
bool forEachLeaf(Callable &&func) const
Definition:
radix.h:144
avalanche::ProofId
Definition:
proofid.h:17
Generated on Wed Nov 20 2024 17:55:57 for Bitcoin ABC by
1.9.4