Skip to content

Commit

Permalink
move proposer* from esperanza/ to proposer/
Browse files Browse the repository at this point in the history
  • Loading branch information
scravy committed Oct 11, 2018
1 parent 99f5591 commit 2f2fd6a
Show file tree
Hide file tree
Showing 12 changed files with 54 additions and 53 deletions.
14 changes: 7 additions & 7 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,7 @@ UNITE_CORE_H = \
esperanza/finalizationstate.h \
esperanza/init.h \
esperanza/kernel.h \
esperanza/proposer.h \
esperanza/proposer_init.h \
esperanza/params.h \
esperanza/rpcproposer.h \
esperanza/settings.h \
esperanza/settings_init.h \
esperanza/stakevalidation.h \
Expand Down Expand Up @@ -153,6 +150,8 @@ UNITE_CORE_H = \
policy/policy.h \
policy/rbf.h \
pow.h \
proposer/proposer.h \
proposer/proposer_init.h \
proposer/transactionpicker.h \
protocol.h \
random.h \
Expand All @@ -162,6 +161,7 @@ UNITE_CORE_H = \
rpc/client.h \
rpc/esperanza.h \
rpc/mining.h \
rpc/proposer.h \
rpc/protocol.h \
rpc/safemode.h \
rpc/server.h \
Expand Down Expand Up @@ -265,7 +265,6 @@ libunite_server_a_SOURCES = \
policy/policy.cpp \
policy/rbf.cpp \
pow.cpp \
proposer/transactionpicker.cpp \
rest.cpp \
rpc/blockchain.cpp \
rpc/esperanza.cpp \
Expand Down Expand Up @@ -311,12 +310,13 @@ libunite_wallet_a_SOURCES = \
address/address.cpp \
esperanza/init.cpp \
esperanza/kernel.cpp \
esperanza/proposer.cpp \
esperanza/proposer_init.cpp \
esperanza/rpcproposer.cpp \
esperanza/stakevalidation.cpp \
esperanza/walletextension.cpp \
key/mnemonic/mnemonic.cpp \
proposer/proposer.cpp \
proposer/proposer_init.cpp \
proposer/transactionpicker.cpp \
rpc/proposer.cpp \
unilib/uninorms.cpp \
unilib/utf8.cpp \
wallet/crypter.cpp \
Expand Down
4 changes: 2 additions & 2 deletions src/Makefile.test.include
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ UNITE_TESTS =\
test/policyestimator_tests.cpp \
test/pow_tests.cpp \
test/prevector_tests.cpp \
test/proposer/blockassembleradapter_tests.cpp \
test/raii_event_tests.cpp \
test/random_tests.cpp \
test/reverselock_tests.cpp \
Expand Down Expand Up @@ -111,7 +110,8 @@ UNITE_TESTS =\
if ENABLE_WALLET
UNITE_TESTS += \
test/mnemonic_tests.cpp \
test/proposer_tests.cpp \
test/proposer/blockassembleradapter_tests.cpp \
test/proposer/proposer_tests.cpp \
wallet/test/wallet_test_fixture.cpp \
wallet/test/wallet_test_fixture.h \
wallet/test/accounting_tests.cpp \
Expand Down
6 changes: 3 additions & 3 deletions src/esperanza/walletextension.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

#include <esperanza/walletextension.h>

#include <consensus/validation.h>
#include <esperanza/finalizationstate.h>
#include <esperanza/kernel.h>
#include <esperanza/proposer.h>
#include <esperanza/stakevalidation.h>
#include <esperanza/walletextension.h>
#include <net.h>
#include <policy/policy.h>
#include <primitives/txtype.h>
Expand Down Expand Up @@ -792,7 +792,7 @@ void WalletExtension::BlockConnected(
}
}

