Skip to content

Commit

Permalink
Commit 1
Browse files Browse the repository at this point in the history
Turtlecoin repo
  • Loading branch information
bobbieltd committed May 29, 2019
1 parent 6228e39 commit 5067b50
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 52 deletions.
2 changes: 1 addition & 1 deletion .appveyor.yml
Expand Up @@ -16,7 +16,7 @@ before_build:
build_script:
- md build
- cd build
- cmake -G "Visual Studio 15 2017 Win64" .. -DARCH=default -DOPENSSL_ROOT_DIR=C:\OpenSSL-v111-Win64
- cmake -G "Visual Studio 15 2017 Win64" .. -DOPENSSL_ROOT_DIR=C:\OpenSSL-v111-Win64
- MSBuild TurtleCoin.sln /p:CLToolExe=clcache.exe /p:CLToolPath=c:\Python37\Scripts\ /p:Configuration=Release /m
- src\Release\cryptotest.exe

Expand Down
2 changes: 1 addition & 1 deletion .travis.yml
Expand Up @@ -126,7 +126,7 @@ script:
# we do this in the script stage because this happens after the repo is cloned
- if [[ "$LABEL" == "aarch64" ]]; then source scripts/prep-aarch64.sh ; fi
- mkdir build && cd build
- cmake -DARCH=default -DCMAKE_BUILD_TYPE=Release -DSTATIC=true ..
- cmake -DCMAKE_BUILD_TYPE=Release -DSTATIC=true ..
- make -j2
- if [[ "$LABEL" != "aarch64" ]]; then ./src/cryptotest ; fi

Expand Down
15 changes: 11 additions & 4 deletions CMakeLists.txt
Expand Up @@ -9,7 +9,6 @@ endif()

set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build, options are: Debug, Release, RelWithDebInfo")
set(CMAKE_CONFIGURATION_TYPES Debug RelWithDebInfo Release CACHE TYPE INTERNAL)
set(ARCH native CACHE STRING "CPU to build for: -march value or native")

project(BitcoinMono)

Expand Down Expand Up @@ -53,13 +52,20 @@ set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

## This section is specifically for RocksDB build options that we've disabled for maximum portability
set(ENABLE_AVX OFF CACHE STRING "Enable RocksDB AVX/AVX2? Defaults to OFF")
set(ENABLE_LEAF_FRAME OFF CACHE STRING "Enable RocksDB OMIT_LEAF_FRAME_POINTER detection? Defaults to OFF")
set(ENABLE_SSE42 OFF CACHE STRING "Enable RocksDB SSE4.2 support detection? Defaults to OFF")
set(ENABLE_THREAD_LOCAL OFF CACHE STRING "Enable RocksDB THREAD_LOCAL support detection? Defaults to OFF")
set(ENABLE_SYNC_FILE_RANGE_WRITE OFF CACHE STRING "Enable RocksDB SYNC_FILE_RANGE_WRITE support detection? Defaults to OFF")
set(ENABLE_PTHREAD_MUTEX_ADAPTIVE_NP OFF CACHE STRING "Enable RocksDB PTHREAD_MUTEX_ADAPTIVE_NP support detection? Defaults to OFF")
set(ENABLE_MALLOC_USABLE_SIZE OFF CACHE STRING "Enable RocksDB MALLOC_USABLE_SIZE support detection? Defaults to OFF")
set(ENABLE_SCHED_GETCPU OFF CACHE STRING "Enable RocksDB SCHED_GETCPU support detection? Defaults to OFF")
## This section is for settings found in the slow-hash routine(s) that may benefit some systems (mostly ARM)
set(FORCE_USE_HEAP ON CACHE BOOL "Force the use of heap memory allocation")
set(NO_AES OFF CACHE BOOL "Turn off Hardware AES instructions?")
set(NO_OPTIMIZED_MULTIPLY_ON_ARM OFF CACHE BOOL "Turn off Optimized Multiplication on ARM?")

