Dash Core  0.12.2.1
P2P Digital Currency
spentindex.h
Go to the documentation of this file.
1 // Copyright (c) 2009-2010 Satoshi Nakamoto
2 // Copyright (c) 2009-2015 The Bitcoin Core developers
3 // Distributed under the MIT software license, see the accompanying
4 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
5 
6 #ifndef BITCOIN_SPENTINDEX_H
7 #define BITCOIN_SPENTINDEX_H
8 
9 #include "uint256.h"
10 #include "amount.h"
11 
14  unsigned int outputIndex;
15 
17 
18  template <typename Stream, typename Operation>
19  inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
20  READWRITE(txid);
22  }
23 
24  CSpentIndexKey(uint256 t, unsigned int i) {
25  txid = t;
26  outputIndex = i;
27  }
28 
30  SetNull();
31  }
32 
33  void SetNull() {
34  txid.SetNull();
35  outputIndex = 0;
36  }
37 
38 };
39 
42  unsigned int inputIndex;
47 
49 
50  template <typename Stream, typename Operation>
51  inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
52  READWRITE(txid);
58  }
59 
60  CSpentIndexValue(uint256 t, unsigned int i, int h, CAmount s, int type, uint160 a) {
61  txid = t;
62  inputIndex = i;
63  blockHeight = h;
64  satoshis = s;
65  addressType = type;
66  addressHash = a;
67  }
68 
70  SetNull();
71  }
72 
73  void SetNull() {
74  txid.SetNull();
75  inputIndex = 0;
76  blockHeight = 0;
77  satoshis = 0;
78  addressType = 0;
80  }
81 
82  bool IsNull() const {
83  return txid.IsNull();
84  }
85 };
86 
88 {
89  bool operator()(const CSpentIndexKey& a, const CSpentIndexKey& b) const {
90  if (a.txid == b.txid) {
91  return a.outputIndex < b.outputIndex;
92  } else {
93  return a.txid < b.txid;
94  }
95  }
96 };
97 
98 #endif // BITCOIN_SPENTINDEX_H
void SetNull()
Definition: uint256.h:41
#define READWRITE(obj)
Definition: serialize.h:175
uint256 txid
Definition: spentindex.h:13
unsigned int inputIndex
Definition: spentindex.h:42
unsigned int outputIndex
Definition: spentindex.h:14
bool operator()(const CSpentIndexKey &a, const CSpentIndexKey &b) const
Definition: spentindex.h:89
uint160 addressHash
Definition: spentindex.h:46
bool IsNull() const
Definition: uint256.h:33
int64_t CAmount
Definition: amount.h:14
CAmount satoshis
Definition: spentindex.h:44
void SetNull()
Definition: spentindex.h:33
void SerializationOp(Stream &s, Operation ser_action, int nType, int nVersion)
Definition: spentindex.h:19
bool IsNull() const
Definition: spentindex.h:82
void SerializationOp(Stream &s, Operation ser_action, int nType, int nVersion)
Definition: spentindex.h:51
CSpentIndexKey(uint256 t, unsigned int i)
Definition: spentindex.h:24
CSpentIndexValue(uint256 t, unsigned int i, int h, CAmount s, int type, uint160 a)
Definition: spentindex.h:60