Skip to content

Commit 36d00ad

Browse files
committed
Add UtxoSetHash file to manage UTXO set hashes
The UtxoSetHash is implemented as an index (subclass of BaseIndex) and maintains data in LevelDB. It keeps the muhash for each block in the database and also allows to search them by block hash or height. It also maintains the global Muhash object which is being modified as new blocks get added to the chain or as reorgs happen. This commit also adds a serialization method to the Muhash object to be able to persist it between restarts of the node.
1 parent d3b1d40 commit 36d00ad

File tree

4 files changed

+443
-0
lines changed

4 files changed

+443
-0
lines changed

src/Makefile.am

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ BITCOIN_CORE_H = \
135135
index/base.h \
136136
index/blockfilterindex.h \
137137
index/txindex.h \
138+
index/utxosethash.h \
138139
indirectmap.h \
139140
init.h \
140141
interfaces/chain.h \
@@ -270,6 +271,7 @@ libbitcoin_server_a_SOURCES = \
270271
index/base.cpp \
271272
index/blockfilterindex.cpp \
272273
index/txindex.cpp \
274+
index/utxosethash.cpp \
273275
interfaces/chain.cpp \
274276
interfaces/node.cpp \
275277
init.cpp \

src/crypto/muhash.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#endif
1111

1212
#include <stdint.h>
13+
#include <serialize.h>
1314

1415
struct Num3072 {
1516
#ifdef HAVE___INT128
@@ -47,6 +48,15 @@ class MuHash3072
4748

4849
/* Finalize into a 384-byte hash. Does not change this object's value. */
4950
void Finalize(unsigned char* hash384) noexcept;
51+
52+
ADD_SERIALIZE_METHODS;
53+
54+
template <typename Stream, typename Operation>
55+
inline void SerializationOp(Stream& s, Operation ser_action) {
56+
for(int i = 0; i<data.LIMBS; i++) {
57+
READWRITE(data.limbs[i]);
58+
}
59+
}
5060
};
5161

5262
#endif // BITCOIN_CRYPTO_MUHASH_H

0 commit comments

Comments
 (0)