Merge remote-tracking branch 'bytecoin/master'

This commit is contained in:
cryptonotefoundation 2016-01-18 15:33:29 +00:00
commit 8edd998304
595 changed files with 8720 additions and 2910 deletions

View file

@ -1,3 +1,7 @@
Release notes 1.1.1
- New API for CryptoNote RPC Wallet
Release notes 1.1.0
- CryptoNote RPC Wallet

View file

@ -75,7 +75,7 @@ class GTEST_API_ ScopedFakeTestPartResultReporter
//
// This method is from the TestPartResultReporterInterface
// interface.
virtual void ReportTestPartResult(const TestPartResult& result);
virtual void ReportTestPartResult(const TestPartResult& result) override;
private:
void Init();

View file

@ -162,8 +162,8 @@ class GTEST_API_ HasNewFatalFailureHelper
: public TestPartResultReporterInterface {
public:
HasNewFatalFailureHelper();
virtual ~HasNewFatalFailureHelper();
virtual void ReportTestPartResult(const TestPartResult& result);
virtual ~HasNewFatalFailureHelper() override;
virtual void ReportTestPartResult(const TestPartResult& result) override;
bool has_new_fatal_failure() const { return has_new_fatal_failure_; }
private:
bool has_new_fatal_failure_;

View file

@ -1011,21 +1011,21 @@ class TestEventListener {
// above.
class EmptyTestEventListener : public TestEventListener {
public:
virtual void OnTestProgramStart(const UnitTest& /*unit_test*/) {}
virtual void OnTestProgramStart(const UnitTest& /*unit_test*/) override {}
virtual void OnTestIterationStart(const UnitTest& /*unit_test*/,
int /*iteration*/) {}
virtual void OnEnvironmentsSetUpStart(const UnitTest& /*unit_test*/) {}
virtual void OnEnvironmentsSetUpEnd(const UnitTest& /*unit_test*/) {}
virtual void OnTestCaseStart(const TestCase& /*test_case*/) {}
virtual void OnTestStart(const TestInfo& /*test_info*/) {}
virtual void OnTestPartResult(const TestPartResult& /*test_part_result*/) {}
virtual void OnTestEnd(const TestInfo& /*test_info*/) {}
virtual void OnTestCaseEnd(const TestCase& /*test_case*/) {}
virtual void OnEnvironmentsTearDownStart(const UnitTest& /*unit_test*/) {}
virtual void OnEnvironmentsTearDownEnd(const UnitTest& /*unit_test*/) {}
int /*iteration*/) override {}
virtual void OnEnvironmentsSetUpStart(const UnitTest& /*unit_test*/) override {}
virtual void OnEnvironmentsSetUpEnd(const UnitTest& /*unit_test*/) override {}
virtual void OnTestCaseStart(const TestCase& /*test_case*/) override {}
virtual void OnTestStart(const TestInfo& /*test_info*/) override {}
virtual void OnTestPartResult(const TestPartResult& /*test_part_result*/) override {}
virtual void OnTestEnd(const TestInfo& /*test_info*/) override {}
virtual void OnTestCaseEnd(const TestCase& /*test_case*/) override {}
virtual void OnEnvironmentsTearDownStart(const UnitTest& /*unit_test*/) override {}
virtual void OnEnvironmentsTearDownEnd(const UnitTest& /*unit_test*/) override {}
virtual void OnTestIterationEnd(const UnitTest& /*unit_test*/,
int /*iteration*/) {}
virtual void OnTestProgramEnd(const UnitTest& /*unit_test*/) {}
int /*iteration*/) override {}
virtual void OnTestProgramEnd(const UnitTest& /*unit_test*/) override {}
};
// TestEventListeners lets users add listeners to track events in Google Test.

View file

@ -148,7 +148,7 @@ class DeathTestFactory {
class DefaultDeathTestFactory : public DeathTestFactory {
public:
virtual bool Create(const char* statement, const RE* regex,
const char* file, int line, DeathTest** test);
const char* file, int line, DeathTest** test) override;
};
// Returns true if exit_status describes a process that was terminated

View file

