merge() functions are virtual to enable polymorphism

This commit is contained in:
woodser
2019-07-03 17:07:49 -04:00
parent b3ea78ac62
commit c019a0c36b
4 changed files with 15 additions and 10 deletions
+4
View File
@@ -80,6 +80,10 @@ namespace monero {
return node;
}
void MoneroBlock::merge(const shared_ptr<MoneroBlockHeader>& self, const shared_ptr<MoneroBlockHeader>& other) {
merge(static_pointer_cast<MoneroBlock>(self), static_pointer_cast<MoneroBlock>(other));
}
void MoneroBlock::merge(const shared_ptr<MoneroBlock>& self, const shared_ptr<MoneroBlock>& other) {
if (this != self.get()) throw runtime_error("this != self");
if (self == other) return;
+4 -3
View File
@@ -82,7 +82,7 @@ namespace monero {
boost::optional<string> powHash;
boost::property_tree::ptree toPropertyTree() const;
void merge(const shared_ptr<MoneroBlockHeader>& self, const shared_ptr<MoneroBlockHeader>& other);
virtual void merge(const shared_ptr<MoneroBlockHeader>& self, const shared_ptr<MoneroBlockHeader>& other);
};
/**
@@ -95,6 +95,7 @@ namespace monero {
vector<string> txIds;
boost::property_tree::ptree toPropertyTree() const;
void merge(const shared_ptr<MoneroBlockHeader>& self, const shared_ptr<MoneroBlockHeader>& other);
void merge(const shared_ptr<MoneroBlock>& self, const shared_ptr<MoneroBlock>& other);
};
@@ -144,7 +145,7 @@ namespace monero {
boost::property_tree::ptree toPropertyTree() const;
boost::optional<uint64_t> getHeight() const;
void merge(const shared_ptr<MoneroTx>& self, const shared_ptr<MoneroTx>& other);
virtual void merge(const shared_ptr<MoneroTx>& self, const shared_ptr<MoneroTx>& other) ;
};
/**
@@ -170,6 +171,6 @@ namespace monero {
boost::optional<string> stealthPublicKey;
boost::property_tree::ptree toPropertyTree() const;
void merge(const shared_ptr<MoneroOutput>& self, const shared_ptr<MoneroOutput>& other);
virtual void merge(const shared_ptr<MoneroOutput>& self, const shared_ptr<MoneroOutput>& other);
};
}