diff --git a/src/daemon/MoneroDaemonModel.cpp b/src/daemon/MoneroDaemonModel.cpp index 13e3c37..472a152 100644 --- a/src/daemon/MoneroDaemonModel.cpp +++ b/src/daemon/MoneroDaemonModel.cpp @@ -92,7 +92,7 @@ namespace monero { // merge coinbase tx if (coinbaseTx == boost::none) coinbaseTx = otherBlock->coinbaseTx; - else if (otherBlock->coinbaseTx != boost::none) (**coinbaseTx).merge(*coinbaseTx, *otherBlock->coinbaseTx); + else if (otherBlock->coinbaseTx != boost::none) coinbaseTx.get()->merge(*coinbaseTx, *otherBlock->coinbaseTx); // merge non-coinbase txs if (txs.empty()) txs = otherBlock->txs; @@ -111,13 +111,13 @@ namespace monero { } if (!txs.empty()) { for (const shared_ptr& tx : txs) { - tx->block = static_pointer_cast(self); + tx->block = self; } } // merge other fields hex = MoneroUtils::reconcile(hex, otherBlock->hex); - //txIds = MoneroUtils::reconcile(txIds, otherBlock->txIds); // TODO: implement + txIds = MoneroUtils::reconcile(txIds, otherBlock->txIds); } // ------------------------------- MONERO TX -------------------------------- diff --git a/src/utils/MoneroUtils.h b/src/utils/MoneroUtils.h index fbaa355..63bf93b 100644 --- a/src/utils/MoneroUtils.h +++ b/src/utils/MoneroUtils.h @@ -173,6 +173,20 @@ namespace MoneroUtils return reconcile(val1, val2, boost::none, boost::none, boost::none); } + template + vector reconcile(const vector& v1, const vector& v2) { + + // check for equality + if (v1 == v2) return v1; + + // resolve one vector empty + if (v1.empty()) return v2; + if (v2.empty()) return v1; + + // otherwise cannot reconcile + throw runtime_error("Cannot reconcile vectors"); + } + // template // boost::optional reconcile(const boost::optional& val1, const boost::optional& val2) { // return reconcile(val1, val2, boost::none, boost::none, boost::none);