Raven Core  3.0.0
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 RAVEN_SPENTINDEX_H
7 #define RAVEN_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) {
20  READWRITE(txid);
21  READWRITE(outputIndex);
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) {
52  READWRITE(txid);
53  READWRITE(inputIndex);
54  READWRITE(blockHeight);
55  READWRITE(satoshis);
56  READWRITE(addressType);
57  READWRITE(addressHash);
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;
79  addressHash.SetNull();
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 // RAVEN_SPENTINDEX_H
void SetNull()
Definition: spentindex.h:33
void SetNull()
Definition: uint256.h:41
#define READWRITE(obj)
Definition: serialize.h:163
CSpentIndexValue(uint256 t, unsigned int i, int h, CAmount s, int type, uint160 a)
Definition: spentindex.h:60
unsigned int outputIndex
Definition: spentindex.h:14
unsigned int inputIndex
Definition: spentindex.h:42
bool IsNull() const
Definition: uint256.h:33
int64_t CAmount
Amount in corbies (Can be negative)
Definition: amount.h:13
CSpentIndexKey(uint256 t, unsigned int i)
Definition: spentindex.h:24
bool operator()(const CSpentIndexKey &a, const CSpentIndexKey &b) const
Definition: spentindex.h:89
uint256 txid
Definition: spentindex.h:13
void SerializationOp(Stream &s, Operation ser_action)
Definition: spentindex.h:19
256-bit opaque blob.
Definition: uint256.h:123
uint160 addressHash
Definition: spentindex.h:46
void SerializationOp(Stream &s, Operation ser_action)
Definition: spentindex.h:51
160-bit opaque blob.
Definition: uint256.h:112
bool IsNull() const
Definition: spentindex.h:82
CAmount satoshis
Definition: spentindex.h:44