block merge sets coinbase tx block

This commit is contained in:
woodser
2019-07-16 15:11:20 -04:00
parent 06f0289514
commit e03b6b18bc
3 changed files with 14 additions and 18 deletions
+11 -3
View File
@@ -152,7 +152,7 @@ namespace monero {
if (this != self.get()) throw runtime_error("this != self");
if (self == other) return;
// merge base classes
// merge header fields
MoneroBlockHeader::merge(self, other);
// merge reconcilable block extensions
@@ -161,9 +161,9 @@ namespace monero {
// merge coinbase tx
if (coinbaseTx == boost::none) coinbaseTx = other->coinbaseTx;
else if (other->coinbaseTx != boost::none) {
if (other->coinbaseTx != boost::none) {
other->coinbaseTx.get()->block = self;
coinbaseTx.get()->merge(*coinbaseTx, *other->coinbaseTx);
coinbaseTx.get()->merge(coinbaseTx.get(), other->coinbaseTx.get());
}
// merge non-coinbase txs
@@ -385,6 +385,14 @@ namespace monero {
void MoneroOutput::merge(const shared_ptr<MoneroOutput>& self, const shared_ptr<MoneroOutput>& other) {
if (this != self.get()) throw runtime_error("this != self");
if (self == other) return;
// merge txs if they're different which comes back to merging outputs
if (tx != other->tx) {
tx->merge(tx, other->tx);
return;
}
// otherwise merge output fields
if (keyImage == boost::none) keyImage = other->keyImage;
else if (other->keyImage != boost::none) keyImage.get()->merge(keyImage.get(), other->keyImage.get());
amount = MoneroUtils::reconcile(amount, other->amount);
+3 -3
View File
@@ -1329,7 +1329,7 @@ namespace monero {
//cout << "4" << endl;
// collect unique txs
// cache unique txs and blocks
uint64_t chainHeight = getChainHeight();
map<string, shared_ptr<MoneroTxWallet>> txMap;
map<uint64_t, shared_ptr<MoneroBlock>> blockMap;
@@ -1442,7 +1442,7 @@ namespace monero {
tools::wallet2::transfer_container outputsW2;
wallet2->get_transfers(outputsW2);
// collect unique txs and blocks
// cache unique txs and blocks
map<string, shared_ptr<MoneroTxWallet>> txMap;
map<uint64_t, shared_ptr<MoneroBlock>> blockMap;
for (const auto& outputW2 : outputsW2) {
@@ -1466,7 +1466,7 @@ namespace monero {
}
}
// remove txs without requested transfer
// remove txs without requested vout
if (tx->vouts.empty() && tx->block != boost::none) tx->block.get()->txs.erase(std::remove(tx->block.get()->txs.begin(), tx->block.get()->txs.end(), tx), tx->block.get()->txs.end()); // TODO, no way to use const_iterator?
}
return vouts;
-12
View File
@@ -156,18 +156,6 @@ namespace monero {
}
}
//boost::property_tree::ptree MoneroUtils::txWalletToPropertyTree(const MoneroTxWallet& tx) {
// cout << "txWalletToPropertyTree(tx)" << endl;
// boost::property_tree::ptree txNode = txToPropertyTree(tx);
// if (!tx.vouts.empty()) throw runtime_error("not implemented");
// if (!tx.incomingTransfers.empty()) throw runtime_error("not implemented");
// if (tx.outgoingTransfer != boost::none) throw runtime_error("not implemented");
// if (tx.numSuggestedConfirmations != boost::none) txNode.put("numSuggestedConfirmations", *tx.numSuggestedConfirmations);
// if (tx.note != boost::none) txNode.put("note", *tx.note);
// return txNode;
//}
//
// -------------------------- MONERO TX REQUEST -----------------------------
boost::property_tree::ptree MoneroTxRequest::toPropertyTree() const {