message(STATUS "Building for target architecture: ${ARCH}")

if(FORCE_USE_HEAP)
add_definitions(-DFORCE_USE_HEAP)
message(STATUS "FORCE_USE_HEAP: ENABLED")
Expand Down Expand Up @@ -152,6 +158,7 @@ if(NOT MSVC)
endif()

## This is here to support building for multiple architecture types... but we all know how well that usually goes...
set(ARCH default CACHE STRING "CPU to build for: -march value or default")
if("${ARCH}" STREQUAL "default")
set(ARCH_FLAG "")
else()
Expand Down Expand Up @@ -288,7 +295,7 @@ add_subdirectory(src)
## We need to setup the RocksDB build environment to match our system
if(NOT MSVC)
execute_process(
COMMAND cmake ${CMAKE_CURRENT_SOURCE_DIR}/external/rocksdb -DARCH=${ARCH} -DWITH_LZ4=ON -DWITH_GFLAGS=0 -DCMAKE_BUILD_TYPE=MinSizeRel -DWITH_TESTS=OFF -DWITH_TOOLS=OFF -DPORTABLE=ON -B${PROJECT_BINARY_DIR}/rocksdb
COMMAND cmake ${CMAKE_CURRENT_SOURCE_DIR}/external/rocksdb -DWITH_LZ4=ON -DWITH_GFLAGS=0 -DCMAKE_BUILD_TYPE=MinSizeRel -DWITH_TESTS=OFF -DWITH_TOOLS=OFF -DPORTABLE=ON -B${PROJECT_BINARY_DIR}/rocksdb
)
set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${PROJECT_BINARY_DIR}/rocksdb/librocksdb.a")
endif()
23 changes: 10 additions & 13 deletions external/rocksdb/CMakeLists.txt
Expand Up @@ -34,8 +34,6 @@

cmake_minimum_required(VERSION 2.8.12)

message(STATUS "Setting up build environment for RocksDB")

find_program(CCACHE_PROGRAM ccache)
if(CCACHE_PROGRAM)
message(STATUS "Found ccache package... Activating...")
Expand All @@ -53,7 +51,6 @@ endif()

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake/modules/")

set(ARCH native CACHE STRING "CPU to build for: -march value or native")
option(WITH_JEMALLOC "build with JeMalloc" OFF)
option(WITH_SNAPPY "build with SNAPPY" OFF)
option(WITH_LZ4 "build with lz4" OFF)
Expand All @@ -65,7 +62,7 @@ if(MSVC)
option(WITH_GFLAGS "build with GFlags" OFF)
option(WITH_XPRESS "build with windows built in compression" OFF)
include(${CMAKE_CURRENT_SOURCE_DIR}/thirdparty.inc)

