Skip to content

Commit

Permalink
Merge pull request #137 from pmconrad/1584_more_simplification
Browse files Browse the repository at this point in the history
More simplifications
  • Loading branch information
pmconrad authored Jun 19, 2019
2 parents a87a99b + deb9d4f commit 6ed9431
Show file tree
Hide file tree
Showing 78 changed files with 769 additions and 2,006 deletions.
13 changes: 7 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@ CMAKE_MINIMUM_REQUIRED( VERSION 3.1 )

set( CMAKE_CXX_STANDARD 14 )
SET( CMAKE_CXX_STANDARD_REQUIRED ON )
set( CMAKE_CXX_EXTENSIONS OFF )

if( "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" )
set( CMAKE_CXX_EXTENSIONS ON ) # for __int128 support
else( GNU )
set( CMAKE_CXX_EXTENSIONS OFF )
endif( GNU )

MESSAGE(STATUS "Configuring project fc located in: ${CMAKE_CURRENT_SOURCE_DIR}")
SET( CMAKE_AUTOMOC OFF )
Expand Down Expand Up @@ -194,8 +199,7 @@ set( CMAKE_FIND_LIBRARY_SUFFIXES ${ORIGINAL_LIB_SUFFIXES} )
option( UNITY_BUILD OFF )

set( fc_sources
src/uint128.cpp
src/real128.cpp
src/popcount.cpp
src/variant.cpp
src/exception.cpp
src/variant_object.cpp
Expand All @@ -211,7 +215,6 @@ set( fc_sources
src/thread/non_preemptable_scope_check.cpp
src/asio.cpp
src/string.cpp
src/shared_ptr.cpp
src/stacktrace.cpp
src/time.cpp
src/utf8.cpp
Expand All @@ -226,7 +229,6 @@ set( fc_sources
src/interprocess/signals.cpp
src/interprocess/file_mapping.cpp
src/rpc/cli.cpp
src/rpc/http_api.cpp
src/rpc/state.cpp
src/rpc/websocket_api.cpp
src/log/log_message.cpp
Expand Down Expand Up @@ -258,7 +260,6 @@ set( fc_sources
src/network/tcp_socket.cpp
src/network/udp_socket.cpp
src/network/http/http_connection.cpp
src/network/http/http_server.cpp
src/network/http/websocket.cpp
src/network/ip.cpp
src/network/rate_limiting.cpp
Expand Down
145 changes: 0 additions & 145 deletions include/fc/array.hpp

This file was deleted.

18 changes: 9 additions & 9 deletions include/fc/asio.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,15 +122,15 @@ namespace asio {
template<typename AsyncReadStream, typename MutableBufferSequence>
future<size_t> read_some(AsyncReadStream& s, const MutableBufferSequence& buf)
{
promise<size_t>::ptr completion_promise(new promise<size_t>("fc::asio::async_read_some"));
promise<size_t>::ptr completion_promise = promise<size_t>::create("fc::asio::async_read_some");
s.async_read_some(buf, detail::read_write_handler(completion_promise));
return completion_promise;//->wait();
}

template<typename AsyncReadStream>
future<size_t> read_some(AsyncReadStream& s, char* buffer, size_t length, size_t offset = 0)
{
promise<size_t>::ptr completion_promise(new promise<size_t>("fc::asio::async_read_some"));
promise<size_t>::ptr completion_promise = promise<size_t>::create("fc::asio::async_read_some");
s.async_read_some(boost::asio::buffer(buffer + offset, length),
detail::read_write_handler(completion_promise));
return completion_promise;//->wait();
Expand All @@ -139,7 +139,7 @@ namespace asio {
template<typename AsyncReadStream>
future<size_t> read_some(AsyncReadStream& s, const std::shared_ptr<char>& buffer, size_t length, size_t offset)
{
promise<size_t>::ptr completion_promise(new promise<size_t>("fc::asio::async_read_some"));
promise<size_t>::ptr completion_promise = promise<size_t>::create("fc::asio::async_read_some");
s.async_read_some(boost::asio::buffer(buffer.get() + offset, length),
detail::read_write_handler_with_buffer(completion_promise, buffer));
return completion_promise;//->wait();
Expand Down Expand Up @@ -179,7 +179,7 @@ namespace asio {
*/
template<typename AsyncWriteStream, typename ConstBufferSequence>
size_t write( AsyncWriteStream& s, const ConstBufferSequence& buf ) {
promise<size_t>::ptr p(new promise<size_t>("fc::asio::write"));
promise<size_t>::ptr p = promise<size_t>::create("fc::asio::write");
boost::asio::async_write(s, buf, detail::read_write_handler(p));
return p->wait();
}
Expand All @@ -191,23 +191,23 @@ namespace asio {
*/
template<typename AsyncWriteStream, typename ConstBufferSequence>
future<size_t> write_some( AsyncWriteStream& s, const ConstBufferSequence& buf ) {
promise<size_t>::ptr p(new promise<size_t>("fc::asio::write_some"));
promise<size_t>::ptr p = promise<size_t>::create("fc::asio::write_some");
s.async_write_some( buf, detail::read_write_handler(p));
return p; //->wait();
}

template<typename AsyncWriteStream>
future<size_t> write_some( AsyncWriteStream& s, const char* buffer,
size_t length, size_t offset = 0) {
promise<size_t>::ptr p(new promise<size_t>("fc::asio::write_some"));
promise<size_t>::ptr p = promise<size_t>::create("fc::asio::write_some");
s.async_write_some( boost::asio::buffer(buffer + offset, length), detail::read_write_handler(p));
return p; //->wait();
}

template<typename AsyncWriteStream>
future<size_t> write_some( AsyncWriteStream& s, const std::shared_ptr<const char>& buffer,
size_t length, size_t offset ) {
promise<size_t>::ptr p(new promise<size_t>("fc::asio::write_some"));
promise<size_t>::ptr p = promise<size_t>::create("fc::asio::write_some");
s.async_write_some( boost::asio::buffer(buffer.get() + offset, length), detail::read_write_handler_with_buffer(p, buffer));
return p; //->wait();
}
Expand Down Expand Up @@ -250,7 +250,7 @@ namespace asio {
template<typename SocketType, typename AcceptorType>
void accept( AcceptorType& acc, SocketType& sock ) {
//promise<boost::system::error_code>::ptr p( new promise<boost::system::error_code>("fc::asio::tcp::accept") );
promise<void>::ptr p( new promise<void>("fc::asio::tcp::accept") );
promise<void>::ptr p = promise<void>::create("fc::asio::tcp::accept");
acc.async_accept( sock, boost::bind( fc::asio::detail::error_handler, p, _1 ) );
p->wait();
//if( ec ) BOOST_THROW_EXCEPTION( boost::system::system_error(ec) );
Expand All @@ -262,7 +262,7 @@ namespace asio {
*/
template<typename AsyncSocket, typename EndpointType>
void connect( AsyncSocket& sock, const EndpointType& ep ) {
promise<void>::ptr p(new promise<void>("fc::asio::tcp::connect"));
promise<void>::ptr p = promise<void>::create("fc::asio::tcp::connect");
sock.async_connect( ep, boost::bind( fc::asio::detail::error_handler, p, _1 ) );
p->wait();
//if( ec ) BOOST_THROW_EXCEPTION( boost::system::system_error(ec) );
Expand Down
2 changes: 1 addition & 1 deletion include/fc/bloom_filter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
namespace fc {


static const std::size_t bits_per_char = 0x08; // 8 bits in 1 char(unsigned)
static constexpr std::size_t bits_per_char = 0x08; // 8 bits in 1 char(unsigned)
static const unsigned char bit_mask[bits_per_char] = {
0x01, //00000001
0x02, //00000010
Expand Down
11 changes: 5 additions & 6 deletions include/fc/crypto/aes.hpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
#pragma once
#include <fc/io/raw_fwd.hpp>

#include <fc/crypto/sha512.hpp>
#include <fc/crypto/sha256.hpp>
#include <fc/uint128.hpp>
#include <fc/fwd.hpp>
#include <fc/uint128.hpp>

#include <vector>

namespace fc {
Expand All @@ -15,9 +16,8 @@ namespace fc {
aes_encoder();
~aes_encoder();

void init( const fc::sha256& key, const fc::uint128& init_value );
void init( const fc::sha256& key, const uint128_t& init_value );
uint32_t encode( const char* plaintxt, uint32_t len, char* ciphertxt );
// uint32_t final_encode( char* ciphertxt );

private:
struct impl;
Expand All @@ -29,9 +29,8 @@ namespace fc {
aes_decoder();
~aes_decoder();

void init( const fc::sha256& key, const fc::uint128& init_value );
void init( const fc::sha256& key, const uint128_t& init_value );
uint32_t decode( const char* ciphertxt, uint32_t len, char* plaintext );
// uint32_t final_decode( char* plaintext );

private:
struct impl;
Expand Down
19 changes: 4 additions & 15 deletions include/fc/crypto/city.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,36 +41,25 @@
// doesn't hold for any hash functions in this file.
#pragma once

#include <fc/uint128.hpp>

#include <stdlib.h> // for size_t.
#include <stdint.h>
#include <utility>

namespace fc {

template<typename T, size_t N>
class array;
class uint128;

// Hash function for a byte array.
uint64_t city_hash64(const char *buf, size_t len);

uint32_t city_hash32(const char *buf, size_t len);

#if SIZE_MAX > UINT32_MAX
inline size_t city_hash_size_t(const char *buf, size_t len) { return city_hash64(buf, len); }
#else
uint32_t city_hash32(const char *buf, size_t len);
inline size_t city_hash_size_t(const char *buf, size_t len) { return city_hash32(buf, len); }
#endif

// Hash function for a byte array.
uint128 city_hash128(const char *s, size_t len);

// Hash function for a byte array.
uint64_t city_hash_crc_64(const char *buf, size_t len);

// Hash function for a byte array.
uint128 city_hash_crc_128(const char *s, size_t len);
array<uint64_t,4> city_hash_crc_256(const char *s, size_t len);

uint128_t city_hash_crc_128(const char *s, size_t len);

} // namespace fc
21 changes: 11 additions & 10 deletions include/fc/crypto/elliptic.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
#include <fc/crypto/sha256.hpp>
#include <fc/crypto/sha512.hpp>
#include <fc/fwd.hpp>
#include <fc/array.hpp>
#include <fc/io/raw_fwd.hpp>

#include <array>

namespace fc {

namespace ecc {
Expand All @@ -16,15 +17,15 @@ namespace fc {
class private_key_impl;
}

typedef fc::sha256 blind_factor_type;
typedef fc::array<char,33> commitment_type;
typedef fc::array<char,33> public_key_data;
typedef fc::sha256 private_key_secret;
typedef fc::array<char,65> public_key_point_data; ///< the full non-compressed version of the ECC point
typedef fc::array<char,72> signature;
typedef fc::array<unsigned char,65> compact_signature;
typedef std::vector<char> range_proof_type;
typedef fc::array<char,78> extended_key_data;
typedef fc::sha256 blind_factor_type;
typedef std::array<unsigned char,33> commitment_type;
typedef std::array<unsigned char,33> public_key_data;
typedef fc::sha256 private_key_secret;
typedef std::array<unsigned char,65> public_key_point_data; ///< the full non-compressed version of the ECC point
typedef std::array<unsigned char,72> signature;
typedef std::array<unsigned char,65> compact_signature;
typedef std::vector<char> range_proof_type;
typedef std::array<unsigned char,78> extended_key_data;

/**
* @class public_key
Expand Down
Loading

0 comments on commit 6ed9431

Please sign in to comment.