const Proposer::State &WalletExtension::GetProposerState() const {
const proposer::Proposer::State &WalletExtension::GetProposerState() const {
return m_proposerState;
}

Expand Down
8 changes: 4 additions & 4 deletions src/esperanza/walletextension.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
#define UNITE_ESPERANZA_WALLETEXTENSION_H

#include <amount.h>
#include <esperanza/proposer.h>
#include <esperanza/validatorstate.h>
#include <key.h>
#include <key/mnemonic/mnemonic.h>
#include <miner.h>
#include <primitives/transaction.h>
#include <proposer/proposer.h>

#include <cstddef>
#include <cstdint>
Expand All @@ -29,7 +29,7 @@ namespace esperanza {
//! in bitcoin-core. The alterations done to wallet.h/wallet.cpp are kept to
//! a minimum. All extended functionality should be put here.
class WalletExtension {
friend class esperanza::Proposer;
friend class proposer::Proposer;

private:
//! a reference to the esperanza settings
Expand All @@ -45,7 +45,7 @@ class WalletExtension {
int m_deepestTxnDepth = 0;

//! the state of proposing blocks from this wallet
Proposer::State m_proposerState;
proposer::Proposer::State m_proposerState;

void VoteIfNeeded(const std::shared_ptr<const CBlock> &pblock,
const CBlockIndex *pindex);
Expand Down Expand Up @@ -95,7 +95,7 @@ class WalletExtension {
void BlockConnected(const std::shared_ptr<const CBlock> &pblock,
const CBlockIndex *pindex);

const Proposer::State &GetProposerState() const;
const proposer::Proposer::State &GetProposerState() const;

ValidatorState validatorState;
bool nIsValidatorEnabled = false;
Expand Down
10 changes: 5 additions & 5 deletions src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@
#include <wallet/wallet.h>
#include <esperanza/settings.h>
#include <esperanza/settings_init.h>
#include <esperanza/proposer_init.h>
#include <esperanza/rpcproposer.h>
#include <proposer/proposer_init.h>
#include <rpc/proposer.h>
#endif
#include <warnings.h>
#include <stdint.h>
Expand Down Expand Up @@ -200,7 +200,7 @@ void Shutdown()
StopRPC();
StopHTTPServer();
#ifdef ENABLE_WALLET
esperanza::StopProposer();
proposer::StopProposer();
FlushWallets();
#endif
MapPort(false);
Expand Down Expand Up @@ -1854,10 +1854,10 @@ bool AppInitMain()

// ********************************************************* Step 13: start proposing

if (!esperanza::InitProposer(*esperanzaSettings, vpwallets)) {
if (!proposer::InitProposer(*esperanzaSettings, vpwallets)) {
return false;
}
esperanza::StartProposer();
proposer::StartProposer();
#endif

LogPrintf("Started up.\n");
Expand Down
15 changes: 8 additions & 7 deletions src/esperanza/proposer.cpp → src/proposer/proposer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

#include <esperanza/proposer.h>
#include <proposer/proposer.h>

#include <address/address.h>
#include <chainparams.h>
Expand All @@ -21,9 +21,10 @@
#include <chrono>
#include <memory>

namespace esperanza {
namespace proposer {

Proposer::Thread::Thread(const std::string &threadName, const Settings &config,
Proposer::Thread::Thread(const std::string &threadName,
const esperanza::Settings &config,
const std::vector<CWallet *> &wallets,
CountingSemaphore &initSemaphore,
CountingSemaphore &startSemaphore,
Expand Down Expand Up @@ -59,7 +60,7 @@ void Proposer::Thread::SetStatus(const Proposer::Status status,
}

std::vector<std::unique_ptr<Proposer::Thread>> Proposer::CreateProposerThreads(
const Settings &settings, const std::vector<CWallet *> &wallets,
const esperanza::Settings &settings, const std::vector<CWallet *> &wallets,
CountingSemaphore &initSemaphore, CountingSemaphore &startSemaphore,
CountingSemaphore &stopSemaphore) {
// total number of threads can not exceed number of wallets
Expand Down Expand Up @@ -98,7 +99,7 @@ std::vector<std::unique_ptr<Proposer::Thread>> Proposer::CreateProposerThreads(
return threads;
}

Proposer::Proposer(const Settings &settings,
Proposer::Proposer(const esperanza::Settings &settings,
const std::vector<CWallet *> &wallets)
: m_initSemaphore(0),
m_startSemaphore(0),
Expand Down Expand Up @@ -269,7 +270,7 @@ void Proposer::Run(Proposer::Thread &thread) {
if (walletExt.SignBlock(blockTemplate.get(), bestHeight + 1,
searchTime)) {
const CBlock &block = blockTemplate->block;
if (!ProposeBlock(blockTemplate->block)) {
if (!esperanza::ProposeBlock(blockTemplate->block)) {
LogPrint(BCLog::PROPOSING, "%s/%s: failed to propose block",
thread.m_threadName, wallet->GetName());
continue;
Expand Down Expand Up @@ -297,4 +298,4 @@ void Proposer::Run(Proposer::Thread &thread) {
thread.m_stopSemaphore.release();
}

} // namespace esperanza
} // namespace proposer
18 changes: 9 additions & 9 deletions src/esperanza/proposer.h → src/proposer/proposer.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

#ifndef UNITE_ESPERANZA_PROPOSER_H
#define UNITE_ESPERANZA_PROPOSER_H
#ifndef UNITE_PROPOSER_PROPOSER_H
#define UNITE_PROPOSER_PROPOSER_H

#include <better-enums/enum.h>
#include <esperanza/settings.h>
Expand All @@ -20,7 +20,7 @@

class CWallet;

namespace esperanza {
namespace proposer {

// a stub for testing – specializations of this class have access to the
// Proposer's guts
Expand Down Expand Up @@ -81,7 +81,7 @@ class Proposer {
Proposer(
//! [in] a name to derive thread names from (groupName-1, groupName-2,
//! ...)
const Settings &,
const esperanza::Settings &,
//! [in] a reference to all wallets to propose from
const std::vector<CWallet *> &wallets);

Expand All @@ -105,7 +105,7 @@ class Proposer {
const std::string m_threadName;

//! unmodifiable reference to esperanza configuration
const Settings &m_settings;
const esperanza::Settings &m_settings;

//! will be set to true to stop the thread
std::atomic<bool> m_interrupted;
Expand All @@ -130,7 +130,7 @@ class Proposer {
//! [in] a name for this thread.
const std::string &,
//! [in] a reference to the global esperanza config
const Settings &,
const esperanza::Settings &,
//! [in] the wallets which this thread is responsible for.
const std::vector<CWallet *> &,
//! a semaphore for synchronizing initialization
Expand Down Expand Up @@ -167,13 +167,13 @@ class Proposer {
const std::vector<std::unique_ptr<Thread>> m_threads;

static std::vector<std::unique_ptr<Proposer::Thread>> CreateProposerThreads(
const Settings &settings, const std::vector<CWallet *> &wallets,
const esperanza::Settings &settings, const std::vector<CWallet *> &wallets,
CountingSemaphore &initSemaphore, CountingSemaphore &startSemaphore,
CountingSemaphore &stopSemaphore);

static void Run(Thread &);
};

} // namespace esperanza
} // namespace proposer

#endif // UNITE_ESPERANZA_PROPOSER_H
#endif // UNITE_PROPOSER_PROPOSER_H
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

#include <esperanza/proposer_init.h>
#include <proposer/proposer_init.h>

#include <esperanza/proposer.h>
#include <proposer/proposer.h>
#include <util.h>

#include <mutex>

namespace esperanza {
namespace proposer {

static std::mutex initLock;
static std::unique_ptr<Proposer> proposer = nullptr;

bool InitProposer(const Settings &settings,
bool InitProposer(const esperanza::Settings &settings,
const std::vector<CWallet *> &wallets) {
std::unique_lock<decltype(initLock)> lock;
if (proposer) {
Expand Down Expand Up @@ -56,4 +56,4 @@ void WakeProposer(const CWallet *wallet) {
}
}

} // namespace esperanza
} // namespace proposer
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@

class CWallet;

namespace esperanza {
namespace proposer {

bool InitProposer(const Settings &settings,
bool InitProposer(const esperanza::Settings &settings,
const std::vector<CWallet *> &wallets);

void StartProposer();
Expand All @@ -22,6 +22,6 @@ void StopProposer();

void WakeProposer(const CWallet *wallet = nullptr);

} // namespace esperanza
} // namespace proposer

#endif // UNIT_E_PROPOSER_INIT_H
12 changes: 6 additions & 6 deletions src/esperanza/rpcproposer.cpp → src/rpc/proposer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

#include <esperanza/rpcproposer.h>
#include <rpc/proposer.h>

#include <core_io.h>
#include <esperanza/proposer.h>
#include <esperanza/proposer_init.h>
#include <proposer/proposer.h>
#include <proposer/proposer_init.h>
#include <net.h>
#include <rpc/server.h>
#include <rpc/util.h>
Expand Down Expand Up @@ -50,16 +50,16 @@ UniValue proposerstatus(const JSONRPCRequest &request) {
}

UniValue proposerwake(const JSONRPCRequest &request) {
esperanza::WakeProposer();
proposer::WakeProposer();
return proposerstatus(request);
}

// clang-format off
static const CRPCCommand commands[] = {
// category name actor (function) argNames
// --------------------- ------------------------ ----------------------- ------------------------------------------
{ "esperanza", "proposerstatus", &proposerstatus, {}},
{ "esperanza", "proposerwake", &proposerwake, {}},
{ "proposer", "proposerstatus", &proposerstatus, {}},
{ "proposer", "proposerwake", &proposerwake, {}},
};
// clang-format on

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

#include <esperanza/proposer.h>
#include <proposer/proposer.h>
#include <test/test_unite.h>
#include <wallet/wallet.h>
#include <boost/test/unit_test.hpp>

#include <thread>

namespace esperanza {
namespace proposer {

struct None {};

Expand Down

0 comments on commit 2f2fd6a

Please sign in to comment.