-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #236 from AntelopeIO/desubmod_fc
[3.2] desubmodule fc
- Loading branch information
Showing
258 changed files
with
39,931 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule fc
deleted from
6f9fc5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,155 @@ | ||
set( ECC_IMPL secp256k1 CACHE STRING "secp256k1 or openssl or mixed" ) | ||
|
||
add_subdirectory( secp256k1 ) | ||
|
||
set( WITH_PROCPS OFF CACHE BOOL "" FORCE) | ||
set( CURVE "ALT_BN128" CACHE STRING "" FORCE) | ||
set( USE_ASM OFF CACHE BOOL "" FORCE) | ||
set( IS_LIBFF_PARENT OFF CACHE BOOL "" FORCE) | ||
set( FF_INSTALL_COMPONENT "${FC_INSTALL_COMPONENT}") | ||
add_subdirectory( libraries/ff ) | ||
|
||
if( ECC_IMPL STREQUAL openssl ) | ||
set( ECC_REST src/crypto/elliptic_impl_pub.cpp ) | ||
else( ECC_IMPL STREQUAL openssl ) | ||
set( ECC_LIB secp256k1 ) | ||
if( ECC_IMPL STREQUAL mixed ) | ||
set( ECC_REST src/crypto/elliptic_impl_priv.cpp src/crypto/elliptic_impl_pub.cpp ) | ||
else( ECC_IMPL STREQUAL mixed ) | ||
set( ECC_REST src/crypto/elliptic_impl_priv.cpp ) | ||
endif( ECC_IMPL STREQUAL mixed ) | ||
endif( ECC_IMPL STREQUAL openssl ) | ||
|
||
set(CMAKE_THREAD_PREFER_PTHREAD TRUE) | ||
set(THREADS_PREFER_PTHREAD_FLAG TRUE) | ||
find_package(Threads) | ||
|
||
find_package(OpenSSL REQUIRED) | ||
|
||
set( fc_sources | ||
src/uint128.cpp | ||
src/real128.cpp | ||
src/variant.cpp | ||
src/exception.cpp | ||
src/variant_object.cpp | ||
src/string.cpp | ||
src/time.cpp | ||
src/mock_time.cpp | ||
src/utf8.cpp | ||
src/io/datastream.cpp | ||
src/io/json.cpp | ||
src/io/varint.cpp | ||
src/io/fstream.cpp | ||
src/io/console.cpp | ||
src/filesystem.cpp | ||
src/interprocess/file_mapping.cpp | ||
src/interprocess/mmap_struct.cpp | ||
src/log/log_message.cpp | ||
src/log/logger.cpp | ||
src/log/appender.cpp | ||
src/log/console_appender.cpp | ||
src/log/dmlog_appender.cpp | ||
src/log/logger_config.cpp | ||
src/crypto/_digest_common.cpp | ||
src/crypto/aes.cpp | ||
src/crypto/crc.cpp | ||
src/crypto/city.cpp | ||
# src/crypto/base32.cpp | ||
src/crypto/base36.cpp | ||
src/crypto/base58.cpp | ||
src/crypto/base64.cpp | ||
src/crypto/bigint.cpp | ||
src/crypto/hex.cpp | ||
src/crypto/sha1.cpp | ||
src/crypto/sha3.cpp | ||
src/crypto/ripemd160.cpp | ||
src/crypto/sha256.cpp | ||
src/crypto/sha224.cpp | ||
src/crypto/sha512.cpp | ||
src/crypto/dh.cpp | ||
src/crypto/blowfish.cpp | ||
src/crypto/elliptic_common.cpp | ||
${ECC_REST} | ||
src/crypto/elliptic_${ECC_IMPL}.cpp | ||
src/crypto/elliptic_r1.cpp | ||
src/crypto/elliptic_webauthn.cpp | ||
src/crypto/rand.cpp | ||
src/crypto/public_key.cpp | ||
src/crypto/private_key.cpp | ||
src/crypto/signature.cpp | ||
src/crypto/alt_bn128.cpp | ||
src/crypto/modular_arithmetic.cpp | ||
src/crypto/blake2.cpp | ||
src/crypto/k1_recover.cpp | ||
src/network/ip.cpp | ||
src/network/platform_root_ca.cpp | ||
src/network/resolve.cpp | ||
src/network/udp_socket.cpp | ||
src/network/url.cpp | ||
src/network/http/http_client.cpp | ||
src/compress/smaz.cpp | ||
src/compress/zlib.cpp | ||
src/log/gelf_appender.cpp | ||
src/log/zipkin.cpp | ||
) | ||
|
||
file( GLOB_RECURSE fc_headers ${CMAKE_CURRENT_SOURCE_DIR} *.hpp *.h ) | ||
|
||
add_library(fc ${fc_sources} ${fc_headers}) | ||
|
||
function(detect_thread_name) | ||
include(CheckSymbolExists) | ||
list(APPEND CMAKE_REQUIRED_DEFINITIONS -D_GNU_SOURCE) | ||
list(APPEND CMAKE_REQUIRED_LIBRARIES "-pthread") | ||
check_symbol_exists(pthread_setname_np pthread.h HAVE_PTHREAD_SETNAME_NP) | ||
if(HAVE_PTHREAD_SETNAME_NP) | ||
set_source_files_properties(src/log/logger_config.cpp PROPERTIES COMPILE_DEFINITIONS FC_USE_PTHREAD_NAME_NP) | ||
endif() | ||
endfunction() | ||
if(CMAKE_SYSTEM_NAME MATCHES "Linux") | ||
detect_thread_name() | ||
endif() | ||
|
||
find_package(Boost 1.66 REQUIRED COMPONENTS | ||
date_time | ||
filesystem | ||
chrono | ||
unit_test_framework | ||
iostreams) | ||
|
||
# fc picks up a dependency on zlib via Boost::iostreams, however in some versions of cmake/boost (depending on if CMake config | ||
# files are used) the Boost::iostreams target does not have a dependency on zlib itself so add it explicitly | ||
find_package(ZLIB REQUIRED) | ||
|
||
target_include_directories(fc PUBLIC include) | ||
|
||
# try and make this very clear that this json parser is intended only for webauthn parsing.. | ||
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.11.0) | ||
set_source_files_properties(src/crypto/elliptic_webauthn.cpp PROPERTIES INCLUDE_DIRECTORIES "${CMAKE_CURRENT_SOURCE_DIR}/include/fc/crypto/webauthn_json/include") | ||
else() | ||
set_source_files_properties(src/crypto/elliptic_webauthn.cpp PROPERTIES COMPILE_FLAGS "-I${CMAKE_CURRENT_SOURCE_DIR}/include/fc/crypto/webauthn_json/include") | ||
endif() | ||
|
||
if(WIN32) | ||
target_link_libraries( fc PUBLIC ws2_32 mswsock userenv ) | ||
endif() | ||
|
||
if(APPLE) | ||
find_library(security_framework Security) | ||
find_library(corefoundation_framework CoreFoundation) | ||
endif() | ||
target_link_libraries( fc PUBLIC ff | ||
Boost::date_time Boost::filesystem Boost::chrono Boost::iostreams Threads::Threads | ||
OpenSSL::Crypto OpenSSL::SSL ZLIB::ZLIB ${PLATFORM_SPECIFIC_LIBS} ${CMAKE_DL_LIBS} ${ECC_LIB} ${security_framework} ${corefoundation_framework} ) | ||
|
||
# Critically, this ensures that OpenSSL 1.1 & 3.0 both have a variant of BN_zero() with void return value. But it also allows access | ||
# to some obsoleted AES functions in 3.0 too, since 3.0's API_COMPAT is effectively 3.0 by default | ||
target_compile_definitions(fc PUBLIC "OPENSSL_API_COMPAT=0x10100000L" "OPENSSL_NO_DEPRECATED") | ||
|
||
add_subdirectory( test ) | ||
|
||
install(TARGETS fc | ||
LIBRARY DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR} COMPONENT dev EXCLUDE_FROM_ALL | ||
ARCHIVE DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR} COMPONENT dev EXCLUDE_FROM_ALL) | ||
install(DIRECTORY include/fc DESTINATION ${CMAKE_INSTALL_FULL_INCLUDEDIR} COMPONENT dev EXCLUDE_FROM_ALL) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
#pragma once | ||
#include <fc/api.hpp> | ||
#include <fc/thread/thread.hpp> | ||
|
||
namespace fc { | ||
|
||
namespace detail { | ||
struct actor_member { | ||
#if 1 // BOOST_NO_VARIADIC_TEMPLATES | ||
#define RPC_MEMBER_FUNCTOR(z,n,IS_CONST) \ | ||
template<typename R, typename C, typename P BOOST_PP_ENUM_TRAILING_PARAMS( n, typename A)> \ | ||
static std::function<fc::future<R>( BOOST_PP_ENUM_PARAMS(n,A) ) > \ | ||
functor( P p, R (C::*mem_func)(BOOST_PP_ENUM_PARAMS(n,A)) IS_CONST, fc::thread* c = 0) { \ | ||
return [=](BOOST_PP_ENUM_BINARY_PARAMS(n,A,a))->fc::future<R>{ \ | ||
return c->async( [=](){ return (p->*mem_func)(BOOST_PP_ENUM_PARAMS(n,a)); } ); }; \ | ||
} | ||
BOOST_PP_REPEAT( 8, RPC_MEMBER_FUNCTOR, const ) | ||
BOOST_PP_REPEAT( 8, RPC_MEMBER_FUNCTOR, BOOST_PP_EMPTY() ) | ||
#undef RPC_MEMBER_FUNCTOR | ||
|
||
#else // g++ has a bug that prevents lambdas and varidic templates from working together (G++ Bug 41933) | ||
template<typename R, typename C, typename P, typename... Args> | ||
static std::function<fc::future<R>(Args...)> functor( P&& p, R (C::*mem_func)(Args...), fc::thread* c ) { | ||
return [=](Args... args)->fc::future<R>{ c->async( [=]()->R { return p->*mem_func( fc::forward<Args>(args)... ); } ) }; | ||
} | ||
template<typename R, typename C, typename P, typename... Args> | ||
static std::function<fc::future<R>(Args...)> functor( P&& p, R (C::*mem_func)(Args...)const, fc::thread* c ){ | ||
return [=](Args... args)->fc::future<R>{ c->async( [=]()->R { return p->*mem_func( fc::forward<Args>(args)... ); } ) }; | ||
} | ||
#endif | ||
}; | ||
|
||
template<typename ThisPtr> | ||
struct actor_vtable_visitor { | ||
template<typename U> | ||
actor_vtable_visitor( fc::thread* t, U&& u ):_thread(t),_this( fc::forward<U>(u) ){} | ||
|
||
template<typename Function, typename MemberPtr> | ||
void operator()( const char* name, Function& memb, MemberPtr m )const { | ||
memb = actor_member::functor( _this, m, _thread ); | ||
} | ||
fc::thread* _thread; | ||
ThisPtr _this; | ||
}; | ||
} | ||
|
||
/** | ||
* Posts all method calls to another thread and | ||
* returns a future. | ||
*/ | ||
template<typename Interface> | ||
class actor : public api<Interface, detail::actor_member> { | ||
public: | ||
actor(){} | ||
|
||
template<typename InterfaceType> | ||
actor( InterfaceType* p, fc::thread* t = &fc::thread::current() ) | ||
{ | ||
this->_vtable.reset(new detail::vtable<Interface,detail::actor_member>() ); | ||
this->_vtable->template visit<InterfaceType>( detail::actor_vtable_visitor<InterfaceType*>(t, p) ); | ||
} | ||
}; | ||
|
||
} // namespace fc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#pragma once | ||
namespace fc { | ||
|
||
template<unsigned int S, typename T=double> | ||
struct aligned { | ||
union { | ||
T _align; | ||
char _data[S]; | ||
} _store; | ||
operator char*() { return _store._data; } | ||
operator const char*()const { return _store._data; } | ||
}; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#pragma once | ||
#include <boost/any.hpp> | ||
|
||
namespace fc { | ||
// TODO: define this without using boost | ||
typedef boost::any any; | ||
} |
Oops, something went wrong.