File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -25,6 +25,28 @@ struct TransactionCompressor {
25
25
}
26
26
};
27
27
28
+ class DifferenceFormatter
29
+ {
30
+ uint64_t m_shift = 0 ;
31
+
32
+ public:
33
+ template <typename Stream, typename I>
34
+ void Ser (Stream& s, I v)
35
+ {
36
+ if (v < m_shift || v >= std::numeric_limits<uint64_t >::max ()) throw std::ios_base::failure (" differential value overflow" );
37
+ WriteCompactSize (s, v - m_shift);
38
+ m_shift = uint64_t (v) + 1 ;
39
+ }
40
+ template <typename Stream, typename I>
41
+ void Unser (Stream& s, I& v)
42
+ {
43
+ uint64_t n = ReadCompactSize (s);
44
+ m_shift += n;
45
+ if (m_shift < n || m_shift >= std::numeric_limits<uint64_t >::max () || m_shift < std::numeric_limits<I>::min () || m_shift > std::numeric_limits<I>::max ()) throw std::ios_base::failure (" differential value overflow" );
46
+ v = I (m_shift++);
47
+ }
48
+ };
49
+
28
50
class BlockTransactionsRequest {
29
51
public:
30
52
// A BlockTransactionsRequest message
You can’t perform that action at this time.
0 commit comments