Merge pull request #3 from PBSA/master

Ubuntu 18.04 Upgrade
This commit is contained in:
pbattu123 2019-09-03 13:20:49 -03:00 committed by GitHub
commit 961452f06f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
636 changed files with 47012 additions and 25492 deletions

3
.gitignore vendored Normal file → Executable file
View file

@ -48,7 +48,4 @@ fc_automoc.cpp
git_revision.cpp
GitSHA3.cpp
ntp_test
task_cancel_test
udt_client
udt_server

5
.gitmodules vendored Normal file → Executable file
View file

@ -1,6 +1,3 @@
[submodule "vendor/secp256k1-zkp"]
path = vendor/secp256k1-zkp
url = https://github.com/cryptonomex/secp256k1-zkp.git
[submodule "vendor/websocketpp"]
path = vendor/websocketpp
url = https://github.com/zaphoyd/websocketpp.git
url = https://github.com/bitshares/secp256k1-zkp.git

189
CMakeLists.txt Normal file → Executable file
View file

@ -40,7 +40,7 @@ endif()
SET (ORIGINAL_LIB_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES})
SET(BOOST_COMPONENTS)
LIST(APPEND BOOST_COMPONENTS thread date_time system filesystem program_options signals serialization chrono unit_test_framework context locale iostreams)
LIST(APPEND BOOST_COMPONENTS thread date_time filesystem system program_options signals serialization chrono unit_test_framework context locale iostreams)
SET( Boost_USE_STATIC_LIBS ON CACHE STRING "ON or OFF" )
IF( ECC_IMPL STREQUAL openssl )
@ -55,7 +55,7 @@ ELSE( ECC_IMPL STREQUAL openssl )
ENDIF( ECC_IMPL STREQUAL openssl )
# Configure secp256k1-zkp
if ( WIN32 )
if ( MSVC )
# autoconf won't work here, hard code the defines
set( SECP256K1_DIR "${CMAKE_CURRENT_SOURCE_DIR}/vendor/secp256k1-zkp" )
@ -71,8 +71,18 @@ if ( WIN32 )
USE_SCALAR_8X32
USE_SCALAR_INV_BUILTIN )
set_target_properties( secp256k1 PROPERTIES COMPILE_DEFINITIONS "${SECP256K1_BUILD_DEFINES}" LINKER_LANGUAGE C )
else ( WIN32 )
else ( MSVC )
include(ExternalProject)
if ( MINGW )
ExternalProject_Add( project_secp256k1
PREFIX ${CMAKE_CURRENT_BINARY_DIR}/vendor/secp256k1-zkp
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/vendor/secp256k1-zkp
CONFIGURE_COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/vendor/secp256k1-zkp/configure --prefix=${CMAKE_CURRENT_BINARY_DIR}/vendor/secp256k1-zkp --with-bignum=no --host=x86_64-w64-mingw32
BUILD_COMMAND make
INSTALL_COMMAND true
BUILD_BYPRODUCTS ${CMAKE_CURRENT_BINARY_DIR}/vendor/secp256k1-zkp/src/project_secp256k1-build/.libs/libsecp256k1.a
)
else ( MINGW )
ExternalProject_Add( project_secp256k1
PREFIX ${CMAKE_CURRENT_BINARY_DIR}/vendor/secp256k1-zkp
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/vendor/secp256k1-zkp
@ -81,6 +91,7 @@ else ( WIN32 )
INSTALL_COMMAND true
BUILD_BYPRODUCTS ${CMAKE_CURRENT_BINARY_DIR}/vendor/secp256k1-zkp/src/project_secp256k1-build/.libs/libsecp256k1.a
)
endif ( MINGW )
ExternalProject_Add_Step(project_secp256k1 autogen
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/vendor/secp256k1-zkp
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/vendor/secp256k1-zkp/autogen.sh
@ -93,13 +104,14 @@ else ( WIN32 )
set_property(TARGET secp256k1 PROPERTY IMPORTED_LOCATION ${binary_dir}/.libs/libsecp256k1${CMAKE_STATIC_LIBRARY_SUFFIX})
set_property(TARGET secp256k1 PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_CURRENT_SOURCE_DIR}/vendor/secp256k1-zkp/include)
add_dependencies(secp256k1 project_secp256k1)
endif ( WIN32 )
install( FILES ${binary_dir}/.libs/libsecp256k1${CMAKE_STATIC_LIBRARY_SUFFIX} DESTINATION lib/cryptonomex )
endif ( MSVC )
# End configure secp256k1-zkp
IF( WIN32 )
MESSAGE(STATUS "Configuring fc to build on Win32")
set( RPCRT4 Rpcrt4 )
set( RPCRT4 rpcrt4 )
#boost
SET(BOOST_ROOT $ENV{BOOST_ROOT})
@ -116,7 +128,7 @@ IF( WIN32 )
SET(Boost_LIBRARIES ${BOOST_LIBRARIES_TEMP} ${Boost_LIBRARIES})
ENDIF()
set( PLATFORM_SPECIFIC_LIBS WS2_32.lib Userenv.lib)
set( PLATFORM_SPECIFIC_LIBS wsock32.lib ws2_32.lib userenv.lib)
# iphlpapi.lib
ELSE(WIN32)
@ -178,14 +190,15 @@ set( fc_sources
src/io/varint.cpp
src/io/console.cpp
src/filesystem.cpp
src/interprocess/process.cpp
src/interprocess/signals.cpp
src/interprocess/file_mapping.cpp
src/interprocess/mmap_struct.cpp
src/interprocess/file_mutex.cpp
src/rpc/cli.cpp
src/rpc/http_api.cpp
src/rpc/json_connection.cpp
src/rpc/state.cpp
src/rpc/bstate.cpp
src/rpc/websocket_api.cpp
src/log/log_message.cpp
src/log/logger.cpp
@ -199,7 +212,6 @@ set( fc_sources
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
@ -219,20 +231,16 @@ set( fc_sources
src/crypto/rand.cpp
src/network/tcp_socket.cpp
src/network/udp_socket.cpp
src/network/udt_socket.cpp
src/network/http/http_connection.cpp
src/network/http/http_server.cpp
src/network/http/websocket.cpp
src/network/ntp.cpp
src/network/ip.cpp
src/network/ntp.cpp
src/network/rate_limiting.cpp
src/network/resolve.cpp
src/network/url.cpp
src/network/gntp.cpp
src/compress/smaz.cpp
src/compress/zlib.cpp
vendor/cyoencode-1.0.2/src/CyoDecode.c
vendor/cyoencode-1.0.2/src/CyoEncode.c
)
file( GLOB_RECURSE fc_headers ${CMAKE_CURRENT_SOURCE_DIR} *.hpp *.h )
@ -245,10 +253,10 @@ configure_file("${CMAKE_CURRENT_SOURCE_DIR}/src/git_revision.cpp.in" "${CMAKE_CU
list(APPEND sources "${CMAKE_CURRENT_BINARY_DIR}/git_revision.cpp")
list(APPEND sources ${fc_headers})
add_subdirectory( vendor/websocketpp )
add_subdirectory( vendor/udt4 )
add_subdirectory( vendor/websocketpp EXCLUDE_FROM_ALL )
setup_library( fc SOURCES ${sources} LIBRARY_TYPE STATIC DONT_INSTALL_LIBRARY )
setup_library( fc SOURCES ${sources} LIBRARY_TYPE STATIC )
install( DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/include/" DESTINATION include )
# begin readline stuff
find_package(Curses)
@ -269,6 +277,10 @@ if(WIN32)
endif(WIN32)
# end readline stuff
if( NOT CPP_STANDARD )
set( CPP_STANDARD, "-std=c++11" )
endif()
IF(WIN32)
target_compile_definitions(fc PUBLIC WIN32 NOMINMAX _WIN32_WINNT=0x0501 _CRT_SECURE_NO_WARNINGS
_SCL_SERCURE_NO_WARNINGS
@ -279,47 +291,86 @@ IF(WIN32)
# autodetecting code to do the right thing.
_WEBSOCKETPP_CPP11_CHRONO_
)
if( MSVC )
# Activate C++ exception handling, assume extern C calls don't throw
# Add /U options to be sure settings specific to dynamic boost link are ineffective
target_compile_options(fc PUBLIC /EHsc /UBOOST_ALL_DYN_LINK /UBOOST_LINKING_PYTHON /UBOOST_DEBUG_PYTHON)
elseif( MINGW )
# Put MinGW specific compiler settings here
endif()
ELSE()
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99 -Wall")
IF(APPLE)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -stdlib=libc++ -Wall")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CPP_STANDARD} -stdlib=libc++ -Wall")
ELSE()
if( NOT "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" )
target_compile_options(fc PUBLIC -std=c++11 -Wall -fnon-call-exceptions)
target_compile_options(fc PUBLIC ${CPP_STANDARD} -Wall -fnon-call-exceptions)
endif()
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CPP_STANDARD} -Wall -fnon-call-exceptions")
if( "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" )
if( CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL 4.0.0 OR CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 4.0.0 )
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-invalid-partial-specialization" )
endif()
endif()
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -fnon-call-exceptions")
ENDIF()
ENDIF()
IF(APPLE)
# As of 10.10 yosemite, the OpenSSL static libraries shipped with os x have a dependency
# on zlib, so any time you link in openssl you also need to link zlib. . We really want to detect whether openssl was configured with the --no-zlib
# option or not when it was built, but that's difficult to do in practice, so we
# just always try to link it in on mac.
find_package( ZLIB REQUIRED )
ELSE(APPLE)
find_package( ZLIB )
ENDIF(APPLE)
if( ZLIB_FOUND )
MESSAGE( STATUS "zlib found" )
add_definitions( -DHAS_ZLIB )
else()
MESSAGE( STATUS "zlib not found" )
set( ZLIB_LIBRARIES "" )
endif( ZLIB_FOUND )
# This will become unnecessary once we update to websocketpp which fixes upstream issue #395
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DWEBSOCKETPP_STRICT_MASKING")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DBOOST_ASIO_HAS_STD_CHRONO")
OPTION( LOG_LONG_API "Log long API calls over websocket (ON OR OFF)" ON )
MESSAGE( STATUS "LOG_LONG_API: ${LOG_LONG_API}" )
if( LOG_LONG_API )
SET( LOG_LONG_API_MAX_MS 1000 CACHE STRING "Max API execution time in ms" )
SET( LOG_LONG_API_WARN_MS 750 CACHE STRING "API execution time in ms at which to warn" )
MESSAGE( STATUS " " )
MESSAGE( STATUS " LOGGING LONG API CALLS" )
MESSAGE( STATUS " MAX MS: ${LOG_LONG_API_MAX_MS}" )
MESSAGE( STATUS " WARN MS: ${LOG_LONG_API_WARN_MS}" )
MESSAGE( STATUS " " )
SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DLOG_LONG_API -DLOG_LONG_API_MAX_MS=${LOG_LONG_API_MAX_MS} -DLOG_LONG_API_WARN_MS=${LOG_LONG_API_WARN_MS}" )
SET( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DLOG_LONG_API -DLOG_LONG_API_MAX_MS=${LOG_LONG_API_MAX_MS} -DLOG_LONG_API_WARN_MS=${LOG_LONG_API_WARN_MS}" )
endif()
target_include_directories(fc
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include
${Boost_INCLUDE_DIR}
${OPENSSL_INCLUDE_DIR}
"vendor/diff-match-patch-cpp-stl"
${CMAKE_CURRENT_SOURCE_DIR}/vendor/websocketpp
"${readline_includes}"
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/vendor/boost_1.51/include
${CMAKE_CURRENT_SOURCE_DIR}/vendor/cyoencode-1.0.2/src
${CMAKE_CURRENT_SOURCE_DIR}/vendor/udt4/src
${CMAKE_CURRENT_SOURCE_DIR}/vendor/websocketpp
${CMAKE_CURRENT_SOURCE_DIR}/vendor/secp256k1-zkp
${ZLIB_INCLUDE_DIRS}
)
#target_link_libraries( fc PUBLIC udt ${Boost_LIBRARIES} ${OPENSSL_LIBRARIES} ${ZLIB_LIBRARIES} ${PLATFORM_SPECIFIC_LIBS} ${RPCRT4} ${CMAKE_DL_LIBS} ${rt_library} ${ECC_LIB} )
#target_link_libraries( fc PUBLIC ${Boost_LIBRARIES} ${OPENSSL_LIBRARIES} ${ZLIB_LIBRARIES} ${BZIP2_LIBRARIES} ${PLATFORM_SPECIFIC_LIBS} ${RPCRT4} ${CMAKE_DL_LIBS} ${rt_library} ${ECC_LIB} )
IF(NOT WIN32)
set(LINK_USR_LOCAL_LIB -L/usr/local/lib)
ENDIF()
target_link_libraries( fc PUBLIC ${LINK_USR_LOCAL_LIB} udt ${Boost_LIBRARIES} ${OPENSSL_LIBRARIES} ${ZLIB_LIBRARIES} ${PLATFORM_SPECIFIC_LIBS} ${RPCRT4} ${CMAKE_DL_LIBS} ${rt_library} ${readline_libraries} ${ECC_LIB} )
target_link_libraries( fc PUBLIC ${LINK_USR_LOCAL_LIB} ${Boost_LIBRARIES} ${OPENSSL_LIBRARIES} ${ZLIB_LIBRARIES} ${PLATFORM_SPECIFIC_LIBS} ${RPCRT4} ${CMAKE_DL_LIBS} ${rt_library} ${readline_libraries} ${ECC_LIB} )
if(MSVC)
set_source_files_properties( src/network/http/websocket.cpp PROPERTIES COMPILE_FLAGS "/bigobj" )
@ -327,77 +378,16 @@ endif(MSVC)
IF(NOT Boost_UNIT_TEST_FRAMEWORK_LIBRARY MATCHES "\\.(a|lib)$")
IF(WIN32)
IF(MSVC)
add_definitions(/DBOOST_TEST_DYN_LINK)
ELSE(WIN32)
ELSE(MSVC)
add_definitions(-DBOOST_TEST_DYN_LINK)
ENDIF(WIN32)
ENDIF(MSVC)
ENDIF()
add_executable( api tests/api.cpp )
target_link_libraries( api fc )
if( ECC_IMPL STREQUAL secp256k1 )
add_executable( blind tests/all_tests.cpp tests/crypto/blind.cpp )
target_link_libraries( blind fc )
endif()
include_directories( vendor/websocketpp )
add_executable( ntp_test tests/all_tests.cpp tests/network/ntp_test.cpp )
target_link_libraries( ntp_test fc )
add_executable( task_cancel_test tests/all_tests.cpp tests/thread/task_cancel.cpp )
target_link_libraries( task_cancel_test fc )
add_executable( bloom_test tests/all_tests.cpp tests/bloom_test.cpp )
target_link_libraries( bloom_test fc )
add_executable( real128_test tests/all_tests.cpp tests/real128_test.cpp )
target_link_libraries( real128_test fc )
add_executable( hmac_test tests/hmac_test.cpp )
target_link_libraries( hmac_test fc )
add_executable( blinding_test tests/blinding_test.cpp )
target_link_libraries( blinding_test fc )
add_executable( udt_server tests/udts.cpp )
target_link_libraries( udt_server fc udt )
add_executable( udt_client tests/udtc.cpp )
target_link_libraries( udt_client fc udt )
add_executable( ecc_test tests/crypto/ecc_test.cpp )
target_link_libraries( ecc_test fc )
#add_executable( test_aes tests/aes_test.cpp )
#target_link_libraries( test_aes fc ${rt_library} ${pthread_library} )
#add_executable( test_sleep tests/sleep.cpp )
#target_link_libraries( test_sleep fc )
#add_executable( test_rate_limiting tests/rate_limiting.cpp )
#target_link_libraries( test_rate_limiting fc )
add_executable( all_tests tests/all_tests.cpp
tests/compress/compress.cpp
tests/crypto/aes_test.cpp
tests/crypto/base_n_tests.cpp
tests/crypto/bigint_test.cpp
tests/crypto/blind.cpp
tests/crypto/blowfish_test.cpp
tests/crypto/dh_test.cpp
tests/crypto/rand_test.cpp
tests/crypto/sha_tests.cpp
tests/network/ntp_test.cpp
tests/network/http/websocket_test.cpp
tests/thread/task_cancel.cpp
tests/bloom_test.cpp
tests/real128_test.cpp
tests/utf8_test.cpp
)
target_link_libraries( all_tests fc )
add_subdirectory(tests)
if(WIN32)
# add addtional import library on windows platform
@ -481,14 +471,6 @@ if(WIN32)
endif(WIN32)
IF(APPLE)
# As of 10.10 yosemite, the OpenSSL static libraries shipped with os x have a dependency
# on zlib, so any time you link in openssl you also need to link zlib. . We really want to detect whether openssl was configured with the --no-zlib
# option or not when it was built, but that's difficult to do in practice, so we
# just always try to link it in on mac.
find_package( ZLIB REQUIRED )
ENDIF(APPLE)
SET(OPENSSL_CONF_TARGET )
IF(DEFINED CMAKE_RUNTIME_OUTPUT_DIRECTORY)
SET (OPENSSL_CONF_TARGET ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
@ -497,8 +479,15 @@ ELSE()
ENDIF()
IF(WIN32)
IF("${OPENSSL_ROOT_DIR}" STREQUAL "")
get_filename_component(OPENSSL_ROOT_DIR "${OPENSSL_INCLUDE_DIR}/.." REALPATH)
ENDIF()
SET(OPENSSL_CONF_SOURCE "${OPENSSL_ROOT_DIR}/ssl/openssl.cnf")
IF(MINGW)
SET(OPENSSL_CONF_SOURCE "${OPENSSL_ROOT_DIR}/openssl.cnf")
ENDIF(MINGW)
SET(POST_BUILD_STEP_COMMANDS ${POST_BUILD_STEP_COMMANDS}
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${OPENSSL_ROOT_DIR}/ssl/openssl.cnf" "${OPENSSL_CONF_TARGET}/openssl.cnf")
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${OPENSSL_CONF_SOURCE}" "${OPENSSL_CONF_TARGET}/openssl.cnf")
ENDIF(WIN32)
ADD_CUSTOM_COMMAND(TARGET fc POST_BUILD ${POST_BUILD_STEP_COMMANDS}

0
CMakeModules/ArgumentParser.cmake Normal file → Executable file
View file

0
CMakeModules/FindBoost.cmake Normal file → Executable file
View file

0
CMakeModules/FindReadline.cmake Normal file → Executable file
View file

0
CMakeModules/FindVLD.cmake Normal file → Executable file
View file

View file

@ -1,127 +0,0 @@
# Find Wt includes and libraries
#
# This script sets the following variables:
#
# Wt_INCLUDE_DIR
# Wt_LIBRARIES - Release libraries
# Wt_FOUND - True if release libraries found
# Wt_DEBUG_LIBRARIES - Debug libraries
# Wt_DEBUG_FOUND - True if debug libraries found
#
# To direct the script to a particular Wt installation, use the
# standard cmake variables CMAKE_INCLUDE_PATH and CMAKE_LIBRARY_PATH
#
# To use this script to find Wt, when using the new style for include files:
# #include <Wt/WLineEdit>
# #include <Wt/Ext/LineEdit>
# #include <Wt/Chart/WPieChart>
#
# include the following CMake snippet in your project:
#
# FIND_PACKAGE( Wt REQUIRED )
# INCLUDE_DIRECTORIES( ${Wt_INCLUDE_DIR} )
# TARGET_LINK_LIBRARIES( yourexe
# ${Wt_DEBUG_LIBRARY} # or {Wt_LIBRARY}
# ${Wt_HTTP_DEBUG_LIBRARY} # or {Wt_HTTP_LIBRARY}
# ${Wt_EXT_DEBUG_LIBRARY} # or {Wt_EXT_LIBRARY}
# )
#
# To use this script to find Wt, when using the old include style:
# #include <WLineEdit>
# #include <Ext/LineEdit>
# #include <Chart/WPieChart>
# style of include files, change the INCLUDE_DIRECTORIES statement to:
# INCLUDE_DIRECTORIES( ${Wt_INCLUDE_DIR} ${Wt_INCLUDE_DIR}/Wt )
#
#
#
#
# Copyright (c) 2007, Pau Garcia i Quiles, <pgquiles@elpauer.org>
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
FIND_PATH( Wt_INCLUDE_DIR NAMES Wt/WObject PATHS ENV PATH PATH_SUFFIXES include wt )
SET( Wt_FIND_COMPONENTS Release Debug )
IF( Wt_INCLUDE_DIR )
FIND_LIBRARY( Wt_LIBRARY NAMES wt PATHS PATH PATH_SUFFIXES lib lib-release lib_release )
FIND_LIBRARY( Wt_EXT_LIBRARY NAMES wtext PATHS PATH PATH_SUFFIXES lib lib-release lib_release )
FIND_LIBRARY( Wt_HTTP_LIBRARY NAMES wthttp PATHS PATH PATH_SUFFIXES lib lib-release lib_release )
FIND_LIBRARY( Wt_FCGI_LIBRARY NAMES wtfcgi PATHS PATH PATH_SUFFIXES lib lib-release lib_release )
FIND_LIBRARY( Wt_DBO_LIBRARY NAMES wtdbo PATHS PATH PATH_SUFFIXES lib lib-release lib_release )
FIND_LIBRARY( Wt_DBOSQLITE3_LIBRARY NAMES wtdbosqlite3 PATHS PATH PATH_SUFFIXES lib lib-release lib_release )
FIND_LIBRARY( Wt_DBOPOSTGRES_LIBRARY NAMES wtdbopostgres PATHS PATH PATH_SUFFIXES lib lib-release lib_release )
FIND_LIBRARY( Wt_DEBUG_LIBRARY NAMES wtd wt PATHS PATH PATH_SUFFIXES lib libd lib-debug lib_debug HINTS /usr/lib/debug/usr/lib)
FIND_LIBRARY( Wt_EXT_DEBUG_LIBRARY NAMES wtextd wtext PATHS PATH PATH_SUFFIXES lib libd lib-debug lib_debug HINTS /usr/lib/debug/usr/lib)
FIND_LIBRARY( Wt_HTTP_DEBUG_LIBRARY NAMES wthttpd wthttp PATHS PATH PATH_SUFFIXES lib libd lib-debug lib_debug HINTS /usr/lib/debug/usr/lib)
FIND_LIBRARY( Wt_FCGI_DEBUG_LIBRARY NAMES wtfcgid wtfcgi PATHS PATH PATH_SUFFIXES lib libd lib-debug lib_debug HINTS /usr/lib/debug/usr/lib)
FIND_LIBRARY( Wt_DBO_DEBUG_LIBRARY NAMES wtdbod wtdbo PATHS PATH PATH_SUFFIXES lib lib-debug lib_debug HINTS /usr/lib/debug/usr/lib)
FIND_LIBRARY( Wt_DBOSQLITE3_DEBUG_LIBRARY NAMES wtdbosqlite3d wtdbosqlite3 PATHS PATH PATH_SUFFIXES lib lib-debug lib_debug HINTS /usr/lib/debug/usr/lib)
FIND_LIBRARY( Wt_DBOPOSTGRES_DEBUG_LIBRARY NAMES wtdbopostgresd wtdbopostgres PATHS PATH PATH_SUFFIXES lib lib-debug lib_debug HINTS /usr/lib/debug/usr/lib)
IF( Wt_LIBRARY AND Wt_EXT_LIBRARY AND Wt_HTTP_LIBRARY)
SET( Wt_FOUND TRUE )
SET( Wt_FIND_REQUIRED_Release TRUE )
SET( Wt_LIBRARIES ${Wt_HTTP_LIBRARY} ${Wt_EXT_LIBRARY} ${Wt_LIBRARY} )
ENDIF( Wt_LIBRARY AND Wt_EXT_LIBRARY AND Wt_HTTP_LIBRARY)
IF( Wt_DBO_LIBRARY )
SET( Wt_LIBRARIES ${Wt_LIBRARIES} ${Wt_DBO_LIBRARY} )
IF( Wt_DBOSQLITE3_LIBRARY )
SET( Wt_LIBRARIES ${Wt_LIBRARIES} ${Wt_DBOSQLITE3_LIBRARY} )
ENDIF( Wt_DBOSQLITE3_LIBRARY )
IF( Wt_DBOPOSTGRES_LIBRARY )
SET( Wt_LIBRARIES ${Wt_LIBRARIES} ${Wt_DBOPOSTGRES_LIBRARY} )
ENDIF( Wt_DBOPOSTGRES_LIBRARY )
ENDIF( Wt_DBO_LIBRARY )
IF( Wt_FCGI_LIBRARY )
SET( Wt_LIBRARIES ${Wt_LIBRARIES} ${Wt_FCGI_LIBRARY} )
ENDIF( Wt_FCGI_LIBRARY )
IF( Wt_DEBUG_LIBRARY AND Wt_EXT_DEBUG_LIBRARY AND Wt_HTTP_DEBUG_LIBRARY)
SET( Wt_DEBUG_FOUND TRUE )
SET( Wt_FIND_REQUIRED_Debug TRUE )
SET( Wt_DEBUG_LIBRARIES ${Wt_HTTP_DEBUG_LIBRARY} ${Wt_EXT_DEBUG_LIBRARY} ${Wt_DEBUG_LIBRARY} )
ENDIF( Wt_DEBUG_LIBRARY AND Wt_EXT_DEBUG_LIBRARY AND Wt_HTTP_DEBUG_LIBRARY)
IF( Wt_DBO_DEBUG_LIBRARY )
SET( Wt_DEBUG_LIBRARIES ${Wt_DEBUG_LIBRARIES} ${Wt_DBO_DEBUG_LIBRARY} )
IF( Wt_DBOSQLITE3_DEBUG_LIBRARY )
SET( Wt_DEBUG_LIBRARIES ${Wt_DEBUG_LIBRARIES} ${Wt_DBOSQLITE3_DEBUG_LIBRARY} )
ENDIF( Wt_DBOSQLITE3_DEBUG_LIBRARY )
IF( Wt_DBOPOSTGRES_DEBUG_LIBRARY )
SET( Wt_DEBUG_LIBRARIES ${Wt_DEBUG_LIBRARIES} ${Wt_DBOPOSTGRES_DEBUG_LIBRARY} )
ENDIF( Wt_DBOPOSTGRES_DEBUG_LIBRARY )
ENDIF( Wt_DBO_DEBUG_LIBRARY )
IF( Wt_FCGI_DEBUG_LIBRARY )
SET( Wt_DEBUG_LIBRARIES ${Wt_DEBUG_LIBRARIES} ${Wt_FCGI_DEBUG_LIBRARY} )
ENDIF( Wt_FCGI_DEBUG_LIBRARY )
IF(Wt_FOUND)
IF (NOT Wt_FIND_QUIETLY)
MESSAGE(STATUS "Found the Wt libraries at ${Wt_LIBRARIES}")
MESSAGE(STATUS "Found the Wt headers at ${Wt_INCLUDE_DIR}")
ENDIF (NOT Wt_FIND_QUIETLY)
ELSE(Wt_FOUND)
IF(Wt_FIND_REQUIRED)
MESSAGE(FATAL_ERROR "Could NOT find Wt")
ENDIF(Wt_FIND_REQUIRED)
ENDIF(Wt_FOUND)
IF(Wt_DEBUG_FOUND)
IF (NOT Wt_FIND_QUIETLY)
MESSAGE(STATUS "Found the Wt debug libraries at ${Wt_DEBUG_LIBRARIES}")
MESSAGE(STATUS "Found the Wt debug headers at ${Wt_INCLUDE_DIR}")
ENDIF (NOT Wt_FIND_QUIETLY)
ELSE(Wt_DEBUG_FOUND)
IF(Wt_FIND_REQUIRED_Debug)
MESSAGE(FATAL_ERROR "Could NOT find Wt debug libraries")
ENDIF(Wt_FIND_REQUIRED_Debug)
ENDIF(Wt_DEBUG_FOUND)
ENDIF( Wt_INCLUDE_DIR )

0
CMakeModules/ParseLibraryList.cmake Normal file → Executable file
View file

0
CMakeModules/SetupTargetMacros.cmake Normal file → Executable file
View file

0
CMakeModules/UseLibraryMacros.cmake Normal file → Executable file
View file

0
CMakeModules/VersionMacros.cmake Normal file → Executable file
View file

2
GitVersionGen/GetGitRevisionDescription.cmake Normal file → Executable file
View file

@ -58,7 +58,7 @@ function(get_git_head_revision _refspecvar _hashvar)
file(READ ${GIT_DIR} submodule)
string(REGEX REPLACE "gitdir: (.*)\n$" "\\1" GIT_DIR_RELATIVE ${submodule})
get_filename_component(SUBMODULE_DIR ${GIT_DIR} PATH)
get_filename_component(GIT_DIR ${SUBMODULE_DIR}/${GIT_DIR_RELATIVE} ABSOLUTE)
get_filename_component(GIT_DIR ${GIT_DIR_RELATIVE} ABSOLUTE BASE_DIR ${SUBMODULE_DIR})
endif()
set(GIT_DATA "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/git-data")
if(NOT EXISTS "${GIT_DATA}")

0
GitVersionGen/GetGitRevisionDescription.cmake.in Normal file → Executable file
View file

0
README-ecc.md Normal file → Executable file
View file

2
README.md Normal file → Executable file
View file

@ -1,6 +1,8 @@
fc
==
**NOTE:** This fork reverts upstream commit a421e280488385cab26a42153f7ce3c8d5b6281f to avoid changing the BitShares API.
FC stands for fast-compiling c++ library and provides a set of utility libraries useful
for the development of asynchronous libraries. Some of the highlights include:

0
fc.natvis Normal file → Executable file
View file

0
include/fc/actor.hpp Normal file → Executable file
View file

0
include/fc/aligned.hpp Normal file → Executable file
View file

0
include/fc/any.hpp Normal file → Executable file
View file

31
include/fc/api.hpp Normal file → Executable file
View file

@ -38,8 +38,33 @@ namespace fc {
OtherType& _source;
};
template<typename Interface, typename Transform >
class api;
class api_connection;
typedef uint32_t api_id_type;
class api_base
{
public:
api_base() {}
virtual ~api_base() {}
virtual uint64_t get_handle()const = 0;
virtual api_id_type register_api( api_connection& conn )const = 0;
// defined in api_connection.hpp
template< typename T >
api<T, identity_member> as();
};
typedef std::shared_ptr< api_base > api_ptr;
class api_connection;
template<typename Interface, typename Transform = identity_member >
class api {
class api : public api_base {
public:
typedef vtable<Interface,Transform> vtable_type;
@ -58,10 +83,12 @@ namespace fc {
}
api( const api& cpy ):_vtable(cpy._vtable),_data(cpy._data) {}
virtual ~api() {}
friend bool operator == ( const api& a, const api& b ) { return a._data == b._data && a._vtable == b._vtable; }
friend bool operator != ( const api& a, const api& b ) { return !(a._data == b._data && a._vtable == b._vtable); }
uint64_t get_handle()const { return uint64_t(_data.get()); }
virtual uint64_t get_handle()const override { return uint64_t(_data.get()); }
virtual api_id_type register_api( api_connection& conn )const override; // defined in api_connection.hpp
vtable_type& operator*()const { FC_ASSERT( _vtable ); return *_vtable; }
vtable_type* operator->()const { FC_ASSERT( _vtable ); return _vtable.get(); }

8
include/fc/array.hpp Normal file → Executable file
View file

@ -21,10 +21,16 @@ namespace fc {
const T& at( size_t pos )const { assert( pos < N); return data[pos]; }
///@}
T* begin() { return &data[0]; }
T& operator[]( size_t pos ) { assert( pos < N); return data[pos]; }
const T& operator[]( size_t pos )const { assert( pos < N); return data[pos]; }
const T* begin()const { return &data[0]; }
const T* end()const { return &data[N]; }
T* begin() { return &data[0]; }
T* end() { return &data[N]; }
size_t size()const { return N; }
T data[N];

0
include/fc/asio.hpp Normal file → Executable file
View file

0
include/fc/bitutil.hpp Normal file → Executable file
View file

0
include/fc/bloom_filter.hpp Normal file → Executable file
View file

0
include/fc/compress/smaz.hpp Normal file → Executable file
View file

0
include/fc/compress/zlib.hpp Normal file → Executable file
View file

0
include/fc/container/deque.hpp Normal file → Executable file
View file

0
include/fc/container/deque_fwd.hpp Normal file → Executable file
View file

45
include/fc/container/flat.hpp Normal file → Executable file
View file

@ -30,8 +30,8 @@ namespace fc {
value.insert( std::move(tmp) );
}
}
template<typename Stream, typename K, typename V>
inline void pack( Stream& s, const flat_map<K,V>& value ) {
template<typename Stream, typename K, typename... V>
inline void pack( Stream& s, const flat_map<K,V...>& value ) {
pack( s, unsigned_int((uint32_t)value.size()) );
auto itr = value.begin();
auto end = value.end();
@ -40,8 +40,8 @@ namespace fc {
++itr;
}
}
template<typename Stream, typename K, typename V>
inline void unpack( Stream& s, flat_map<K,V>& value )
template<typename Stream, typename K, typename V, typename... A>
inline void unpack( Stream& s, flat_map<K,V,A...>& value )
{
unsigned_int size; unpack( s, size );
value.clear();
@ -54,6 +54,35 @@ namespace fc {
value.insert( std::move(tmp) );
}
}
template<typename Stream, typename T, typename A>
void pack( Stream& s, const bip::vector<T,A>& value ) {
pack( s, unsigned_int((uint32_t)value.size()) );
if( !std::is_fundamental<T>::value ) {
auto itr = value.begin();
auto end = value.end();
while( itr != end ) {
fc::raw::pack( s, *itr );
++itr;
}
} else {
s.write( (const char*)value.data(), value.size() );
}
}
template<typename Stream, typename T, typename A>
void unpack( Stream& s, bip::vector<T,A>& value ) {
unsigned_int size;
unpack( s, size );
value.resize( size );
if( !std::is_fundamental<T>::value ) {
for( auto& item : value )
unpack( s, item );
} else {
s.read( (char*)value.data(), value.size() );
}
}
} // namespace raw
@ -76,8 +105,8 @@ namespace fc {
vo.insert( itr->as<T>() );
}
template<typename K, typename T>
void to_variant( const flat_map<K, T>& var, variant& vo )
template<typename K, typename... T>
void to_variant( const flat_map<K, T...>& var, variant& vo )
{
std::vector< variant > vars(var.size());
size_t i = 0;
@ -85,8 +114,8 @@ namespace fc {
vars[i] = fc::variant(*itr);
vo = vars;
}
template<typename K, typename T>
void from_variant( const variant& var, flat_map<K, T>& vo )
template<typename K, typename T, typename... A>
void from_variant( const variant& var, flat_map<K, T, A...>& vo )
{
const variants& vars = var.get_array();
vo.clear();

16
include/fc/container/flat_fwd.hpp Normal file → Executable file
View file

@ -1,21 +1,29 @@
#pragma once
#include <boost/container/flat_map.hpp>
#include <boost/container/flat_set.hpp>
#include <boost/interprocess/containers/vector.hpp>
namespace fc {
using boost::container::flat_map;
using boost::container::flat_set;
namespace bip = boost::interprocess;
namespace raw {
template<typename Stream, typename T>
void pack( Stream& s, const flat_set<T>& value );
template<typename Stream, typename T>
void unpack( Stream& s, flat_set<T>& value );
template<typename Stream, typename K, typename V>
void pack( Stream& s, const flat_map<K,V>& value );
template<typename Stream, typename K, typename V>
void unpack( Stream& s, flat_map<K,V>& value ) ;
template<typename Stream, typename K, typename... V>
void pack( Stream& s, const flat_map<K,V...>& value );
template<typename Stream, typename K, typename V, typename... A>
void unpack(Stream& s, flat_map<K, V, A...>& value);
template<typename Stream, typename T, typename A>
void pack( Stream& s, const bip::vector<T,A>& value );
template<typename Stream, typename T, typename A>
void unpack( Stream& s, bip::vector<T,A>& value );
} // namespace raw
} // fc

0
include/fc/crypto/aes.hpp Normal file → Executable file
View file

View file

@ -1,10 +0,0 @@
#pragma once
#include <fc/vector.hpp>
#include <fc/string.hpp>
namespace fc
{
std::vector<char> from_base32( const fc::string& b32 );
fc::string to_base32( const std::vector<char>& vec );
fc::string to_base32( const char* data, size_t len );
}

0
include/fc/crypto/base36.hpp Normal file → Executable file
View file

0
include/fc/crypto/base58.hpp Normal file → Executable file
View file

0
include/fc/crypto/base64.hpp Normal file → Executable file
View file

0
include/fc/crypto/bigint.hpp Normal file → Executable file
View file

0
include/fc/crypto/blowfish.hpp Normal file → Executable file
View file

0
include/fc/crypto/city.hpp Normal file → Executable file
View file

0
include/fc/crypto/dh.hpp Normal file → Executable file
View file

0
include/fc/crypto/digest.hpp Normal file → Executable file
View file

30
include/fc/crypto/elliptic.hpp Normal file → Executable file
View file

@ -25,8 +25,6 @@ namespace fc {
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 blinded_hash;
typedef fc::sha256 blind_signature;
/**
* @class public_key
@ -38,7 +36,6 @@ namespace fc {
public_key();
public_key(const public_key& k);
~public_key();
// bool verify( const fc::sha256& digest, const signature& sig );
public_key_data serialize()const;
public_key_point_data serialize_ecc_point()const;
@ -52,8 +49,6 @@ namespace fc {
public_key child( const fc::sha256& offset )const;
bool valid()const;
/** Computes new pubkey = generator * offset + old pubkey ?! */
// public_key mult( const fc::sha256& offset )const;
/** Computes new pubkey = regenerate(offset).pubkey + old pubkey
* = offset * G + 1 * old pubkey ?! */
public_key add( const fc::sha256& offset )const;
@ -123,7 +118,7 @@ namespace fc {
fc::sha512 get_shared_secret( const public_key& pub )const;
// signature sign( const fc::sha256& digest )const;
compact_signature sign_compact( const fc::sha256& digest )const;
compact_signature sign_compact( const fc::sha256& digest, bool require_canonical = true )const;
// bool verify( const fc::sha256& digest, const signature& sig );
public_key get_public_key()const;
@ -164,8 +159,6 @@ namespace fc {
fc::string to_base58() const { return str(); }
static extended_public_key from_base58( const fc::string& base58 );
public_key generate_p( int i ) const;
public_key generate_q( int i ) const;
private:
sha256 c;
int child_num, parent_fp;
@ -192,25 +185,10 @@ namespace fc {
static extended_private_key generate_master( const fc::string& seed );
static extended_private_key generate_master( const char* seed, uint32_t seed_len );
// Oleg Andreev's blind signature scheme,
// see http://blog.oleganza.com/post/77474860538/blind-signatures
public_key blind_public_key( const extended_public_key& bob, int i ) const;
blinded_hash blind_hash( const fc::sha256& hash, int i ) const;
blind_signature blind_sign( const blinded_hash& hash, int i ) const;
// WARNING! This may produce non-canonical signatures!
compact_signature unblind_signature( const extended_public_key& bob,
const blind_signature& sig,
const fc::sha256& hash, int i ) const;
private:
extended_private_key private_derive_rest( const fc::sha512& hash,
int num ) const;
private_key generate_a( int i ) const;
private_key generate_b( int i ) const;
private_key generate_c( int i ) const;
private_key generate_d( int i ) const;
private_key_secret compute_p( int i ) const;
private_key_secret compute_q( int i, const private_key_secret& p ) const;
sha256 c;
int child_num, parent_fp;
uint8_t depth;
@ -218,8 +196,8 @@ namespace fc {
struct range_proof_info
{
int exp;
int mantissa;
int64_t exp;
int64_t mantissa;
uint64_t min_value;
uint64_t max_value;
};

View file

@ -0,0 +1,107 @@
#pragma once
#include <boost/multiprecision/integer.hpp>
namespace fc {
/**
* Always returns 0. Useful for testing.
*/
class nullary_rng
{
public:
nullary_rng() {}
virtual ~nullary_rng() {}
template< typename T > T operator()( T max )
{ return T(0); }
} ;
/**
* The hash_ctr_rng generates bits using a hash function in counter (CTR)
* mode.
*/
template<class HashClass, int SeedLength>
class hash_ctr_rng
{
public:
hash_ctr_rng( const char* seed, uint64_t counter = 0 )
: _counter( counter ), _current_offset( 0 )
{
memcpy( _seed, seed, SeedLength );
_reset_current_value();
return;
}
virtual ~hash_ctr_rng() {}
uint64_t get_bits( uint8_t count )
{
uint64_t result = 0;
uint64_t mask = 1;
// grab the requested number of bits
while( count > 0 )
{
result |=
(
(
(
_current_value.data()[ (_current_offset >> 3) & 0x1F ]
& ( 1 << (_current_offset & 0x07) )
)
!= 0
) ? mask : 0
);
mask += mask;
--count;
++_current_offset;
if( _current_offset == (_current_value.data_size() << 3) )
{
_counter++;
_current_offset = 0;
_reset_current_value();
}
}
return result;
}
uint64_t operator()( uint64_t bound )
{
if( bound <= 1 )
return 0;
uint8_t bitcount = boost::multiprecision::detail::find_msb( bound ) + 1;
// probability of loop exiting is >= 1/2, so probability of
// running N times is bounded above by (1/2)^N
while( true )
{
uint64_t result = get_bits( bitcount );
if( result < bound )
return result;
}
}
// convenience method which does casting for types other than uint64_t
template< typename T > T operator()( T bound )
{ return (T) ( (*this)(uint64_t( bound )) ); }
void _reset_current_value()
{
// internal implementation detail, called to update
// _current_value when _counter changes
typename HashClass::encoder enc;
enc.write( _seed , SeedLength );
enc.write( (char *) &_counter, 8 );
_current_value = enc.result();
return;
}
uint64_t _counter;
char _seed[ SeedLength ];
HashClass _current_value;
uint16_t _current_offset;
static const int seed_length = SeedLength;
};
} // end namespace fc

0
include/fc/crypto/hex.hpp Normal file → Executable file
View file

0
include/fc/crypto/hmac.hpp Normal file → Executable file
View file

0
include/fc/crypto/md5.hpp Normal file → Executable file
View file

0
include/fc/crypto/openssl.hpp Normal file → Executable file
View file

0
include/fc/crypto/pke.hpp Normal file → Executable file
View file

0
include/fc/crypto/rand.hpp Normal file → Executable file
View file

0
include/fc/crypto/ripemd160.hpp Normal file → Executable file
View file

0
include/fc/crypto/sha1.hpp Normal file → Executable file
View file

0
include/fc/crypto/sha224.hpp Normal file → Executable file
View file

23
include/fc/crypto/sha256.hpp Normal file → Executable file
View file

@ -68,7 +68,7 @@ class sha256
friend bool operator > ( const sha256& h1, const sha256& h2 );
friend bool operator < ( const sha256& h1, const sha256& h2 );
uint32_t pop_count()
uint32_t pop_count()const
{
return (uint32_t)(__builtin_popcountll(_hash[0]) +
__builtin_popcountll(_hash[1]) +
@ -76,6 +76,25 @@ class sha256
__builtin_popcountll(_hash[3]));
}
/**
* Count leading zero bits
*/
uint16_t clz()const;
/**
* Approximate (log_2(x) + 1) * 2**24.
*
* Detailed specs:
* - Return 0 when x == 0.
* - High 8 bits of result simply counts nonzero bits.
* - Low 24 bits of result are the 24 bits of input immediately after the most significant 1 in the input.
* - If above would require reading beyond the end of the input, zeros are used instead.
*/
uint32_t approx_log_32()const;
void set_to_inverse_approx_log_32( uint32_t x );
static double inverse_approx_log_32_double( uint32_t x );
uint64_t _hash[4];
};
@ -99,5 +118,7 @@ namespace std
}
};
}
#include <fc/reflect/reflect.hpp>
FC_REFLECT_TYPENAME( fc::sha256 )

0
include/fc/crypto/sha512.hpp Normal file → Executable file
View file

4
include/fc/exception/exception.hpp Normal file → Executable file
View file

@ -32,7 +32,6 @@ namespace fc
invalid_operation_exception_code = 14,
unknown_host_exception_code = 15,
null_optional_code = 16,
udt_error_code = 17,
aes_error_code = 18,
overflow_code = 19,
underflow_code = 20,
@ -76,7 +75,7 @@ namespace fc
const std::string& what_value = "unspecified");
exception( const exception& e );
exception( exception&& e );
~exception();
virtual ~exception();
const char* name()const throw();
int64_t code()const throw();
@ -294,7 +293,6 @@ namespace fc
FC_DECLARE_EXCEPTION( assert_exception, assert_exception_code, "Assert Exception" );
FC_DECLARE_EXCEPTION( eof_exception, eof_exception_code, "End Of File" );
FC_DECLARE_EXCEPTION( null_optional, null_optional_code, "null optional" );
FC_DECLARE_EXCEPTION( udt_exception, udt_error_code, "UDT error" );
FC_DECLARE_EXCEPTION( aes_exception, aes_error_code, "AES error" );
FC_DECLARE_EXCEPTION( overflow_exception, overflow_code, "Integer Overflow" );
FC_DECLARE_EXCEPTION( underflow_exception, underflow_code, "Integer Underflow" );

10
include/fc/filesystem.hpp Normal file → Executable file
View file

@ -31,7 +31,7 @@ namespace fc {
path();
~path();
path( const boost::filesystem::path& );
path( const fc::string& p );
path( const std::string& p );
/// Constructor to build path using unicode native characters.
path(const std::wstring& p);
path( const char* );
@ -54,12 +54,12 @@ namespace fc {
fc::path extension()const;
fc::path filename()const;
fc::path parent_path()const;
fc::string string()const;
fc::string generic_string()const;
std::string string()const;
std::string generic_string()const;
/** On windows, returns a path where all path separators are '\' suitable for displaying
* to users. On other platforms, it does the same as generic_string()
*/
fc::string preferred_string() const;
std::string preferred_string() const;
std::wstring wstring() const;
std::wstring generic_wstring() const;
@ -77,7 +77,7 @@ namespace fc {
*
* @note not part of boost::filesystem::path
*/
fc::string windows_string()const;
std::string windows_string()const;
bool is_relative()const;
bool is_absolute()const;

161
include/fc/fixed_string.hpp Executable file
View file

@ -0,0 +1,161 @@
#pragma once
#include <fc/io/raw_fwd.hpp>
namespace fc {
/**
* This class is designed to offer in-place memory allocation of a string up to Length equal to
* sizeof(Storage).
*
* The string will serialize the same way as std::string for variant and raw formats
* The string will sort according to the comparison operators defined for Storage, this enables effecient
* sorting.
*/
template<typename Storage = std::pair<uint64_t,uint64_t> >
class fixed_string {
public:
fixed_string(){}
fixed_string( const fixed_string& c ):data(c.data){}
fixed_string( const std::string& str ) {
if( str.size() <= sizeof(data) )
memcpy( (char*)&data, str.c_str(), str.size() );
else {
memcpy( (char*)&data, str.c_str(), sizeof(data) );
}
}
fixed_string( const char* str ) {
auto l = strlen(str);
if( l <= sizeof(data) )
memcpy( (char*)&data, str, l );
else {
memcpy( (char*)&data, str, sizeof(data) );
}
}
operator std::string()const {
const char* self = (const char*)&data;
return std::string( self, self + size() );
}
uint32_t size()const {
if( *(((const char*)&data)+sizeof(data) - 1) )
return sizeof(data);
return strnlen( (const char*)&data, sizeof(data) );
}
uint32_t length()const { return size(); }
fixed_string& operator=( const fixed_string& str ) {
data = str.data;
return *this;
}
fixed_string& operator=( const char* str ) {
return *this = fixed_string(str);
}
fixed_string& operator=( const std::string& str ) {
if( str.size() <= sizeof(data) ) {
data = Storage();
memcpy( (char*)&data, str.c_str(), str.size() );
}
else {
memcpy( (char*)&data, str.c_str(), sizeof(data) );
}
return *this;
}
friend std::string operator + ( const fixed_string& a, const std::string& b ) {
return std::string(a) + b;
}
friend std::string operator + ( const std::string& a, const fixed_string& b ) {
return a + std::string(b);
}
friend bool operator < ( const fixed_string& a, const fixed_string& b ) {
return a.data < b.data;
}
friend bool operator <= ( const fixed_string& a, const fixed_string& b ) {
return a.data <= b.data;
}
friend bool operator > ( const fixed_string& a, const fixed_string& b ) {
return a.data > b.data;
}
friend bool operator >= ( const fixed_string& a, const fixed_string& b ) {
return a.data >= b.data;
}
friend bool operator == ( const fixed_string& a, const fixed_string& b ) {
return a.data == b.data;
}
friend bool operator != ( const fixed_string& a, const fixed_string& b ) {
return a.data != b.data;
}
//private:
Storage data;
};
namespace raw
{
template<typename Stream, typename Storage>
inline void pack( Stream& s, const fc::fixed_string<Storage>& u ) {
unsigned_int size = u.size();
pack( s, size );
s.write( (const char*)&u.data, size );
}
template<typename Stream, typename Storage>
inline void unpack( Stream& s, fc::fixed_string<Storage>& u ) {
unsigned_int size;
fc::raw::unpack( s, size );
if( size.value > 0 ) {
if( size.value > sizeof(Storage) ) {
s.read( (char*)&u.data, sizeof(Storage) );
char buf[1024];
size_t left = size.value - sizeof(Storage);
while( left >= 1024 )
{
s.read( buf, 1024 );
left -= 1024;
}
s.read( buf, left );
/*
s.seekp( s.tellp() + (size.value - sizeof(Storage)) );
char tmp;
size.value -= sizeof(storage);
while( size.value ){ s.read( &tmp, 1 ); --size.value; }
*/
// s.skip( size.value - sizeof(Storage) );
} else {
s.read( (char*)&u.data, size.value );
}
}
}
/*
template<typename Stream, typename... Args>
inline void pack( Stream& s, const boost::multiprecision::number<Args...>& d ) {
s.write( (const char*)&d, sizeof(d) );
}
template<typename Stream, typename... Args>
inline void unpack( Stream& s, boost::multiprecision::number<Args...>& u ) {
s.read( (const char*)&u, sizeof(u) );
}
*/
}
}
#include <fc/variant.hpp>
namespace fc {
template<typename Storage>
void to_variant( const fixed_string<Storage>& s, variant& v ) {
v = std::string(s);
}
template<typename Storage>
void from_variant( const variant& v, fixed_string<Storage>& s ) {
s = v.as_string();
}
}

0
include/fc/fwd.hpp Normal file → Executable file
View file

0
include/fc/fwd_impl.hpp Normal file → Executable file
View file

0
include/fc/git_revision.hpp Normal file → Executable file
View file

View file

@ -0,0 +1,143 @@
#pragma once
#include <fc/variant.hpp>
#include <boost/interprocess/allocators/allocator.hpp>
#include <boost/interprocess/containers/string.hpp>
#include <boost/interprocess/containers/vector.hpp>
#include <boost/interprocess/containers/map.hpp>
#include <boost/interprocess/containers/flat_map.hpp>
#include <boost/interprocess/containers/set.hpp>
#include <boost/interprocess/containers/deque.hpp>
#include <fc/crypto/hex.hpp>
#include <fc/io/raw_fwd.hpp>
namespace fc {
namespace bip = boost::interprocess;
template<typename... T >
void to_variant( const bip::deque< T... >& t, fc::variant& v ) {
std::vector<variant> vars(t.size());
for( size_t i = 0; i < t.size(); ++i ) {
vars[i] = t[i];
}
v = std::move(vars);
}
template<typename T, typename... A>
void from_variant( const fc::variant& v, bip::deque< T, A... >& d ) {
const variants& vars = v.get_array();
d.clear();
d.resize( vars.size() );
for( uint32_t i = 0; i < vars.size(); ++i ) {
from_variant( vars[i], d[i] );
}
}
//bip::map == boost::map
template<typename K, typename V, typename... T >
void to_variant( const bip::map< K, V, T... >& var, fc::variant& vo ) {
std::vector< variant > vars(var.size());
size_t i = 0;
for( auto itr = var.begin(); itr != var.end(); ++itr, ++i )
vars[i] = fc::variant(*itr);
vo = vars;
}
/*
template<typename K, typename V, typename... A>
void from_variant( const variant& var, bip::map<K, V, A...>& vo )
{
const variants& vars = var.get_array();
vo.clear();
for( auto itr = vars.begin(); itr != vars.end(); ++itr )
vo.insert( itr->as< std::pair<K,V> >() ); Not safe for interprocess. Needs allocator
}
*/
template<typename... T >
void to_variant( const bip::vector< T... >& t, fc::variant& v ) {
std::vector<variant> vars(t.size());
for( size_t i = 0; i < t.size(); ++i ) {
vars[i] = t[i];
}
v = std::move(vars);
}
template<typename T, typename... A>
void from_variant( const fc::variant& v, bip::vector< T, A... >& d ) {
const variants& vars = v.get_array();
d.clear();
d.resize( vars.size() );
for( uint32_t i = 0; i < vars.size(); ++i ) {
from_variant( vars[i], d[i] );
}
}
template<typename... T >
void to_variant( const bip::set< T... >& t, fc::variant& v ) {
std::vector<variant> vars;
vars.reserve(t.size());
for( const auto& item : t ) {
vars.emplace_back( item );
}
v = std::move(vars);
}
/*
template<typename T, typename... A>
void from_variant( const fc::variant& v, bip::set< T, A... >& d ) {
const variants& vars = v.get_array();
d.clear();
d.reserve( vars.size() );
for( uint32_t i = 0; i < vars.size(); ++i ) {
from_variant( vars[i], d[i] ); Not safe for interprocess. Needs allocator
}
}
*/
template<typename... A>
void to_variant( const bip::vector<char, A...>& t, fc::variant& v )
{
if( t.size() )
v = variant(fc::to_hex(t.data(), t.size()));
else
v = "";
}
template<typename... A>
void from_variant( const fc::variant& v, bip::vector<char, A...>& d )
{
auto str = v.as_string();
d.resize( str.size() / 2 );
if( d.size() )
{
size_t r = fc::from_hex( str, d.data(), d.size() );
FC_ASSERT( r == d.size() );
}
// std::string b64 = base64_decode( var.as_string() );
// vo = std::vector<char>( b64.c_str(), b64.c_str() + b64.size() );
}
namespace raw {
namespace bip = boost::interprocess;
template<typename Stream, typename T, typename... A>
inline void pack( Stream& s, const bip::vector<T,A...>& value ) {
pack( s, unsigned_int((uint32_t)value.size()) );
auto itr = value.begin();
auto end = value.end();
while( itr != end ) {
fc::raw::pack( s, *itr );
++itr;
}
}
template<typename Stream, typename T, typename... A>
inline void unpack( Stream& s, bip::vector<T,A...>& value ) {
unsigned_int size;
unpack( s, size );
value.clear(); value.resize(size);
for( auto& item : value )
fc::raw::unpack( s, item );
}
}
}

0
include/fc/interprocess/file_mapping.hpp Normal file → Executable file
View file

View file

@ -0,0 +1,44 @@
#pragma once
#include <fc/time.hpp>
#include <fc/thread/spin_yield_lock.hpp>
#include <memory>
namespace fc {
class microseconds;
class time_point;
class path;
struct context;
namespace detail { class file_mutex_impl; }
/**
* The purpose of this class is to support synchronization of
* processes, threads, and coop-threads.
*
* Before grabbing the lock for a thread or coop, a file_mutex will first
* grab a process-level lock. After grabbing the process level lock, it will
* synchronize in the same way as a local process lock.
*/
class file_mutex {
public:
file_mutex( const fc::path& filename );
~file_mutex();
bool try_lock();
bool try_lock_for( const microseconds& rel_time );
bool try_lock_until( const time_point& abs_time );
void lock();
void unlock();
void lock_shared();
void unlock_shared();
bool try_lock_shared();
int readers()const;
private:
std::unique_ptr<detail::file_mutex_impl> my;
};
} // namespace fc

0
include/fc/interprocess/iprocess.hpp Normal file → Executable file
View file

0
include/fc/interprocess/mmap_struct.hpp Normal file → Executable file
View file

0
include/fc/interprocess/process.hpp Normal file → Executable file
View file

0
include/fc/interprocess/signals.hpp Normal file → Executable file
View file

0
include/fc/io/buffered_iostream.hpp Normal file → Executable file
View file

0
include/fc/io/console.hpp Normal file → Executable file
View file

0
include/fc/io/datastream.hpp Normal file → Executable file
View file

0
include/fc/io/datastream_back.hpp Normal file → Executable file
View file

0
include/fc/io/enum_type.hpp Normal file → Executable file
View file

0
include/fc/io/fstream.hpp Normal file → Executable file
View file

0
include/fc/io/iobuffer.hpp Normal file → Executable file
View file

0
include/fc/io/iostream.hpp Normal file → Executable file
View file

0
include/fc/io/json.hpp Normal file → Executable file
View file

1
include/fc/io/json_relaxed.hpp Normal file → Executable file
View file

@ -123,6 +123,7 @@ namespace fc { namespace json_relaxed
char c2 = in.peek();
if( c2 == q )
{
in.get();
char c3 = in.peek();
if( c3 == q )
{

27
include/fc/io/raw.hpp Normal file → Executable file
View file

@ -17,6 +17,13 @@
namespace fc {
namespace raw {
template<typename Stream, typename Arg0, typename... Args>
inline void pack( Stream& s, const Arg0& a0, Args... args ) {
pack( s, a0 );
pack( s, args... );
}
template<typename Stream>
inline void pack( Stream& s, const fc::exception& e )
{
@ -324,13 +331,13 @@ namespace fc {
struct if_enum<fc::true_type> {
template<typename Stream, typename T>
static inline void pack( Stream& s, const T& v ) {
fc::raw::pack(s, (int64_t)v);
fc::raw::pack(s, signed_int((int32_t)v));
}
template<typename Stream, typename T>
static inline void unpack( Stream& s, T& v ) {
int64_t temp;
signed_int temp;
fc::raw::unpack(s, temp);
v = (T)temp;
v = (T)temp.value;
}
};
@ -547,6 +554,20 @@ namespace fc {
return vec;
}
template<typename T, typename... Next>
inline std::vector<char> pack( const T& v, Next... next ) {
datastream<size_t> ps;
fc::raw::pack(ps,v,next...);
std::vector<char> vec(ps.tellp());
if( vec.size() ) {
datastream<char*> ds( vec.data(), size_t(vec.size()) );
fc::raw::pack(ds,v,next...);
}
return vec;
}
template<typename T>
inline T unpack( const std::vector<char>& s )
{ try {

14
include/fc/io/raw_fwd.hpp Normal file → Executable file
View file

@ -25,12 +25,22 @@ namespace fc {
namespace ip { class endpoint; }
namespace ecc { class public_key; class private_key; }
template<typename Storage> class fixed_string;
namespace raw {
template<typename T>
inline size_t pack_size( const T& v );
template<typename Stream, typename Storage> inline void pack( Stream& s, const fc::fixed_string<Storage>& u );
template<typename Stream, typename Storage> inline void unpack( Stream& s, fc::fixed_string<Storage>& u );
template<typename Stream, typename IntType, typename EnumType>
inline void pack( Stream& s, const fc::enum_type<IntType,EnumType>& tp );
template<typename Stream, typename IntType, typename EnumType>
inline void unpack( Stream& s, fc::enum_type<IntType,EnumType>& tp );
template<typename Stream, typename T> inline void pack( Stream& s, const std::set<T>& value );
template<typename Stream, typename T> inline void unpack( Stream& s, std::set<T>& value );
template<typename Stream, typename T> inline void pack( Stream& s, const std::unordered_set<T>& value );
@ -51,8 +61,8 @@ namespace fc {
template<typename Stream, typename K, typename V> inline void pack( Stream& s, const std::map<K,V>& value );
template<typename Stream, typename K, typename V> inline void unpack( Stream& s, std::map<K,V>& value );
template<typename Stream, typename K, typename V> inline void pack( Stream& s, const flat_map<K,V>& value );
template<typename Stream, typename K, typename V> inline void unpack( Stream& s, flat_map<K,V>& value );
template<typename Stream, typename K, typename... V> inline void pack( Stream& s, const flat_map<K,V...>& value );
template<typename Stream, typename K, typename V, typename... A> inline void unpack( Stream& s, flat_map<K,V,A...>& value );
template<typename Stream, typename K, typename V> inline void pack( Stream& s, const std::pair<K,V>& value );
template<typename Stream, typename K, typename V> inline void unpack( Stream& s, std::pair<K,V>& value );

0
include/fc/io/raw_unpack_file.hpp Normal file → Executable file
View file

0
include/fc/io/raw_variant.hpp Normal file → Executable file
View file

0
include/fc/io/sstream.hpp Normal file → Executable file
View file

0
include/fc/io/stdio.hpp Normal file → Executable file
View file

0
include/fc/io/varint.hpp Normal file → Executable file
View file

0
include/fc/log/appender.hpp Normal file → Executable file
View file

0
include/fc/log/console_appender.hpp Normal file → Executable file
View file

0
include/fc/log/file_appender.hpp Normal file → Executable file
View file

0
include/fc/log/gelf_appender.hpp Normal file → Executable file
View file

0
include/fc/log/log_message.hpp Normal file → Executable file
View file

9
include/fc/log/logger.hpp Normal file → Executable file
View file

@ -155,6 +155,15 @@ namespace fc
#define FC_FORMAT_ARG_PARAMS( ... )\
BOOST_PP_SEQ_FOR_EACH( FC_FORMAT_ARGS, v, __VA_ARGS__ )
#define fc_ddump( LOGGER, SEQ ) \
fc_dlog( LOGGER, FC_FORMAT(SEQ), FC_FORMAT_ARG_PARAMS(SEQ) )
#define fc_idump( LOGGER, SEQ ) \
fc_ilog( LOGGER, FC_FORMAT(SEQ), FC_FORMAT_ARG_PARAMS(SEQ) )
#define fc_wdump( LOGGER, SEQ ) \
fc_wlog( LOGGER, FC_FORMAT(SEQ), FC_FORMAT_ARG_PARAMS(SEQ) )
#define fc_edump( LOGGER, SEQ ) \
fc_elog( LOGGER, FC_FORMAT(SEQ), FC_FORMAT_ARG_PARAMS(SEQ) )
#define ddump( SEQ ) \
dlog( FC_FORMAT(SEQ), FC_FORMAT_ARG_PARAMS(SEQ) )
#define idump( SEQ ) \

0
include/fc/log/logger_config.hpp Normal file → Executable file
View file

0
include/fc/make_fused.hpp Normal file → Executable file
View file

View file

@ -1,57 +0,0 @@
#pragma once
#include <fc/crypto/ripemd160.hpp>
#include <fc/crypto/rand.hpp>
#include <fc/optional.hpp>
#include <fc/network/ip.hpp>
#include <memory>
#include <vector>
namespace fc
{
namespace detail {
class gntp_icon_impl;
}
class gntp_notifier;
class gntp_icon {
public:
gntp_icon(const char* buffer, size_t length);
~gntp_icon();
private:
std::unique_ptr<detail::gntp_icon_impl> my;
friend class gntp_notifier;
};
typedef std::shared_ptr<gntp_icon> gntp_icon_ptr;
class gntp_notification_type {
public:
std::string name;
std::string display_name;
bool enabled;
gntp_icon_ptr icon;
};
typedef std::vector<gntp_notification_type> gntp_notification_type_list;
namespace detail {
class gntp_notifier_impl;
}
typedef uint160_t gntp_guid;
class gntp_notifier {
public:
gntp_notifier(const std::string& host_to_notify = "127.0.0.1", uint16_t port = 23053,
const optional<std::string>& password = optional<std::string>());
~gntp_notifier();
void set_application_name(std::string application_name);
void set_application_icon(const gntp_icon_ptr& icon);
void register_notifications();
gntp_guid send_notification(std::string name, std::string title, std::string text, const gntp_icon_ptr& icon = gntp_icon_ptr(), optional<gntp_guid> coalescingId = optional<gntp_guid>());
void add_notification_type(const gntp_notification_type& notificationType);
private:
std::unique_ptr<detail::gntp_notifier_impl> my;
};
} // namespace fc

1
include/fc/network/http/connection.hpp Normal file → Executable file
View file

@ -40,6 +40,7 @@ namespace fc {
struct request
{
fc::string get_header( const fc::string& key )const;
fc::string remote_endpoint;
fc::string method;
fc::string domain;
fc::string path;

0
include/fc/network/http/server.hpp Normal file → Executable file
View file

6
include/fc/network/http/websocket.hpp Normal file → Executable file
View file

@ -29,6 +29,8 @@ namespace fc { namespace http {
void set_session_data( fc::any d ){ _session_data = std::move(d); }
fc::any& get_session_data() { return _session_data; }
virtual std::string get_request_header(const std::string& key) = 0;
fc::signal<void()> closed;
private:
fc::any _session_data;
@ -76,7 +78,7 @@ namespace fc { namespace http {
class websocket_client
{
public:
websocket_client();
websocket_client( const std::string& ca_filename = "_default" );
~websocket_client();
websocket_connection_ptr connect( const std::string& uri );
@ -88,7 +90,7 @@ namespace fc { namespace http {
class websocket_tls_client
{
public:
websocket_tls_client();
websocket_tls_client( const std::string& ca_filename = "_default" );
~websocket_tls_client();
websocket_connection_ptr connect( const std::string& uri );

0
include/fc/network/ip.hpp Normal file → Executable file
View file

0
include/fc/network/ntp.hpp Normal file → Executable file
View file

0
include/fc/network/rate_limiting.hpp Normal file → Executable file
View file

0
include/fc/network/resolve.hpp Normal file → Executable file
View file

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