implemented block notifications in wallet listener

This commit is contained in:
woodser
2019-05-28 16:42:59 -04:00
parent f092175e09
commit 52bcbfb482
2 changed files with 28 additions and 24 deletions
+24 -21
View File
@@ -7,6 +7,30 @@
using namespace cryptonote;
/**
* Adapts wallet2 notifications to a public listener.
*/
struct Wallet2ListenerAdapter : public tools::i_wallet2_callback {
Wallet2ListenerAdapter(MoneroWalletListener* listener) {
this->listener = listener;
}
~Wallet2ListenerAdapter() {
}
virtual void on_new_block(uint64_t height, const cryptonote::block& cnBlock) {
MoneroBlock block;
block.height = height;
listener->onNewBlock(block);
}
MoneroWalletListener* listener;
};
// ------------------------------- WALLET METHODS -----------------------------
bool MoneroWallet::walletExists(const string& path) {
cout << "walletExists(" << path << ")" << endl;
bool keyFileExists;
@@ -128,27 +152,6 @@ uint64_t MoneroWallet::getRestoreHeight() const {
return wallet2->get_refresh_from_block_height();
}
/**
* Adapts wallet2 notifications to a public listener.
*/
struct Wallet2ListenerAdapter : public tools::i_wallet2_callback {
Wallet2ListenerAdapter(MoneroWalletListener* listener) {
this->listener = listener;
}
~Wallet2ListenerAdapter() {
}
virtual void on_new_block(uint64_t height, const cryptonote::block& block) {
cout << "Wallet2ListenerAdapter.on_new_block()" << endl;
throw runtime_error("Not implemented");
}
MoneroWalletListener* listener;
};
void MoneroWallet::setListener(MoneroWalletListener* listener) {
cout << "setListener()" << endl;
this->listener = listener;
+4 -3
View File
@@ -23,15 +23,14 @@ namespace monero {
};
/**
* Models a result of syncing a wallet.
* Models a Monero block header.
*/
struct MoneroBlockHeader {
uint64_t height;
MoneroBlockHeader() {}
};
/**
* Models a result of syncing a wallet.
* Models a Monero block.
*/
struct MoneroBlock : public MoneroBlockHeader {
// TODO
@@ -69,6 +68,7 @@ namespace monero {
* Receives progress notifications as a wallet is synchronized.
*/
class MoneroSyncListener {
public:
/**
* Invoked when sync progress is made.
@@ -86,6 +86,7 @@ namespace monero {
* Receives notifications as a wallet is updated.
*/
class MoneroWalletListener : public MoneroSyncListener {
public:
/**
* Invoked when a new block is processed.