File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ #include < swiftsync.h>
2+ using namespace swiftsync ;
3+
4+ HintsfileWriter::HintsfileWriter (AutoFile& file) : m_file(file.release())
5+ {
6+ m_file << FILE_MAGIC;
7+ m_file << FILE_VERSION;
8+ }
9+
10+ bool HintsfileWriter::WriteStopHeight (uint32_t stop)
11+ {
12+ m_file << stop;
13+ return m_file.Commit ();
14+ }
15+
16+ bool HintsfileWriter::WriteHints (const EliasFano& ef)
17+ {
18+ m_file << ef;
19+ return m_file.Commit ();
20+ }
Original file line number Diff line number Diff line change 66
77#include < serialize.h>
88#include < span.h>
9+ #include < streams.h>
910
1011#include < algorithm>
1112#include < array>
@@ -204,6 +205,30 @@ class EliasFano
204205 }
205206};
206207
208+ /* *
209+ * Simple wrapper class to assist in writing UTXO set hints to file.
210+ *
211+ * The hints of a block are represented as the Elias-Fano encoding of the indices within a block that will remain unspent.
212+ */
213+ class HintsfileWriter
214+ {
215+ private:
216+ AutoFile m_file;
217+
218+ public:
219+ /* *
220+ * Write the file magic and version number to file.
221+ */
222+ HintsfileWriter (AutoFile& file);
223+ /* *
224+ * Write the termination height this file encodes for.
225+ */
226+ bool WriteStopHeight (uint32_t stop);
227+ /* *
228+ * Write the hints for a block.
229+ */
230+ bool WriteHints (const EliasFano& ef);
231+ };
207232} // namespace swiftsync
208233
209234#endif // BITCOIN_SWIFTSYNC_H
You can’t perform that action at this time.
0 commit comments