@ -451,7 +451,7 @@ class TestFactoryBase {
template <class TestClass>
class TestFactoryImpl : public TestFactoryBase {
public:
virtual Test* CreateTest() { return new TestClass; }
virtual Test* CreateTest() override { return new TestClass; }
};
#if GTEST_OS_WINDOWS
@ -1138,7 +1138,7 @@ class GTEST_TEST_CLASS_NAME_(test_case_name, test_name) : public parent_class {\
public:\
GTEST_TEST_CLASS_NAME_(test_case_name, test_name)() {}\
private:\
virtual void TestBody();\
virtual void TestBody() override;\
static ::testing::TestInfo* const test_info_ GTEST_ATTRIBUTE_UNUSED_;\
GTEST_DISALLOW_COPY_AND_ASSIGN_(\
GTEST_TEST_CLASS_NAME_(test_case_name, test_name));\

View file

@ -270,12 +270,12 @@ class ValuesInIteratorRangeGenerator : public ParamGeneratorInterface<T> {
template <typename ForwardIterator>
ValuesInIteratorRangeGenerator(ForwardIterator begin, ForwardIterator end)
: container_(begin, end) {}
virtual ~ValuesInIteratorRangeGenerator() {}
virtual ~ValuesInIteratorRangeGenerator() override {}
virtual ParamIteratorInterface<T>* Begin() const {
virtual ParamIteratorInterface<T>* Begin() const override {
return new Iterator(this, container_.begin());
}
virtual ParamIteratorInterface<T>* End() const {
virtual ParamIteratorInterface<T>* End() const override {
return new Iterator(this, container_.end());
}
@ -287,16 +287,16 @@ class ValuesInIteratorRangeGenerator : public ParamGeneratorInterface<T> {
Iterator(const ParamGeneratorInterface<T>* base,
typename ContainerType::const_iterator iterator)
: base_(base), iterator_(iterator) {}
virtual ~Iterator() {}
virtual ~Iterator() override {}
virtual const ParamGeneratorInterface<T>* BaseGenerator() const {
virtual const ParamGeneratorInterface<T>* BaseGenerator() const override {
return base_;
}
virtual void Advance() {
virtual void Advance() override {
++iterator_;
value_.reset();
}
virtual ParamIteratorInterface<T>* Clone() const {
virtual ParamIteratorInterface<T>* Clone() const override {
return new Iterator(*this);
}
// We need to use cached value referenced by iterator_ because *iterator_
@ -306,12 +306,12 @@ class ValuesInIteratorRangeGenerator : public ParamGeneratorInterface<T> {
// can advance iterator_ beyond the end of the range, and we cannot
// detect that fact. The client code, on the other hand, is
// responsible for not calling Current() on an out-of-range iterator.
virtual const T* Current() const {
virtual const T* Current() const override {
if (value_.get() == NULL)
value_.reset(new T(*iterator_));
return value_.get();
}
virtual bool Equals(const ParamIteratorInterface<T>& other) const {
virtual bool Equals(const ParamIteratorInterface<T>& other) const override {
// Having the same base generator guarantees that the other
// iterator is of the same type and we can downcast.
GTEST_CHECK_(BaseGenerator() == other.BaseGenerator())
@ -355,7 +355,7 @@ class ParameterizedTestFactory : public TestFactoryBase {
typedef typename TestClass::ParamType ParamType;
explicit ParameterizedTestFactory(ParamType parameter) :
parameter_(parameter) {}
virtual Test* CreateTest() {
virtual Test* CreateTest() override {
TestClass::SetParam(&parameter_);
return new TestClass();
}
@ -454,9 +454,9 @@ class ParameterizedTestCaseInfo : public ParameterizedTestCaseInfoBase {
: test_case_name_(name) {}
// Test case base name for display purposes.
virtual const string& GetTestCaseName() const { return test_case_name_; }
virtual const string& GetTestCaseName() const override { return test_case_name_; }
// Test case id to verify identity.
virtual TypeId GetTestCaseTypeId() const { return GetTypeId<TestCase>(); }
virtual TypeId GetTestCaseTypeId() const override { return GetTypeId<TestCase>(); }
// TEST_P macro uses AddTestPattern() to record information
// about a single test in a LocalTestInfo structure.
// test_case_name is the base name of the test case (without invocation
@ -484,7 +484,7 @@ class ParameterizedTestCaseInfo : public ParameterizedTestCaseInfoBase {
// This method should not be called more then once on any single
// instance of a ParameterizedTestCaseInfoBase derived class.
// UnitTest has a guard to prevent from calling this method more then once.
virtual void RegisterTests() {
virtual void RegisterTests() override {
for (typename TestInfoContainer::iterator test_it = tests_.begin();
test_it != tests_.end(); ++test_it) {
linked_ptr<TestInfo> test_info = *test_it;

View file

@ -1296,7 +1296,7 @@ class ThreadWithParam : public ThreadWithParamBase {
}
}
virtual void Run() {
virtual void Run() override {
if (thread_can_start_ != NULL)
thread_can_start_->WaitForNotification();
func_(param_);

View file

@ -373,8 +373,8 @@ class DeathTestImpl : public DeathTest {
// read_fd_ is expected to be closed and cleared by a derived class.
~DeathTestImpl() { GTEST_DEATH_TEST_CHECK_(read_fd_ == -1); }
void Abort(AbortReason reason);
virtual bool Passed(bool status_ok);
void Abort(AbortReason reason) override;
virtual bool Passed(bool status_ok) override;
const char* statement() const { return statement_; }
const RE* regex() const { return regex_; }
@ -778,7 +778,7 @@ class ForkingDeathTest : public DeathTestImpl {
ForkingDeathTest(const char* statement, const RE* regex);
// All of these virtual functions are inherited from DeathTest.
virtual int Wait();
virtual int Wait() override;
protected:
void set_child_pid(pid_t child_pid) { child_pid_ = child_pid; }
@ -814,7 +814,7 @@ class NoExecDeathTest : public ForkingDeathTest {
public:
NoExecDeathTest(const char* a_statement, const RE* a_regex) :
ForkingDeathTest(a_statement, a_regex) { }
virtual TestRole AssumeRole();
virtual TestRole AssumeRole() override;
};
// The AssumeRole process for a fork-and-run death test. It implements a
@ -870,7 +870,7 @@ class ExecDeathTest : public ForkingDeathTest {
ExecDeathTest(const char* a_statement, const RE* a_regex,
const char* file, int line) :
ForkingDeathTest(a_statement, a_regex), file_(file), line_(line) { }
virtual TestRole AssumeRole();
virtual TestRole AssumeRole() override;
private:
static ::std::vector<testing::internal::string>
GetArgvsForDeathTestChildProcess() {

View file

@ -441,10 +441,10 @@ class OsStackTraceGetter : public OsStackTraceGetterInterface {
public:
OsStackTraceGetter() : caller_frame_(NULL) {}
virtual string CurrentStackTrace(int max_depth, int skip_count)
virtual string CurrentStackTrace(int max_depth, int skip_count) override
GTEST_LOCK_EXCLUDED_(mutex_);
virtual void UponLeavingGTest() GTEST_LOCK_EXCLUDED_(mutex_);
virtual void UponLeavingGTest() override GTEST_LOCK_EXCLUDED_(mutex_);
// This string is inserted in place of stack frames that are part of
// Google Test's implementation.
@ -477,7 +477,7 @@ class DefaultGlobalTestPartResultReporter
explicit DefaultGlobalTestPartResultReporter(UnitTestImpl* unit_test);
// Implements the TestPartResultReporterInterface. Reports the test part
// result in the current test.
virtual void ReportTestPartResult(const TestPartResult& result);
virtual void ReportTestPartResult(const TestPartResult& result) override;
private:
UnitTestImpl* const unit_test_;
@ -493,7 +493,7 @@ class DefaultPerThreadTestPartResultReporter
explicit DefaultPerThreadTestPartResultReporter(UnitTestImpl* unit_test);
// Implements the TestPartResultReporterInterface. The implementation just
// delegates to the current global test part result reporter of *unit_test_.
virtual void ReportTestPartResult(const TestPartResult& result);
virtual void ReportTestPartResult(const TestPartResult& result) override;
private:
UnitTestImpl* const unit_test_;
@ -1100,7 +1100,7 @@ class StreamingListener : public EmptyTestEventListener {
}
// Sends a string to the socket.
virtual void Send(const string& message) {
virtual void Send(const string& message) override {
GTEST_CHECK_(sockfd_ != -1)
<< "Send() can be called only when there is a connection.";
@ -1117,7 +1117,7 @@ class StreamingListener : public EmptyTestEventListener {
void MakeConnection();
// Closes the socket.
void CloseConnection() {
void CloseConnection() override {
GTEST_CHECK_(sockfd_ != -1)
<< "CloseConnection() can be called only when there is a connection.";
@ -1141,11 +1141,11 @@ class StreamingListener : public EmptyTestEventListener {
explicit StreamingListener(AbstractSocketWriter* socket_writer)
: socket_writer_(socket_writer) { Start(); }
void OnTestProgramStart(const UnitTest& /* unit_test */) {
void OnTestProgramStart(const UnitTest& /* unit_test */) override {
SendLn("event=TestProgramStart");
}
void OnTestProgramEnd(const UnitTest& unit_test) {
void OnTestProgramEnd(const UnitTest& unit_test) override {
// Note that Google Test current only report elapsed time for each
// test iteration, not for the entire test program.
SendLn("event=TestProgramEnd&passed=" + FormatBool(unit_test.Passed()));
@ -1154,39 +1154,39 @@ class StreamingListener : public EmptyTestEventListener {
socket_writer_->CloseConnection();
}
void OnTestIterationStart(const UnitTest& /* unit_test */, int iteration) {
void OnTestIterationStart(const UnitTest& /* unit_test */, int iteration) override {
SendLn("event=TestIterationStart&iteration=" +
StreamableToString(iteration));
}
void OnTestIterationEnd(const UnitTest& unit_test, int /* iteration */) {
void OnTestIterationEnd(const UnitTest& unit_test, int /* iteration */) override {
SendLn("event=TestIterationEnd&passed=" +
FormatBool(unit_test.Passed()) + "&elapsed_time=" +
StreamableToString(unit_test.elapsed_time()) + "ms");
}
void OnTestCaseStart(const TestCase& test_case) {
void OnTestCaseStart(const TestCase& test_case) override {
SendLn(std::string("event=TestCaseStart&name=") + test_case.name());
}
void OnTestCaseEnd(const TestCase& test_case) {
void OnTestCaseEnd(const TestCase& test_case) override {
SendLn("event=TestCaseEnd&passed=" + FormatBool(test_case.Passed())
+ "&elapsed_time=" + StreamableToString(test_case.elapsed_time())
+ "ms");
}
void OnTestStart(const TestInfo& test_info) {
void OnTestStart(const TestInfo& test_info) override {
SendLn(std::string("event=TestStart&name=") + test_info.name());
}
void OnTestEnd(const TestInfo& test_info) {
void OnTestEnd(const TestInfo& test_info) override {
SendLn("event=TestEnd&passed=" +
FormatBool((test_info.result())->Passed()) +
"&elapsed_time=" +
StreamableToString((test_info.result())->elapsed_time()) + "ms");
}
void OnTestPartResult(const TestPartResult& test_part_result) {
void OnTestPartResult(const TestPartResult& test_part_result) override {
const char* file_name = test_part_result.file_name();
if (file_name == NULL)
file_name = "";

View file

@ -2697,19 +2697,19 @@ class PrettyUnitTestResultPrinter : public TestEventListener {
}
// The following methods override what's in the TestEventListener class.
virtual void OnTestProgramStart(const UnitTest& /*unit_test*/) {}
virtual void OnTestIterationStart(const UnitTest& unit_test, int iteration);
virtual void OnEnvironmentsSetUpStart(const UnitTest& unit_test);
virtual void OnEnvironmentsSetUpEnd(const UnitTest& /*unit_test*/) {}
virtual void OnTestCaseStart(const TestCase& test_case);
virtual void OnTestStart(const TestInfo& test_info);
virtual void OnTestPartResult(const TestPartResult& result);
virtual void OnTestEnd(const TestInfo& test_info);
virtual void OnTestCaseEnd(const TestCase& test_case);
virtual void OnEnvironmentsTearDownStart(const UnitTest& unit_test);
virtual void OnEnvironmentsTearDownEnd(const UnitTest& /*unit_test*/) {}
virtual void OnTestIterationEnd(const UnitTest& unit_test, int iteration);
virtual void OnTestProgramEnd(const UnitTest& /*unit_test*/) {}
virtual void OnTestProgramStart(const UnitTest& /*unit_test*/) override {}
virtual void OnTestIterationStart(const UnitTest& unit_test, int iteration) override;
virtual void OnEnvironmentsSetUpStart(const UnitTest& unit_test) override;
virtual void OnEnvironmentsSetUpEnd(const UnitTest& /*unit_test*/) override {}
virtual void OnTestCaseStart(const TestCase& test_case) override;
virtual void OnTestStart(const TestInfo& test_info) override;
virtual void OnTestPartResult(const TestPartResult& result) override;
virtual void OnTestEnd(const TestInfo& test_info) override;
virtual void OnTestCaseEnd(const TestCase& test_case) override;
virtual void OnEnvironmentsTearDownStart(const UnitTest& unit_test) override;
virtual void OnEnvironmentsTearDownEnd(const UnitTest& /*unit_test*/) override {}
virtual void OnTestIterationEnd(const UnitTest& unit_test, int iteration) override;
virtual void OnTestProgramEnd(const UnitTest& /*unit_test*/) override {}
private:
static void PrintFailedTests(const UnitTest& unit_test);
@ -2908,19 +2908,19 @@ class TestEventRepeater : public TestEventListener {
bool forwarding_enabled() const { return forwarding_enabled_; }
void set_forwarding_enabled(bool enable) { forwarding_enabled_ = enable; }
virtual void OnTestProgramStart(const UnitTest& unit_test);
virtual void OnTestIterationStart(const UnitTest& unit_test, int iteration);
virtual void OnEnvironmentsSetUpStart(const UnitTest& unit_test);
virtual void OnEnvironmentsSetUpEnd(const UnitTest& unit_test);
virtual void OnTestCaseStart(const TestCase& test_case);
virtual void OnTestStart(const TestInfo& test_info);
virtual void OnTestPartResult(const TestPartResult& result);
virtual void OnTestEnd(const TestInfo& test_info);
virtual void OnTestCaseEnd(const TestCase& test_case);
virtual void OnEnvironmentsTearDownStart(const UnitTest& unit_test);
virtual void OnEnvironmentsTearDownEnd(const UnitTest& unit_test);
virtual void OnTestIterationEnd(const UnitTest& unit_test, int iteration);
virtual void OnTestProgramEnd(const UnitTest& unit_test);
virtual void OnTestProgramStart(const UnitTest& unit_test) override;
virtual void OnTestIterationStart(const UnitTest& unit_test, int iteration) override;
virtual void OnEnvironmentsSetUpStart(const UnitTest& unit_test) override;
virtual void OnEnvironmentsSetUpEnd(const UnitTest& unit_test) override;
virtual void OnTestCaseStart(const TestCase& test_case) override;
virtual void OnTestStart(const TestInfo& test_info) override;
virtual void OnTestPartResult(const TestPartResult& result) override;
virtual void OnTestEnd(const TestInfo& test_info) override;
virtual void OnTestCaseEnd(const TestCase& test_case) override;
virtual void OnEnvironmentsTearDownStart(const UnitTest& unit_test) override;
virtual void OnEnvironmentsTearDownEnd(const UnitTest& unit_test) override;
virtual void OnTestIterationEnd(const UnitTest& unit_test, int iteration) override;
virtual void OnTestProgramEnd(const UnitTest& unit_test) override;
private:
// Controls whether events will be forwarded to listeners_. Set to false
@ -3013,7 +3013,7 @@ class XmlUnitTestResultPrinter : public EmptyTestEventListener {
public:
explicit XmlUnitTestResultPrinter(const char* output_file);
virtual void OnTestIterationEnd(const UnitTest& unit_test, int iteration);
virtual void OnTestIterationEnd(const UnitTest& unit_test, int iteration) override;
private:
// Is c a whitespace character that is normalized to a space character

View file

@ -1,4 +1,4 @@
// Copyright (c) 2011-2015 The Cryptonote developers
// Copyright (c) 2011-2016 The Cryptonote developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

View file

@ -1,4 +1,4 @@
// Copyright (c) 2011-2015 The Cryptonote developers
// Copyright (c) 2011-2016 The Cryptonote developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

View file

@ -1,4 +1,4 @@
// Copyright (c) 2011-2015 The Cryptonote developers
// Copyright (c) 2011-2016 The Cryptonote developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

View file

@ -1,4 +1,4 @@
// Copyright (c) 2011-2015 The Cryptonote developers
// Copyright (c) 2011-2016 The Cryptonote developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

View file

@ -1,4 +1,4 @@
// Copyright (c) 2011-2015 The Cryptonote developers
// Copyright (c) 2011-2016 The Cryptonote developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

View file

@ -1,4 +1,4 @@
// Copyright (c) 2011-2015 The Cryptonote developers
// Copyright (c) 2011-2016 The Cryptonote developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

View file

@ -1,4 +1,4 @@
// Copyright (c) 2011-2015 The Cryptonote developers
// Copyright (c) 2011-2016 The Cryptonote developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

View file

@ -1,4 +1,4 @@
// Copyright (c) 2011-2015 The Cryptonote developers
// Copyright (c) 2011-2016 The Cryptonote developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

View file

@ -1,4 +1,4 @@
// Copyright (c) 2011-2015 The Cryptonote developers
// Copyright (c) 2011-2016 The Cryptonote developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
@ -84,7 +84,8 @@ public:
virtual size_t transactionsCount() const = 0;
virtual uint64_t balance(uint32_t flags = IncludeDefault) const = 0;
virtual void getOutputs(std::vector<TransactionOutputInformation>& transfers, uint32_t flags = IncludeDefault) const = 0;
virtual bool getTransactionInformation(const Crypto::Hash& transactionHash, TransactionInformation& info, int64_t& txBalance) const = 0;
virtual bool getTransactionInformation(const Crypto::Hash& transactionHash, TransactionInformation& info,
uint64_t* amountIn = nullptr, uint64_t* amountOut = nullptr) const = 0;
virtual std::vector<TransactionOutputInformation> getTransactionOutputs(const Crypto::Hash& transactionHash, uint32_t flags = IncludeDefault) const = 0;
//only type flags are feasible for this function
virtual std::vector<TransactionOutputInformation> getTransactionInputs(const Crypto::Hash& transactionHash, uint32_t flags) const = 0;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2011-2015 The Cryptonote developers
// Copyright (c) 2011-2016 The Cryptonote developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
@ -49,6 +49,16 @@ public:
virtual ITransfersContainer& getContainer() = 0;
};
class ITransfersSynchronizerObserver {
public:
virtual void onBlocksAdded(const Crypto::PublicKey& viewPublicKey, const std::vector<Crypto::Hash>& blockHashes) {}
virtual void onBlockchainDetach(const Crypto::PublicKey& viewPublicKey, uint32_t blockIndex) {}
virtual void onTransactionDeleteBegin(const Crypto::PublicKey& viewPublicKey, Crypto::Hash transactionHash) {}
virtual void onTransactionDeleteEnd(const Crypto::PublicKey& viewPublicKey, Crypto::Hash transactionHash) {}
virtual void onTransactionUpdated(const Crypto::PublicKey& viewPublicKey, const Crypto::Hash& transactionHash,
const std::vector<ITransfersContainer*>& containers) {}
};
class ITransfersSynchronizer : public IStreamSerializable {
public:
virtual ~ITransfersSynchronizer() {}
@ -58,6 +68,7 @@ public:
virtual void getSubscriptions(std::vector<AccountPublicAddress>& subscriptions) = 0;
// returns nullptr if address is not found
virtual ITransfersSubscription* getSubscription(const AccountPublicAddress& acc) = 0;
virtual std::vector<Crypto::Hash> getViewKeyKnownBlocks(const Crypto::PublicKey& publicViewKey) = 0;
};
}

View file

@ -1,4 +1,4 @@
// Copyright (c) 2011-2015 The Cryptonote developers
// Copyright (c) 2011-2016 The Cryptonote developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
@ -18,7 +18,9 @@ const uint32_t WALLET_UNCONFIRMED_TRANSACTION_HEIGHT = std::numeric_limits<uint3
enum class WalletTransactionState : uint8_t {
SUCCEEDED = 0,
FAILED,
CANCELLED
CANCELLED,
CREATED,
DELETED
};
enum WalletEventType {
@ -26,7 +28,7 @@ enum WalletEventType {
TRANSACTION_UPDATED,
BALANCE_UNLOCKED,
SYNC_PROGRESS_UPDATED,
SYNC_COMPLETED
SYNC_COMPLETED,
};
struct WalletTransactionCreatedData {
@ -64,11 +66,49 @@ struct WalletTransaction {
bool isBase;
};
enum class WalletTransferType : uint8_t {
USUAL = 0,
DONATION,
CHANGE
};
struct WalletOrder {
std::string address;
uint64_t amount;
};
struct WalletTransfer {
WalletTransferType type;
std::string address;
int64_t amount;
};
struct DonationSettings {
std::string address;
uint64_t threshold = 0;
};
struct TransactionParameters {
std::vector<std::string> sourceAddresses;
std::vector<WalletOrder> destinations;
uint64_t fee = 0;
uint64_t mixIn = 0;
std::string extra;
uint64_t unlockTimestamp = 0;
DonationSettings donation;
std::string changeDestination;
};
struct WalletTransactionWithTransfers {
WalletTransaction transaction;
std::vector<WalletTransfer> transfers;
};
struct TransactionsInBlockInfo {
Crypto::Hash blockHash;
std::vector<WalletTransactionWithTransfers> transactions;
};
class IWallet {
public:
virtual ~IWallet() {}
@ -84,6 +124,7 @@ public:
virtual size_t getAddressCount() const = 0;
virtual std::string getAddress(size_t index) const = 0;
virtual KeyPair getAddressSpendKey(size_t index) const = 0;
virtual KeyPair getAddressSpendKey(const std::string& address) const = 0;
virtual KeyPair getViewKey() const = 0;
virtual std::string createAddress() = 0;
virtual std::string createAddress(const Crypto::SecretKey& spendSecretKey) = 0;
@ -100,10 +141,19 @@ public:
virtual size_t getTransactionTransferCount(size_t transactionIndex) const = 0;
virtual WalletTransfer getTransactionTransfer(size_t transactionIndex, size_t transferIndex) const = 0;
virtual size_t transfer(const WalletTransfer& destination, uint64_t fee, uint64_t mixIn = 0, const std::string& extra = "", uint64_t unlockTimestamp = 0) = 0;
virtual size_t transfer(const std::vector<WalletTransfer>& destinations, uint64_t fee, uint64_t mixIn = 0, const std::string& extra = "", uint64_t unlockTimestamp = 0) = 0;
virtual size_t transfer(const std::string& sourceAddress, const WalletTransfer& destination, uint64_t fee, uint64_t mixIn = 0, const std::string& extra = "", uint64_t unlockTimestamp = 0) = 0;
virtual size_t transfer(const std::string& sourceAddress, const std::vector<WalletTransfer>& destinations, uint64_t fee, uint64_t mixIn = 0, const std::string& extra = "", uint64_t unlockTimestamp = 0) = 0;
virtual WalletTransactionWithTransfers getTransaction(const Crypto::Hash& transactionHash) const = 0;
virtual std::vector<TransactionsInBlockInfo> getTransactions(const Crypto::Hash& blockHash, size_t count) const = 0;
virtual std::vector<TransactionsInBlockInfo> getTransactions(uint32_t blockIndex, size_t count) const = 0;
virtual std::vector<Crypto::Hash> getBlockHashes(uint32_t blockIndex, size_t count) const = 0;
virtual uint32_t getBlockCount() const = 0;
virtual std::vector<WalletTransactionWithTransfers> getUnconfirmedTransactions() const = 0;
virtual std::vector<size_t> getDelayedTransactionIds() const = 0;
virtual size_t transfer(const TransactionParameters& sendingTransaction) = 0;
virtual size_t makeTransaction(const TransactionParameters& sendingTransaction) = 0;
virtual void commitTransaction(size_t transactionId) = 0;
virtual void rollbackUncommitedTransaction(size_t transactionId) = 0;
virtual void start() = 0;
virtual void stop() = 0;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2011-2015 The Cryptonote developers
// Copyright (c) 2011-2016 The Cryptonote developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

View file

@ -1,4 +1,4 @@
// Copyright (c) 2011-2015 The Cryptonote developers
// Copyright (c) 2011-2016 The Cryptonote developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
@ -65,12 +65,76 @@ private:
const std::function<void(const INode::Callback&)> requestFunc;
};
BlockchainExplorer::PoolUpdateGuard::PoolUpdateGuard() :
m_state(State::NONE) {
}
bool BlockchainExplorer::PoolUpdateGuard::beginUpdate() {
auto state = m_state.load();
for (;;) {
switch (state) {
case State::NONE:
if (m_state.compare_exchange_weak(state, State::UPDATING)) {
return true;
}
break;
case State::UPDATING:
if (m_state.compare_exchange_weak(state, State::UPDATE_REQUIRED)) {
return false;
}
break;
case State::UPDATE_REQUIRED:
return false;
default:
assert(false);
return false;
}
}
}
bool BlockchainExplorer::PoolUpdateGuard::endUpdate() {
auto state = m_state.load();
for (;;) {
assert(state != State::NONE);
if (m_state.compare_exchange_weak(state, State::NONE)) {
return state == State::UPDATE_REQUIRED;
}
}
}
class ScopeExitHandler {
public:
ScopeExitHandler(std::function<void()>&& handler) :
m_handler(std::move(handler)),
m_cancelled(false) {
}
~ScopeExitHandler() {
if (!m_cancelled) {
m_handler();
}
}
void reset() {
m_cancelled = true;
}
private:
std::function<void()> m_handler;
bool m_cancelled;
};
BlockchainExplorer::BlockchainExplorer(INode& node, Logging::ILogger& logger) :
node(node),
logger(logger, "BlockchainExplorer"),
state(NOT_INITIALIZED),
synchronized(false),
observersCounter(0) {}
observersCounter(0) {
}
BlockchainExplorer::~BlockchainExplorer() {}
@ -416,6 +480,12 @@ void BlockchainExplorer::poolChanged() {
return;
}
if (!poolUpdateGuard.beginUpdate()) {
return;
}
ScopeExitHandler poolUpdateEndGuard(std::bind(&BlockchainExplorer::poolUpdateEndHandler, this));
std::unique_lock<std::mutex> lock(mutex);
std::shared_ptr<std::vector<std::unique_ptr<ITransactionReader>>> rawNewTransactionsPtr = std::make_shared<std::vector<std::unique_ptr<ITransactionReader>>>();
@ -438,8 +508,11 @@ void BlockchainExplorer::poolChanged() {
);
}
);
request.performAsync(asyncContextCounter,
[this, rawNewTransactionsPtr, removedTransactionsPtr, isBlockchainActualPtr](std::error_code ec) {
ScopeExitHandler poolUpdateEndGuard(std::bind(&BlockchainExplorer::poolUpdateEndHandler, this));
if (ec) {
logger(ERROR) << "Can't send poolChanged notification because can't get pool symmetric difference: " << ec.message();
return;
@ -461,12 +534,10 @@ void BlockchainExplorer::poolChanged() {
for (const Hash hash : *removedTransactionsPtr) {
auto iter = knownPoolState.find(hash);
if (iter != knownPoolState.end()) {
removedTransactionsHashesPtr->push_back(
std::move(std::make_pair(
hash,
TransactionRemoveReason::INCLUDED_IN_BLOCK //Can't have real reason here.
))
);
removedTransactionsHashesPtr->push_back({
hash,
TransactionRemoveReason::INCLUDED_IN_BLOCK // Can't have real reason here.
});
knownPoolState.erase(iter);
}
}
@ -487,21 +558,34 @@ void BlockchainExplorer::poolChanged() {
std::placeholders::_1
)
);
request.performAsync(asyncContextCounter,
[this, newTransactionsHashesPtr, newTransactionsPtr, removedTransactionsHashesPtr](std::error_code ec) {
ScopeExitHandler poolUpdateEndGuard(std::bind(&BlockchainExplorer::poolUpdateEndHandler, this));
if (ec) {
logger(ERROR) << "Can't send poolChanged notification because can't get transactions: " << ec.message();
return;
}
if (!newTransactionsPtr->empty() || !removedTransactionsHashesPtr->empty()) {
observerManager.notify(&IBlockchainObserver::poolUpdated, *newTransactionsPtr, *removedTransactionsHashesPtr);
logger(DEBUGGING) << "poolUpdated notification was successfully sent.";
}
}
);
poolUpdateEndGuard.reset();
}
);
poolUpdateEndGuard.reset();
}
void BlockchainExplorer::poolUpdateEndHandler() {
if (poolUpdateGuard.endUpdate()) {
poolChanged();
}
}
void BlockchainExplorer::blockchainSynchronized(uint32_t topHeight) {

View file

@ -1,4 +1,4 @@
// Copyright (c) 2011-2015 The Cryptonote developers
// Copyright (c) 2011-2016 The Cryptonote developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
@ -61,6 +61,25 @@ public:
typedef WalletAsyncContextCounter AsyncContextCounter;
private:
void poolUpdateEndHandler();
class PoolUpdateGuard {
public:
PoolUpdateGuard();
bool beginUpdate();
bool endUpdate();
private:
enum class State {
NONE,
UPDATING,
UPDATE_REQUIRED
};
std::atomic<State> m_state;
};
enum State {
NOT_INITIALIZED,
INITIALIZED
@ -81,6 +100,6 @@ private:
Logging::LoggerRef logger;
AsyncContextCounter asyncContextCounter;
PoolUpdateGuard poolUpdateGuard;
};
}

View file

@ -1,4 +1,4 @@
// Copyright (c) 2011-2015 The Cryptonote developers
// Copyright (c) 2011-2016 The Cryptonote developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
@ -54,7 +54,7 @@ bool BlockchainExplorerDataBuilder::fillTxExtra(const std::vector<uint8_t>& rawE
} else if (typeid(TransactionExtraPublicKey) == field.type()) {
extraDetails.publicKey.push_back(std::move(boost::get<TransactionExtraPublicKey>(field).publicKey));
} else if (typeid(TransactionExtraNonce) == field.type()) {
extraDetails.nonce.push_back(std::move(Common::toHex(boost::get<TransactionExtraNonce>(field).nonce.data(), boost::get<TransactionExtraNonce>(field).nonce.size())));
extraDetails.nonce.push_back(Common::toHex(boost::get<TransactionExtraNonce>(field).nonce.data(), boost::get<TransactionExtraNonce>(field).nonce.size()));
}
}
return true;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2011-2015 The Cryptonote developers
// Copyright (c) 2011-2016 The Cryptonote developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

View file

@ -1,4 +1,4 @@
// Copyright (c) 2011-2015 The Cryptonote developers
// Copyright (c) 2011-2016 The Cryptonote developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

View file

@ -1,4 +1,4 @@
// Copyright (c) 2011-2015 The Cryptonote developers
// Copyright (c) 2011-2016 The Cryptonote developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
@ -21,15 +21,15 @@ class BlockchainExplorerErrorCategory : public std::error_category {
public:
static BlockchainExplorerErrorCategory INSTANCE;
virtual const char* name() const throw() {
virtual const char* name() const throw() override {
return "BlockchainExplorerErrorCategory";
}
virtual std::error_condition default_error_condition(int ev) const throw() {
virtual std::error_condition default_error_condition(int ev) const throw() override {
return std::error_condition(ev, *this);
}
virtual std::string message(int ev) const {
virtual std::string message(int ev) const override {
switch (ev) {
case static_cast<int>(BlockchainExplorerErrorCodes::NOT_INITIALIZED): return "Object was not initialized";
case static_cast<int>(BlockchainExplorerErrorCodes::ALREADY_INITIALIZED): return "Object has been already initialized";

View file

@ -30,6 +30,7 @@ file(GLOB_RECURSE JsonRpcServer JsonRpcServer/*)
file(GLOB_RECURSE PaymentGate PaymentGate/*)
file(GLOB_RECURSE PaymentGateService PaymentGateService/*)
file(GLOB_RECURSE Miner Miner/*)
source_group("" FILES $${Common} ${ConnectivityTool} ${Crypto} ${CryptoNoteCore} ${CryptoNoteProtocol} ${Daemon} ${JsonRpcServer} ${Http} ${Logging} ${NodeRpcProxy} ${P2p} ${Rpc} ${Serialization} ${SimpleWallet} ${System} ${Transfers} ${Wallet} ${WalletLegacy})
@ -54,17 +55,17 @@ add_executable(ConnectivityTool ${ConnectivityTool})
add_executable(Daemon ${Daemon})
add_executable(SimpleWallet ${SimpleWallet})
add_executable(PaymentGateService ${PaymentGateService})
add_executable(Miner ${Miner})
if (MSVC)
target_link_libraries(System ws2_32)
endif ()
target_link_libraries(ConnectivityTool CryptoNoteCore Common Logging Crypto P2P Rpc Http Serialization System ${Boost_LIBRARIES})
target_link_libraries(Daemon CryptoNoteCore P2P Rpc Serialization System Http Logging Common Crypto upnpc-static BlockchainExplorer ${Boost_LIBRARIES})
target_link_libraries(SimpleWallet Wallet NodeRpcProxy Transfers Rpc Http Serialization CryptoNoteCore System Logging Common Crypto ${Boost_LIBRARIES})
target_link_libraries(PaymentGateService PaymentGate JsonRpcServer Wallet NodeRpcProxy Transfers CryptoNoteCore Crypto P2P Rpc Http Serialization System Logging Common InProcessNode upnpc-static BlockchainExplorer ${Boost_LIBRARIES})
if (MSVC)
target_link_libraries(ConnectivityTool ws2_32)
target_link_libraries(SimpleWallet ws2_32)
endif ()
target_link_libraries(Miner CryptoNoteCore Rpc Serialization System Http Logging Common Crypto ${Boost_LIBRARIES})
add_dependencies(Rpc version)
@ -77,5 +78,6 @@ add_dependencies(P2P version)
set_property(TARGET ConnectivityTool PROPERTY OUTPUT_NAME "connectivity_tool")
set_property(TARGET SimpleWallet PROPERTY OUTPUT_NAME "simplewallet")
set_property(TARGET PaymentGateService PROPERTY OUTPUT_NAME "walletd")
set_property(TARGET Miner PROPERTY OUTPUT_NAME "miner")
#TODO Specify the name of daemon for your currency
set_property(TARGET Daemon PROPERTY OUTPUT_NAME "cryptonoted")

View file

@ -1,4 +1,4 @@
// Copyright (c) 2011-2015 The Cryptonote developers
// Copyright (c) 2011-2016 The Cryptonote developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

View file

@ -1,4 +1,4 @@
// Copyright (c) 2011-2015 The Cryptonote developers
// Copyright (c) 2011-2016 The Cryptonote developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

View file

@ -1,4 +1,4 @@
// Copyright (c) 2011-2015 The Cryptonote developers
// Copyright (c) 2011-2016 The Cryptonote developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

View file

@ -1,4 +1,4 @@
// Copyright (c) 2011-2015 The Cryptonote developers
// Copyright (c) 2011-2016 The Cryptonote developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

View file

@ -1,4 +1,4 @@
// Copyright (c) 2011-2015 The Cryptonote developers
// Copyright (c) 2011-2016 The Cryptonote developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

View file

@ -1,4 +1,4 @@
// Copyright (c) 2011-2015 The Cryptonote developers
// Copyright (c) 2011-2016 The Cryptonote developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

View file

@ -1,4 +1,4 @@
// Copyright (c) 2011-2015 The Cryptonote developers
// Copyright (c) 2011-2016 The Cryptonote developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

View file

@ -1,4 +1,4 @@
// Copyright (c) 2011-2015 The Cryptonote developers
// Copyright (c) 2011-2016 The Cryptonote developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

View file

@ -1,4 +1,4 @@
// Copyright (c) 2011-2015 The Cryptonote developers
// Copyright (c) 2011-2016 The Cryptonote developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

View file

@ -1,4 +1,4 @@
// Copyright (c) 2011-2015 The Cryptonote developers
// Copyright (c) 2011-2016 The Cryptonote developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

View file

@ -1,4 +1,4 @@
// Copyright (c) 2011-2015 The Cryptonote developers
// Copyright (c) 2011-2016 The Cryptonote developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

View file

@ -1,4 +1,4 @@
// Copyright (c) 2011-2015 The Cryptonote developers
// Copyright (c) 2011-2016 The Cryptonote developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

View file

@ -1,4 +1,4 @@
// Copyright (c) 2011-2015 The Cryptonote developers
// Copyright (c) 2011-2016 The Cryptonote developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

View file

@ -1,4 +1,4 @@
// Copyright (c) 2011-2015 The Cryptonote developers
// Copyright (c) 2011-2016 The Cryptonote developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

View file

@ -1,4 +1,4 @@
// Copyright (c) 2011-2015 The Cryptonote developers
// Copyright (c) 2011-2016 The Cryptonote developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

View file

@ -1,4 +1,4 @@
// Copyright (c) 2011-2015 The Cryptonote developers
// Copyright (c) 2011-2016 The Cryptonote developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

View file

@ -1,4 +1,4 @@
// Copyright (c) 2011-2015 The Cryptonote developers
// Copyright (c) 2011-2016 The Cryptonote developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

View file

@ -1,4 +1,4 @@
// Copyright (c) 2011-2015 The Cryptonote developers
// Copyright (c) 2011-2016 The Cryptonote developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

View file

@ -1,4 +1,4 @@
// Copyright (c) 2011-2015 The Cryptonote developers
// Copyright (c) 2011-2016 The Cryptonote developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

View file

@ -1,4 +1,4 @@
// Copyright (c) 2011-2015 The Cryptonote developers
// Copyright (c) 2011-2016 The Cryptonote developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

View file

@ -1,4 +1,4 @@
// Copyright (c) 2011-2015 The Cryptonote developers
// Copyright (c) 2011-2016 The Cryptonote developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

View file

@ -1,4 +1,4 @@
// Copyright (c) 2011-2015 The Cryptonote developers
// Copyright (c) 2011-2016 The Cryptonote developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

View file

@ -1,4 +1,4 @@
// Copyright (c) 2011-2015 The Cryptonote developers
// Copyright (c) 2011-2016 The Cryptonote developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
@ -107,6 +107,32 @@ public:
}
}
template<typename F, typename Arg0, typename Arg1, typename Arg2, typename Arg3, typename Arg4>
void notify(F notification, const Arg0& arg0, const Arg1& arg1, const Arg2& arg2, const Arg3& arg3, const Arg4& arg4) {
std::vector<T*> observersCopy;
{
std::unique_lock<std::mutex> lock(m_observersMutex);
observersCopy = m_observers;
}
for (T* observer : observersCopy) {
(observer->*notification)(arg0, arg1, arg2, arg3, arg4);
}
}
template<typename F, typename Arg0, typename Arg1, typename Arg2, typename Arg3, typename Arg4, typename Arg5>
void notify(F notification, const Arg0& arg0, const Arg1& arg1, const Arg2& arg2, const Arg3& arg3, const Arg4& arg4, const Arg5& arg5) {
std::vector<T*> observersCopy;
{
std::unique_lock<std::mutex> lock(m_observersMutex);
observersCopy = m_observers;
}
for (T* observer : observersCopy) {
(observer->*notification)(arg0, arg1, arg2, arg3, arg4, arg5);
}
}
#else
template<typename F, typename... Args>

View file

@ -1,4 +1,4 @@
// Copyright (c) 2011-2015 The Cryptonote developers
// Copyright (c) 2011-2016 The Cryptonote developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

View file

@ -1,4 +1,4 @@
// Copyright (c) 2011-2015 The Cryptonote developers
// Copyright (c) 2011-2016 The Cryptonote developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

24
src/Common/ScopeExit.cpp Normal file
View file

@ -0,0 +1,24 @@
// Copyright (c) 2011-2016 The Cryptonote developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "ScopeExit.h"
namespace Tools {
ScopeExit::ScopeExit(std::function<void()>&& handler) :
m_handler(std::move(handler)),
m_cancelled(false) {
}
ScopeExit::~ScopeExit() {
if (!m_cancelled) {
m_handler();
}
}
void ScopeExit::cancel() {
m_cancelled = true;
}
}

28
src/Common/ScopeExit.h Normal file
View file

@ -0,0 +1,28 @@
// Copyright (c) 2011-2016 The Cryptonote developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#pragma once
#include <functional>
namespace Tools {
class ScopeExit {
public:
ScopeExit(std::function<void()>&& handler);
~ScopeExit();
ScopeExit(const ScopeExit&) = delete;
ScopeExit(ScopeExit&&) = delete;
ScopeExit& operator=(const ScopeExit&) = delete;
ScopeExit& operator=(ScopeExit&&) = delete;
void cancel();
private:
std::function<void()> m_handler;
bool m_cancelled;
};
}

View file

@ -1,4 +1,4 @@
// Copyright (c) 2011-2015 The Cryptonote developers
// Copyright (c) 2011-2016 The Cryptonote developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

View file

@ -1,4 +1,4 @@
// Copyright (c) 2011-2015 The Cryptonote developers
// Copyright (c) 2011-2016 The Cryptonote developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

View file

@ -1,4 +1,4 @@
// Copyright (c) 2011-2015 The Cryptonote developers
// Copyright (c) 2011-2016 The Cryptonote developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

View file

@ -1,4 +1,4 @@
// Copyright (c) 2011-2015 The Cryptonote developers
// Copyright (c) 2011-2016 The Cryptonote developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

View file

@ -1,4 +1,4 @@
// Copyright (c) 2011-2015 The Cryptonote developers
// Copyright (c) 2011-2016 The Cryptonote developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

View file

@ -1,4 +1,4 @@
// Copyright (c) 2011-2015 The Cryptonote developers
// Copyright (c) 2011-2016 The Cryptonote developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

View file

@ -1,4 +1,4 @@
// Copyright (c) 2011-2015 The Cryptonote developers
// Copyright (c) 2011-2016 The Cryptonote developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

View file

@ -1,4 +1,4 @@
// Copyright (c) 2011-2015 The Cryptonote developers
// Copyright (c) 2011-2016 The Cryptonote developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
@ -145,7 +145,7 @@ void readVarint(IInputStream& in, uint64_t& value) {
throw std::runtime_error("readVarint, value overflow");
}
temp |= static_cast<size_t>(piece & 0x7f) << shift;
temp |= static_cast<uint64_t>(piece & 0x7f) << shift;
if ((piece & 0x80) == 0) {
if (piece == 0 && shift != 0) {
throw std::runtime_error("readVarint, invalid value representation");

View file

@ -1,4 +1,4 @@
// Copyright (c) 2011-2015 The Cryptonote developers
// Copyright (c) 2011-2016 The Cryptonote developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

View file

@ -1,4 +1,4 @@
// Copyright (c) 2011-2015 The Cryptonote developers
// Copyright (c) 2011-2016 The Cryptonote developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
@ -19,6 +19,8 @@ public:
const static Size MAXIMUM_SIZE = MAXIMUM_SIZE_VALUE;
const static Size INVALID;
static_assert(MAXIMUM_SIZE != 0, "StringBuffer's size must not be zero");
// Default constructor.
// After construction, 'StringBuffer' is empty, that is 'size' == 0
StringBuffer() : size(0) {
@ -189,7 +191,6 @@ public:
// Compare two strings character-wise.
bool operator<(StringView other) const {
assert(data != nullptr || size == 0);
Size count = other.getSize() < size ? other.getSize() : size;
for (Size i = 0; i < count; ++i) {
Object char1 = *(data + i);
@ -341,7 +342,6 @@ public:
// Looks for the last occurence of 'object' in 'StringView',
// returns index or INVALID if there are no occurences.
Size findLast(const Object& object) const {
assert(data != nullptr || size == 0);
for (Size i = 0; i < size; ++i) {
if (*(data + (size - 1 - i)) == object) {
return size - 1 - i;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2011-2015 The Cryptonote developers
// Copyright (c) 2011-2016 The Cryptonote developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

View file

@ -1,4 +1,4 @@
// Copyright (c) 2011-2015 The Cryptonote developers
// Copyright (c) 2011-2016 The Cryptonote developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

View file

@ -1,4 +1,4 @@
// Copyright (c) 2011-2015 The Cryptonote developers
// Copyright (c) 2011-2016 The Cryptonote developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

View file

@ -1,4 +1,4 @@
// Copyright (c) 2011-2015 The Cryptonote developers
// Copyright (c) 2011-2016 The Cryptonote developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

View file

@ -1,4 +1,4 @@
// Copyright (c) 2011-2015 The Cryptonote developers
// Copyright (c) 2011-2016 The Cryptonote developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

View file

@ -1,4 +1,4 @@
// Copyright (c) 2011-2015 The Cryptonote developers
// Copyright (c) 2011-2016 The Cryptonote developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

View file

@ -1,4 +1,4 @@
// Copyright (c) 2011-2015 The Cryptonote developers
// Copyright (c) 2011-2016 The Cryptonote developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

View file

@ -1,4 +1,4 @@
// Copyright (c) 2011-2015 The Cryptonote developers
// Copyright (c) 2011-2016 The Cryptonote developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

View file

@ -1,4 +1,4 @@
// Copyright (c) 2011-2015 The Cryptonote developers
// Copyright (c) 2011-2016 The Cryptonote developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
@ -346,4 +346,9 @@ std::string get_nix_version_display_string()
return std::error_code(code, std::system_category());
}
bool directoryExists(const std::string& path) {
boost::system::error_code ec;
return boost::filesystem::is_directory(path, ec);
}
}

View file

@ -1,4 +1,4 @@
// Copyright (c) 2011-2015 The Cryptonote developers
// Copyright (c) 2011-2016 The Cryptonote developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
@ -13,4 +13,5 @@ namespace Tools
std::string get_os_version_string();
bool create_directories_if_necessary(const std::string& path);
std::error_code replace_file(const std::string& replacement_name, const std::string& replaced_name);
bool directoryExists(const std::string& path);
}

View file

@ -1,4 +1,4 @@
// Copyright (c) 2011-2015 The Cryptonote developers
// Copyright (c) 2011-2016 The Cryptonote developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

View file

@ -1,4 +1,4 @@
// Copyright (c) 2011-2015 The Cryptonote developers
// Copyright (c) 2011-2016 The Cryptonote developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

View file

@ -1,4 +1,4 @@
// Copyright (c) 2011-2015 The Cryptonote developers
// Copyright (c) 2011-2016 The Cryptonote developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

View file

@ -1,4 +1,4 @@
// Copyright (c) 2011-2015 The Cryptonote developers
// Copyright (c) 2011-2016 The Cryptonote developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

View file

@ -1,4 +1,4 @@
// Copyright (c) 2011-2015 The Cryptonote developers
// Copyright (c) 2011-2016 The Cryptonote developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

View file

@ -1,4 +1,4 @@
// Copyright (c) 2011-2015 The Cryptonote developers
// Copyright (c) 2011-2016 The Cryptonote developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

View file

@ -1,4 +1,4 @@
// Copyright (c) 2011-2015 The Cryptonote developers
// Copyright (c) 2011-2016 The Cryptonote developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

View file

@ -1,4 +1,4 @@
// Copyright (c) 2011-2015 The Cryptonote developers
// Copyright (c) 2011-2016 The Cryptonote developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

View file

@ -1,4 +1,4 @@
// Copyright (c) 2011-2015 The Cryptonote developers
// Copyright (c) 2011-2016 The Cryptonote developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

View file

@ -1,4 +1,4 @@
// Copyright (c) 2011-2015 The Cryptonote developers
// Copyright (c) 2011-2016 The Cryptonote developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

View file

@ -1,4 +1,4 @@
// Copyright (c) 2011-2015 The Cryptonote developers
// Copyright (c) 2011-2016 The Cryptonote developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

View file

@ -1,4 +1,4 @@
// Copyright (c) 2011-2015 The Cryptonote developers
// Copyright (c) 2011-2016 The Cryptonote developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

View file

@ -1,4 +1,4 @@
// Copyright (c) 2011-2015 The Cryptonote developers
// Copyright (c) 2011-2016 The Cryptonote developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
@ -306,7 +306,6 @@ m_currency(currency),
m_tx_pool(tx_pool),
m_current_block_cumul_sz_limit(0),
m_is_in_checkpoint_zone(false),
m_is_blockchain_storing(false),
m_checkpoints(logger) {
m_outputs.set_deleted_key(0);
@ -753,7 +752,7 @@ bool Blockchain::switch_to_alternative_blockchain(std::list<blocks_ext_by_hash::
m_alternative_chains.erase(ch_ent);
}
sendMessage(BlockchainMessage(std::move(ChainSwitchMessage(std::move(blocksFromCommonRoot)))));
sendMessage(BlockchainMessage(ChainSwitchMessage(std::move(blocksFromCommonRoot))));
logger(INFO, BRIGHT_GREEN) << "REORGANIZE SUCCESS! on height: " << split_height << ", new blockchain size: " << m_blocks.size();
return true;
@ -1066,7 +1065,7 @@ bool Blockchain::handle_alternative_block(const Block& b, const Crypto::Hash& id
<< ENDL << "PoW:\t" << proof_of_work
<< ENDL << "difficulty:\t" << current_diff;
if (sendNewAlternativeBlockMessage) {
sendMessage(BlockchainMessage(std::move(NewAlternativeBlockMessage(id))));
sendMessage(BlockchainMessage(NewAlternativeBlockMessage(id)));
}
return true;
}
@ -1617,7 +1616,7 @@ bool Blockchain::addNewBlock(const Block& bl_, block_verification_context& bvc)
} else {
add_result = pushBlock(bl, bvc);
if (add_result) {
sendMessage(BlockchainMessage(std::move(NewBlockMessage(id))));
sendMessage(BlockchainMessage(NewBlockMessage(id)));
}
}
}

View file

@ -1,4 +1,4 @@
// Copyright (c) 2011-2015 The Cryptonote developers
// Copyright (c) 2011-2016 The Cryptonote developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
@ -92,7 +92,6 @@ namespace CryptoNote {
bool get_out_by_msig_gindex(uint64_t amount, uint64_t gindex, MultisignatureOutput& out);
bool checkTransactionInputs(const Transaction& tx, uint32_t& pmax_used_block_height, Crypto::Hash& max_used_block_id, BlockInfo* tail = 0);
uint64_t getCurrentCumulativeBlocksizeLimit();
bool isStoringBlockchain(){return m_is_blockchain_storing;}
uint64_t blockDifficulty(size_t i);
bool getBlockContainingTransaction(const Crypto::Hash& txId, Crypto::Hash& blockId, uint32_t& blockHeight);
bool getAlreadyGeneratedCoins(const Crypto::Hash& hash, uint64_t& generatedCoins);
@ -233,7 +232,6 @@ namespace CryptoNote {
std::string m_config_folder;
Checkpoints m_checkpoints;
std::atomic<bool> m_is_in_checkpoint_zone;
std::atomic<bool> m_is_blockchain_storing;
typedef SwappedVector<BlockEntry> Blocks;
typedef std::unordered_map<Crypto::Hash, uint32_t> BlockMap;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2011-2015 The Cryptonote developers
// Copyright (c) 2011-2016 The Cryptonote developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

View file

@ -1,4 +1,4 @@
// Copyright (c) 2011-2015 The Cryptonote developers
// Copyright (c) 2011-2016 The Cryptonote developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

View file

@ -1,4 +1,4 @@
// Copyright (c) 2011-2015 The Cryptonote developers
// Copyright (c) 2011-2016 The Cryptonote developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

View file

@ -1,4 +1,4 @@
// Copyright (c) 2011-2015 The Cryptonote developers
// Copyright (c) 2011-2016 The Cryptonote developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

View file

@ -1,4 +1,4 @@
// Copyright (c) 2011-2015 The Cryptonote developers
// Copyright (c) 2011-2016 The Cryptonote developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

View file

@ -1,4 +1,4 @@
// Copyright (c) 2011-2015 The Cryptonote developers
// Copyright (c) 2011-2016 The Cryptonote developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

View file

@ -1,4 +1,4 @@
// Copyright (c) 2011-2015 The Cryptonote developers
// Copyright (c) 2011-2016 The Cryptonote developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
@ -86,11 +86,6 @@ bool core::handle_command_line(const boost::program_options::variables_map& vm)
return true;
}
bool core::is_ready() {
return !m_blockchain.isStoringBlockchain();
}
uint32_t core::get_current_blockchain_height() {
return m_blockchain.getCurrentBlockchainHeight();
}

View file

@ -1,4 +1,4 @@
// Copyright (c) 2011-2015 The Cryptonote developers
// Copyright (c) 2011-2016 The Cryptonote developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
@ -35,18 +35,18 @@ namespace CryptoNote {
core(const Currency& currency, i_cryptonote_protocol* pprotocol, Logging::ILogger& logger);
~core();
bool on_idle();
virtual bool handle_incoming_tx(const BinaryArray& tx_blob, tx_verification_context& tvc, bool keeped_by_block); //Deprecated. Should be removed with CryptoNoteProtocolHandler.
bool handle_incoming_block_blob(const BinaryArray& block_blob, block_verification_context& bvc, bool control_miner, bool relay_block);
virtual i_cryptonote_protocol* get_protocol(){return m_pprotocol;}
bool on_idle() override;
virtual bool handle_incoming_tx(const BinaryArray& tx_blob, tx_verification_context& tvc, bool keeped_by_block) override; //Deprecated. Should be removed with CryptoNoteProtocolHandler.
bool handle_incoming_block_blob(const BinaryArray& block_blob, block_verification_context& bvc, bool control_miner, bool relay_block) override;
virtual i_cryptonote_protocol* get_protocol() override {return m_pprotocol;}
const Currency& currency() const { return m_currency; }
//-------------------- IMinerHandler -----------------------
virtual bool handle_block_found(Block& b);
virtual bool get_block_template(Block& b, const AccountPublicAddress& adr, difficulty_type& diffic, uint32_t& height, const BinaryArray& ex_nonce);
virtual bool handle_block_found(Block& b) override;
virtual bool get_block_template(Block& b, const AccountPublicAddress& adr, difficulty_type& diffic, uint32_t& height, const BinaryArray& ex_nonce) override;
bool addObserver(ICoreObserver* observer);
bool removeObserver(ICoreObserver* observer);
bool addObserver(ICoreObserver* observer) override;
bool removeObserver(ICoreObserver* observer) override;
miner& get_miner() { return *m_miner; }
static void init_options(boost::program_options::options_description& desc);
@ -80,13 +80,12 @@ namespace CryptoNote {
virtual bool removeMessageQueue(MessageQueue<BlockchainMessage>& messageQueue) override;
uint32_t get_current_blockchain_height();
bool have_block(const Crypto::Hash& id);
bool have_block(const Crypto::Hash& id) override;
std::vector<Crypto::Hash> buildSparseChain() override;
std::vector<Crypto::Hash> buildSparseChain(const Crypto::Hash& startBlockId) override;
void on_synchronized();
bool is_ready() override;
void on_synchronized() override;
virtual void get_blockchain_top(uint32_t& height, Crypto::Hash& top_id);
virtual void get_blockchain_top(uint32_t& height, Crypto::Hash& top_id) override;
bool get_blocks(uint32_t start_offset, uint32_t count, std::list<Block>& blocks, std::list<Transaction>& txs);
bool get_blocks(uint32_t start_offset, uint32_t count, std::list<Block>& blocks);
template<class t_ids_container, class t_blocks_container, class t_missed_container>
@ -116,13 +115,13 @@ namespace CryptoNote {
//bool get_outs(uint64_t amount, std::list<Crypto::PublicKey>& pkeys);
virtual std::vector<Crypto::Hash> findBlockchainSupplement(const std::vector<Crypto::Hash>& remoteBlockIds, size_t maxCount,
uint32_t& totalBlockCount, uint32_t& startBlockIndex) override;
bool get_stat_info(core_stat_info& st_inf);
bool get_stat_info(core_stat_info& st_inf) override;
virtual bool get_tx_outputs_gindexs(const Crypto::Hash& tx_id, std::vector<uint32_t>& indexs);
virtual bool get_tx_outputs_gindexs(const Crypto::Hash& tx_id, std::vector<uint32_t>& indexs) override;
Crypto::Hash get_tail_id();
virtual bool get_random_outs_for_amounts(const COMMAND_RPC_GET_RANDOM_OUTPUTS_FOR_AMOUNTS_request& req, COMMAND_RPC_GET_RANDOM_OUTPUTS_FOR_AMOUNTS_response& res);
void pause_mining();
void update_block_template_and_resume_mining();
virtual bool get_random_outs_for_amounts(const COMMAND_RPC_GET_RANDOM_OUTPUTS_FOR_AMOUNTS_request& req, COMMAND_RPC_GET_RANDOM_OUTPUTS_FOR_AMOUNTS_response& res) override;
void pause_mining() override;
void update_block_template_and_resume_mining() override;
//Blockchain& get_blockchain_storage(){return m_blockchain;}
//debug functions
void print_blockchain(uint32_t start_index, uint32_t end_index);

View file

@ -1,4 +1,4 @@
// Copyright (c) 2011-2015 The Cryptonote developers
// Copyright (c) 2011-2016 The Cryptonote developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
@ -16,6 +16,7 @@ CoreConfig::CoreConfig() {
void CoreConfig::init(const boost::program_options::variables_map& options) {
if (options.count(command_line::arg_data_dir.name) != 0 && (!options[command_line::arg_data_dir.name].defaulted() || configFolder == Tools::getDefaultDataDirectory())) {
configFolder = command_line::get_arg(options, command_line::arg_data_dir);
configFolderDefaulted = options[command_line::arg_data_dir.name].defaulted();
}
}

Some files were not shown because too many files have changed in this diff Show more