if(WITH_LZ4)
SET(LZ4_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../lz4")
SET(LZ4_LIBRARIES lz4)
Expand Down Expand Up @@ -191,7 +188,7 @@ else()
if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-omit-frame-pointer")
include(CheckCXXCompilerFlag)
if(NOT "${ARCH}" STREQUAL "default")
if(ENABLE_LEAF_FRAME)
CHECK_CXX_COMPILER_FLAG("-momit-leaf-frame-pointer" HAVE_OMIT_LEAF_FRAME_POINTER)
if(HAVE_OMIT_LEAF_FRAME_POINTER)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -momit-leaf-frame-pointer")
Expand Down Expand Up @@ -237,7 +234,7 @@ else()
endif()

include(CheckCXXSourceCompiles)
if(NOT "${ARCH}" STREQUAL "default")
if(ENABLE_SSE42)
if(NOT MSVC)
set(CMAKE_REQUIRED_FLAGS "-msse4.2 -mpclmul")
endif()
Expand All @@ -262,7 +259,7 @@ if(NOT "${ARCH}" STREQUAL "default")
endif()
endif()

if(NOT "${ARCH}" STREQUAL "default")
if(ENABLE_THREAD_LOCAL)
CHECK_CXX_SOURCE_COMPILES("
#if defined(_MSC_VER) && !defined(__thread)
#define __thread __declspec(thread)
Expand Down Expand Up @@ -439,7 +436,7 @@ int main() {
endif()
endif()

if(NOT "${ARCH}" STREQUAL "default")
if(ENABLE_SYNC_FILE_RANGE_WRITE)
CHECK_CXX_SOURCE_COMPILES("
#include <fcntl.h>
int main() {
Expand All @@ -452,7 +449,7 @@ if(NOT "${ARCH}" STREQUAL "default")
endif()
endif()

if(NOT "${ARCH}" STREQUAL "default")
if(ENABLE_PTHREAD_MUTEX_ADAPTIVE_NP)
CHECK_CXX_SOURCE_COMPILES("
#include <pthread.h>
int main() {
Expand All @@ -465,14 +462,14 @@ if(NOT "${ARCH}" STREQUAL "default")
endif()

include(CheckCXXSymbolExists)
if(NOT "${ARCH}" STREQUAL "default")
if(ENABLE_MALLOC_USABLE_SIZE)
check_cxx_symbol_exists(malloc_usable_size malloc.h HAVE_MALLOC_USABLE_SIZE)
if(HAVE_MALLOC_USABLE_SIZE)
add_definitions(-DROCKSDB_MALLOC_USABLE_SIZE)
endif()
endif()

if(NOT "${ARCH}" STREQUAL "default")
if(ENABLE_SCHED_GETCPU)
check_cxx_symbol_exists(sched_getcpu sched.h HAVE_SCHED_GETCPU)
if(HAVE_SCHED_GETCPU)
add_definitions(-DROCKSDB_SCHED_GETCPU_PRESENT)
Expand Down Expand Up @@ -1099,9 +1096,9 @@ if(MSVC)
string (REPLACE "/arch:AVX2" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
string (REPLACE "/arch:AVX" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})

if(NOT "${ARCH}" STREQUAL "default")
if(ENABLE_AVX)
include(CheckCXXSourceRuns)

# Check AVX
check_cxx_source_runs("
#include <immintrin.h>
Expand Down
33 changes: 0 additions & 33 deletions include/WalletTypes.h
Expand Up @@ -49,14 +49,6 @@ namespace WalletTypes
CRYPTONOTE_MAX_BLOCK_NUMBER (In cryptonoteconfig) it is treated
as a unix timestamp, else it is treated as a block height. */
uint64_t unlockTime;

size_t memoryUsage() const
{
return keyOutputs.size() * sizeof(KeyOutput) + sizeof(keyOutputs) +
sizeof(hash) +
sizeof(transactionPublicKey) +
sizeof(unlockTime);
}
};

/* A raw transaction, simply key images and amounts */
Expand All @@ -68,13 +60,6 @@ namespace WalletTypes
/* The inputs used for a transaction, can be used to track outgoing
transactions */
std::vector<CryptoNote::KeyInput> keyInputs;

size_t memoryUsage() const
{
return paymentID.size() * sizeof(char) + sizeof(paymentID) +
keyInputs.size() * sizeof(CryptoNote::KeyInput) + sizeof(keyInputs) +
RawCoinbaseTransaction::memoryUsage();
}
};

/* A 'block' with the very basics needed to sync the transactions */
Expand All @@ -94,24 +79,6 @@ namespace WalletTypes

/* The timestamp of the block */
uint64_t blockTimestamp;

size_t memoryUsage() const
{
const size_t txUsage = std::accumulate(
transactions.begin(),
transactions.end(),
sizeof(transactions),
[](const auto acc, const auto item) {

return acc + item.memoryUsage();
});

return coinbaseTransaction.memoryUsage() +
txUsage +
sizeof(blockHeight) +
sizeof(blockHash) +
sizeof(blockTimestamp);
}
};

struct TransactionInput
Expand Down

0 comments on commit 5067b50

Please sign in to comment.