danicoin/include/ITransfersSynchronizer.h

77 lines
2.4 KiB
C
Raw Normal View History

2015-05-27 12:08:46 +00:00
// Copyright (c) 2012-2015, The CryptoNote developers, The Bytecoin developers
//
// This file is part of Bytecoin.
//
// Bytecoin is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Bytecoin is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with Bytecoin. If not, see <http://www.gnu.org/licenses/>.
#pragma once
#include <cstdint>
#include <system_error>
#include "ITransaction.h"
#include "ITransfersContainer.h"
#include "IStreamSerializable.h"
namespace CryptoNote {
struct SynchronizationStart {
uint64_t timestamp;
uint64_t height;
};
struct AccountSubscription {
AccountKeys keys;
SynchronizationStart syncStart;
size_t transactionSpendableAge;
};
class ITransfersSubscription;
class ITransfersObserver {
public:
virtual void onError(ITransfersSubscription* object,
2015-07-30 15:22:07 +00:00
uint32_t height, std::error_code ec) {
}
2015-07-30 15:22:07 +00:00
virtual void onTransactionUpdated(ITransfersSubscription* object, const Crypto::Hash& transactionHash) {}
/**
* \note The sender must guarantee that onTransactionDeleted() is called only after onTransactionUpdated() is called
* for the same \a transactionHash.
*/
2015-07-30 15:22:07 +00:00
virtual void onTransactionDeleted(ITransfersSubscription* object, const Crypto::Hash& transactionHash) {}
};
class ITransfersSubscription : public IObservable < ITransfersObserver > {
public:
virtual ~ITransfersSubscription() {}
2015-07-30 15:22:07 +00:00
virtual AccountPublicAddress getAddress() = 0;
virtual ITransfersContainer& getContainer() = 0;
};
class ITransfersSynchronizer : public IStreamSerializable {
public:
virtual ~ITransfersSynchronizer() {}
virtual ITransfersSubscription& addSubscription(const AccountSubscription& acc) = 0;
2015-07-30 15:22:07 +00:00
virtual bool removeSubscription(const AccountPublicAddress& acc) = 0;
virtual void getSubscriptions(std::vector<AccountPublicAddress>& subscriptions) = 0;
// returns nullptr if address is not found
2015-07-30 15:22:07 +00:00
virtual ITransfersSubscription* getSubscription(const AccountPublicAddress& acc) = 0;
};
}