forked from dashpay/dash
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtimestampindex.h
81 lines (64 loc) · 1.76 KB
/
timestampindex.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
// Copyright (c) 2009-2010 Satoshi Nakamoto
// Copyright (c) 2009-2015 The Bitcoin Core developers
// Copyright (c) 2016 BitPay, Inc.
// Copyright (c) 2023 The Dash Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef BITCOIN_TIMESTAMPINDEX_H
#define BITCOIN_TIMESTAMPINDEX_H
#include <serialize.h>
#include <uint256.h>
struct CTimestampIndexIteratorKey {
public:
uint32_t m_time;
public:
CTimestampIndexIteratorKey() {
SetNull();
}
CTimestampIndexIteratorKey(uint32_t time) : m_time{time} {};
void SetNull() {
m_time = 0;
}
public:
size_t GetSerializeSize(int nType, int nVersion) const {
return 4;
}
template<typename Stream>
void Serialize(Stream& s) const {
ser_writedata32be(s, m_time);
}
template<typename Stream>
void Unserialize(Stream& s) {
m_time = ser_readdata32be(s);
}
};
struct CTimestampIndexKey {
public:
uint32_t m_block_time;
uint256 m_block_hash;
public:
CTimestampIndexKey() {
SetNull();
}
CTimestampIndexKey(uint32_t block_time, uint256 block_hash) :
m_block_time{block_time}, m_block_hash{block_hash} {};
void SetNull() {
m_block_time = 0;
m_block_hash.SetNull();
}
public:
size_t GetSerializeSize(int nType, int nVersion) const {
return 36;
}
template<typename Stream>
void Serialize(Stream& s) const {
ser_writedata32be(s, m_block_time);
m_block_hash.Serialize(s);
}
template<typename Stream>
void Unserialize(Stream& s) {
m_block_time = ser_readdata32be(s);
m_block_hash.Unserialize(s);
}
};
#endif // BITCOIN_TIMESTAMPINDEX_H