@@ -65,6 +65,131 @@ class CFluid
6565
6666};
6767
68+ class DSFluidObject
69+ {
70+ typedef std::vector<unsigned char > byte_vec;
71+ static constexpr int CURRENT_VERSION = 1 ;
72+
73+ friend class CFluidDynode ;
74+ friend class CFluidMining ;
75+ friend class CFluidMint ;
76+ friend class CFluidSovereign ;
77+
78+ private:
79+ int version;
80+
81+ uint256 tx_hash;
82+ uint32_t tx_height;
83+ byte_vec tx_script;
84+
85+ uint64_t obj_reward;
86+ uint64_t obj_time;
87+
88+ protected:
89+ DSFluidObject Null ()
90+ {
91+ DSFluidObject obj;
92+ version = DSFluidObject::CURRENT_VERSION;
93+ tx_hash.SetNull ();
94+ tx_script.clear ();
95+ tx_height = 0 ;
96+ obj_reward = -1 ;
97+ obj_time = 0 ;
98+ obj_sigs.clear ();
99+ obj_address.clear ();
100+
101+ return obj;
102+ }
103+
104+ public:
105+ byte_vec obj_address;
106+ std::set<byte_vec> obj_sigs;
107+
108+ DSFluidObject ()
109+ {
110+ *this = Null ();
111+ }
112+
113+ DSFluidObject (DSFluidObject&& obj)
114+ {
115+ std::swap (version, obj.version );
116+ std::swap (tx_hash, obj.tx_hash );
117+ std::swap (tx_script, obj.tx_script );
118+ std::swap (obj_reward, obj.obj_reward );
119+ std::swap (obj_time, obj.obj_time );
120+ std::swap (obj_sigs, obj.obj_sigs );
121+ std::swap (obj_address, obj.obj_address );
122+ }
123+
124+ DSFluidObject& operator =(DSFluidObject&& obj)
125+ {
126+ std::swap (version, obj.version );
127+ std::swap (tx_hash, obj.tx_hash );
128+ std::swap (tx_script, obj.tx_script );
129+ std::swap (obj_reward, obj.obj_reward );
130+ std::swap (obj_time, obj.obj_time );
131+ std::swap (obj_sigs, obj.obj_sigs );
132+ std::swap (obj_address, obj.obj_address );
133+ return *this ;
134+ }
135+
136+ DSFluidObject (const DSFluidObject& obj) = default ;
137+ DSFluidObject& operator =(const DSFluidObject& obj) = default ;
138+
139+ bool operator >(const DSFluidObject& obj) const
140+ {
141+ return obj_time > obj.obj_time ;
142+ }
143+
144+ bool operator <(const DSFluidObject& obj) const
145+ {
146+ return obj_time < obj.obj_time ;
147+ }
148+
149+ bool operator ==(const DSFluidObject& obj) const
150+ {
151+ return tx_script == obj.tx_script ;
152+ }
153+
154+ bool operator !=(const DSFluidObject& obj) const
155+ {
156+ return !((*this ) == obj);
157+ }
158+
159+ void Initialise (byte_vec _vch, CAmount _amt, int64_t _t)
160+ {
161+ return InitialiseScriptRewardTime (_vch, _amt, _t);
162+ }
163+
164+ void InitialiseScriptRewardTime (byte_vec _vch, CAmount _amt, int64_t _t)
165+ {
166+ tx_script = _vch;
167+ obj_reward = _amt;
168+ obj_time = _t;
169+ }
170+
171+ void InitialiseHeightHash (CAmount _ht, uint256 _hash)
172+ {
173+ tx_height = _ht;
174+ tx_hash = _hash;
175+ }
176+
177+ void SetAddress (byte_vec _vch)
178+ {
179+ obj_address = _vch;
180+ }
181+
182+ uint64_t GetTime () const { return obj_time; }
183+ uint64_t GetHeight () const { return tx_height; }
184+ uint64_t GetReward () const { return obj_reward; }
185+ uint256 GetTransactionHash () const { return tx_hash; }
186+ uint32_t GetTransactionHeight () const { return tx_height; }
187+ byte_vec GetTransactionScript () const { return tx_script; }
188+
189+ bool IsNull () { return *this == Null (); }
190+ void SetNull () const { DSFluidObject (); }
191+ };
192+
68193/* * Standard Reward Payment Determination Functions */
69194CAmount GetStandardPoWBlockPayment (const int & nHeight);
70195CAmount GetStandardDynodePayment (const int & nHeight);
0 commit comments