1111
1212CAmount GetFluidDynodeReward (const int nHeight)
1313{
14- assert (pFluidDynodeDB);
15-
16- if (FLUID_ACTIVATE_HEIGHT > nHeight)
17- return GetStandardDynodePayment (nHeight);
18-
19- if (pFluidDynodeDB->IsEmpty ())
20- return GetStandardDynodePayment (nHeight);
21-
2214 CFluidDynode lastDynodeRecord;
23- if (!pFluidDynodeDB->GetLastFluidDynodeRecord (lastDynodeRecord, nHeight)) {
24- return GetStandardDynodePayment (nHeight);
25- }
26- if (lastDynodeRecord.DynodeReward > 0 ) {
27- return lastDynodeRecord.DynodeReward ;
28- } else {
29- return GetStandardDynodePayment (nHeight);
15+
16+ assert (pFluidDynodeDB);
17+ if (pFluidDynodeDB->GetLastFluidDynodeRecord (lastDynodeRecord, nHeight) && !pFluidDynodeDB->IsEmpty ()) {
18+ return (lastDynodeRecord.GetReward () > 0 && FLUID_ACTIVATE_HEIGHT > nHeight) ?
19+ lastDynodeRecord.GetReward () : GetStandardDynodePayment (nHeight);
3020 }
21+
22+ return GetStandardDynodePayment (nHeight);
3123}
3224
3325CAmount GetFluidMiningReward (const int nHeight)
3426{
35- assert (pFluidMiningDB);
36-
37- if (FLUID_ACTIVATE_HEIGHT > nHeight)
38- return GetStandardPoWBlockPayment (nHeight);
39-
40- if (pFluidMiningDB->IsEmpty ())
41- return GetStandardPoWBlockPayment (nHeight);
42-
4327 CFluidMining lastMiningRecord;
44- if (!pFluidMiningDB->GetLastFluidMiningRecord (lastMiningRecord, nHeight)) {
45- return GetStandardPoWBlockPayment (nHeight);
46- }
47- if (lastMiningRecord.MiningReward > 0 ) {
48- return lastMiningRecord.MiningReward ;
49- } else {
50- return GetStandardPoWBlockPayment (nHeight);
28+
29+ assert (pFluidMiningDB);
30+ if (pFluidMiningDB->GetLastFluidMiningRecord (lastMiningRecord, nHeight) && !pFluidMiningDB->IsEmpty ()) {
31+ return (lastMiningRecord.GetReward () > 0 && FLUID_ACTIVATE_HEIGHT > nHeight) ?
32+ lastMiningRecord.GetReward () : GetStandardPoWBlockPayment (nHeight);
5133 }
34+
35+ return GetStandardDynodePayment (nHeight);
5236}
5337
5438bool GetMintingInstructions (const int nHeight, CFluidMint& fluidMint)
@@ -63,8 +47,8 @@ bool GetMintingInstructions(const int nHeight, CFluidMint& fluidMint)
6347 return false ;
6448 }
6549
66- if (( int ) getFluidMint.nHeight == (nHeight - 1 )) {
67- fluidMint = getFluidMint ;
50+ if (getFluidMint.GetHeight () == (nHeight - 1 )) {
51+ getFluidMint = fluidMint ;
6852 return true ;
6953 }
7054 return false ;
@@ -73,79 +57,57 @@ bool GetMintingInstructions(const int nHeight, CFluidMint& fluidMint)
7357/* * Checks if any given address is a current sovereign wallet address (invoked by RPC) */
7458bool IsSovereignAddress (const CDynamicAddress& inputAddress)
7559{
76- assert (pFluidSovereignDB) ;
60+ CFluidSovereign lastSovereign ;
7761
7862 if (!inputAddress.IsValid ()) {
7963 return false ;
8064 }
8165
82- CFluidSovereign lastSovereign;
83- if (!pFluidSovereignDB->GetLastFluidSovereignRecord (lastSovereign)) {
84- return false ;
85- }
86-
87- for (const std::vector<unsigned char >& vchAddress : lastSovereign.SovereignAddresses ) {
88- CDynamicAddress attemptKey (StringFromCharVector (vchAddress));
89- if (attemptKey.IsValid () && inputAddress == attemptKey) {
90- return true ;
66+ assert (pFluidSovereignDB);
67+ if (pFluidSovereignDB->GetLastFluidSovereignRecord (lastSovereign)) {
68+ for (const std::vector<unsigned char >& vchAddress : lastSovereign.obj_sigs ) {
69+ CDynamicAddress attemptKey (StringFromCharVector (vchAddress));
70+ return attemptKey.IsValid () && inputAddress == attemptKey;
9171 }
9272 }
73+
9374 return false ;
9475}
9576
9677bool GetAllFluidDynodeRecords (std::vector<CFluidDynode>& dynodeEntries)
9778{
9879 assert (pFluidDynodeDB);
99-
100- if (pFluidDynodeDB->GetAllFluidDynodeRecords (dynodeEntries)) {
101- return true ;
102- }
103- return false ;
80+ return pFluidDynodeDB->GetAllFluidDynodeRecords (dynodeEntries);
10481}
10582
10683bool GetAllFluidMiningRecords (std::vector<CFluidMining>& miningEntries)
10784{
10885 assert (pFluidMiningDB);
109-
110- if (!pFluidMiningDB->GetAllFluidMiningRecords (miningEntries)) {
111- return true ;
112- }
113- return false ;
86+ return pFluidMiningDB->GetAllFluidMiningRecords (miningEntries);
11487}
11588
11689bool GetAllFluidMintRecords (std::vector<CFluidMint>& mintEntries)
11790{
11891 assert (pFluidMintDB);
119-
120- if (pFluidMintDB->GetAllFluidMintRecords (mintEntries)) {
121- return true ;
122- }
123- return false ;
92+ return pFluidMintDB->GetAllFluidMintRecords (mintEntries);
12493}
12594
12695bool GetAllFluidSovereignRecords (std::vector<CFluidSovereign>& sovereignEntries)
12796{
12897 assert (pFluidSovereignDB);
129-
130- if (pFluidSovereignDB->IsEmpty ()) {
131- return false ;
132- }
133- if (!pFluidSovereignDB->GetAllFluidSovereignRecords (sovereignEntries)) {
134- return false ;
135- }
136- return true ;
98+ return pFluidSovereignDB->GetAllFluidSovereignRecords (sovereignEntries) && !pFluidSovereignDB->IsEmpty ();
13799}
138100
139101bool GetLastFluidSovereignAddressStrings (std::vector<std::string>& sovereignAddresses)
140102{
141103 assert (pFluidSovereignDB);
142-
143104 CFluidSovereign lastSovereign;
144- if (!pFluidSovereignDB->GetLastFluidSovereignRecord (lastSovereign)) {
145- return false ;
105+ if (pFluidSovereignDB->GetLastFluidSovereignRecord (lastSovereign))
106+ {
107+ sovereignAddresses = lastSovereign.SovereignAddressesStrings ();
108+ return true ;
146109 }
147- sovereignAddresses = lastSovereign.SovereignAddressesStrings ();
148- return true ;
110+ return false ;
149111}
150112
151113/* * Checks whether 3 of 5 sovereign addresses signed the token in the script to meet the quorum requirements */
0 commit comments