Browse Source

Merge branch 'develop' into netFix

cl-refactor
subtly 10 years ago
parent
commit
2c05a0b8fc
  1. 6
      CMakeLists.txt
  2. 21
      libdevcrypto/Common.cpp
  3. 6
      libdevcrypto/Common.h
  4. 4
      libp2p/Host.cpp
  5. 3
      libp2p/RLPXSocket.h
  6. 5
      test/TestUtils.cpp
  7. 8
      test/TestUtils.h
  8. 2
      test/libdevcrypto/SecretStore.cpp
  9. 2
      test/libdevcrypto/crypto.cpp

6
CMakeLists.txt

@ -527,8 +527,8 @@ endif ()
if (WIN32)
# packaging stuff
include(InstallRequiredSystemLibraries)
set(CPACK_PACKAGE_NAME "Ethereum (++)")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "The Ethereum (++) Toolset")
set(CPACK_PACKAGE_NAME "Ethereum")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "The Ethereum Toolset")
set(CPACK_PACKAGE_VENDOR "ethereum.org")
set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README.md")
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
@ -557,7 +557,7 @@ if (WIN32)
set(CPACK_PACKAGE_INSTALL_REGISTRY_KEY "${CPACK_PACKAGE_NAME} ${CPACK_PACKAGE_VERSION}")
endif()
set(CPACK_NSIS_DISPLAY_NAME "Ethereum (++)")
set(CPACK_NSIS_DISPLAY_NAME "Ethereum")
set(CPACK_NSIS_HELP_LINK "https://github.com/ethereum/cpp-ethereum")
set(CPACK_NSIS_URL_INFO_ABOUT "https://github.com/ethereum/cpp-ethereum")
set(CPACK_NSIS_CONTACT "ethereum.org")

21
libdevcrypto/Common.cpp

@ -308,33 +308,14 @@ h256 crypto::kdf(Secret const& _priv, h256 const& _hash)
return s;
}
string const& Nonce::seedFilePath(string const& _filePath)
{
static mutex x_seedFile;
static string s_seedFile;
Guard l(x_seedFile);
if (s_seedFile.empty())
s_seedFile = _filePath.empty() ? getDataDir() + "/seed" : _filePath;
return s_seedFile;
}
Secret Nonce::next()
{
Guard l(x_value);
if (!m_value)
{
bytesSec b = contentsSec(seedFilePath());
if (b.size() == 32)
b.ref().populate(m_value.writable().ref());
else
m_value = Secret::random();
m_value = Secret::random();
if (!m_value)
BOOST_THROW_EXCEPTION(InvalidState());
// prevent seed reuse if process terminates abnormally
// this might throw
writeFile(seedFilePath(), bytes());
}
m_value = sha3Secure(m_value.ref());
return sha3(~m_value);

6
libdevcrypto/Common.h

@ -203,14 +203,8 @@ public:
/// Returns the next nonce (might be read from a file).
static Secret get() { static Nonce s; return s.next(); }
/// @returns path of the seed file. FOR TESTS ONLY: optionally set path to @_filePath.
static std::string const& seedFilePath(std::string const& _filePath = std::string());
private:
Nonce() = default;
/// Destructor. IO operation may throw.
~Nonce() { if (m_value && next()) dev::writeFile(seedFilePath(), m_value.ref()); }
/// @returns the next nonce.
Secret next();

4
libp2p/Host.cpp

@ -396,7 +396,7 @@ void Host::runAcceptor()
clog(NetConnect) << "Listening on local port " << m_listenPort << " (public: " << m_tcpPublic << ")";
m_accepting = true;
auto socket = make_shared<RLPXSocket>(new bi::tcp::socket(m_ioService));
auto socket = make_shared<RLPXSocket>(m_ioService);
m_tcp4Acceptor.async_accept(socket->ref(), [=](boost::system::error_code ec)
{
m_accepting = false;
@ -552,7 +552,7 @@ void Host::connect(std::shared_ptr<Peer> const& _p)
bi::tcp::endpoint ep(_p->endpoint);
clog(NetConnect) << "Attempting connection to node" << _p->id << "@" << ep << "from" << id();
auto socket = make_shared<RLPXSocket>(new bi::tcp::socket(m_ioService));
auto socket = make_shared<RLPXSocket>(m_ioService);
socket->ref().async_connect(ep, [=](boost::system::error_code const& ec)
{
_p->m_lastAttempted = std::chrono::system_clock::now();

3
libp2p/RLPXSocket.h

@ -39,8 +39,7 @@ namespace p2p
class RLPXSocket: public std::enable_shared_from_this<RLPXSocket>
{
public:
/// Constructor. Dereferences and takes ownership of _socket.
RLPXSocket(bi::tcp::socket* _socket): m_socket(std::move(*_socket)) {}
RLPXSocket(ba::io_service& _ioService): m_socket(_ioService) {}
~RLPXSocket() { close(); }
bool isConnected() const { return m_socket.is_open(); }

5
test/TestUtils.cpp

@ -120,8 +120,3 @@ void ParallelClientBaseFixture::enumerateClients(std::function<void(Json::Value
});
}
MoveNonceToTempDir::MoveNonceToTempDir()
{
crypto::Nonce::seedFilePath(m_dir.path() + "/seed");
}

8
test/TestUtils.h

@ -79,13 +79,5 @@ struct JsonRpcFixture: public ClientBaseFixture
};
struct MoveNonceToTempDir
{
MoveNonceToTempDir();
~MoveNonceToTempDir() {}
private:
TransientDirectory m_dir;
};
}
}

2
test/libdevcrypto/SecretStore.cpp

@ -37,8 +37,6 @@ using namespace dev::test;
namespace js = json_spirit;
namespace fs = boost::filesystem;
BOOST_GLOBAL_FIXTURE( MoveNonceToTempDir )
BOOST_AUTO_TEST_SUITE(KeyStore)
BOOST_AUTO_TEST_CASE(basic_tests)

2
test/libdevcrypto/crypto.cpp

@ -40,8 +40,6 @@ using namespace dev::test;
using namespace dev::crypto;
using namespace CryptoPP;
BOOST_GLOBAL_FIXTURE( MoveNonceToTempDir )
BOOST_AUTO_TEST_SUITE(devcrypto)
static Secp256k1PP s_secp256k1;

Loading…
Cancel
Save