diff options
author | Riccardo Spagni <ric@spagni.net> | 2015-10-20 20:55:39 +0200 |
---|---|---|
committer | Riccardo Spagni <ric@spagni.net> | 2015-10-20 20:55:53 +0200 |
commit | 14dd279fe123d7b48baed82d9109c585839b678f (patch) | |
tree | a79e281f205a0578312aa3b7cfc9a488036b9078 /src/blocks | |
parent | Merge pull request #432 (diff) | |
parent | blockchain_export can now export to a blocks.dat format (diff) | |
download | monero-14dd279fe123d7b48baed82d9109c585839b678f.tar.xz |
Merge pull request #437
b13e7f2 blockchain_export can now export to a blocks.dat format (moneromooo-monero)
11db442 bootstrap_file: do not try to create a directory with an empty name (moneromooo-monero)
03bc610 hardfork: use DB transactions when reorganizing (moneromooo-monero)
439c455 hardfork: simplify work done on reload (moneromooo-monero)
Diffstat (limited to 'src/blocks')
-rw-r--r-- | src/blocks/CMakeLists.txt | 6 | ||||
-rw-r--r-- | src/blocks/blockexports.c | 34 | ||||
-rw-r--r-- | src/blocks/blocks.h | 4 | ||||
-rw-r--r-- | src/blocks/testnet_blocks.dat | 0 |
4 files changed, 31 insertions, 13 deletions
diff --git a/src/blocks/CMakeLists.txt b/src/blocks/CMakeLists.txt index 4020132a9..66512e7ab 100644 --- a/src/blocks/CMakeLists.txt +++ b/src/blocks/CMakeLists.txt @@ -30,9 +30,9 @@ if(APPLE) add_library(blocks STATIC blockexports.c) set_target_properties(blocks PROPERTIES LINKER_LANGUAGE C) else() - add_custom_command(OUTPUT blocks.o COMMAND cd ${CMAKE_CURRENT_SOURCE_DIR} && ld -r -b binary -o ${CMAKE_CURRENT_BINARY_DIR}/blocks.o blocks.dat) - add_library(blocks STATIC blocks.o blockexports.c) + add_custom_command(OUTPUT blocks.o COMMAND cd ${CMAKE_CURRENT_SOURCE_DIR} && ld -r -b binary -o ${CMAKE_CURRENT_BINARY_DIR}/blocks.o blocks.dat) + add_custom_command(OUTPUT testnet_blocks.o COMMAND cd ${CMAKE_CURRENT_SOURCE_DIR} && ld -r -b binary -o ${CMAKE_CURRENT_BINARY_DIR}/testnet_blocks.o testnet_blocks.dat) + add_library(blocks STATIC blocks.o testnet_blocks.o blockexports.c) set_target_properties(blocks PROPERTIES LINKER_LANGUAGE C) endif() - diff --git a/src/blocks/blockexports.c b/src/blocks/blockexports.c index cea72b299..3fa3d4d07 100644 --- a/src/blocks/blockexports.c +++ b/src/blocks/blockexports.c @@ -9,16 +9,22 @@ extern const struct mach_header _mh_execute_header; extern const struct mach_header_64 _mh_execute_header; #endif -const unsigned char *get_blocks_dat_start() +const unsigned char *get_blocks_dat_start(int testnet) { size_t size; - return getsectiondata(&_mh_execute_header, "__DATA", "__blocks_dat", &size); + if (testnet) + return getsectiondata(&_mh_execute_header, "__DATA", "__testnet_blocks_dat", &size); + else + return getsectiondata(&_mh_execute_header, "__DATA", "__blocks_dat", &size); } -size_t get_blocks_dat_size() +size_t get_blocks_dat_size(int testnet) { size_t size; - getsectiondata(&_mh_execute_header, "__DATA", "__blocks_dat", &size); + if (testnet) + getsectiondata(&_mh_execute_header, "__DATA", "__testnet_blocks_dat", &size); + else + getsectiondata(&_mh_execute_header, "__DATA", "__blocks_dat", &size); return size; } @@ -27,22 +33,34 @@ size_t get_blocks_dat_size() #if defined(_WIN32) && !defined(_WIN64) #define _binary_blocks_start binary_blocks_dat_start #define _binary_blocks_end binary_blocks_dat_end +#define _binary_testnet_blocks_start binary_testnet_blocks_dat_start +#define _binary_testnet_blocks_end binary_testnet_blocks_dat_end #else #define _binary_blocks_start _binary_blocks_dat_start #define _binary_blocks_end _binary_blocks_dat_end +#define _binary_testnet_blocks_start _binary_testnet_blocks_dat_start +#define _binary_testnet_blocks_end _binary_testnet_blocks_dat_end #endif extern const unsigned char _binary_blocks_start[]; extern const unsigned char _binary_blocks_end[]; +extern const unsigned char _binary_testnet_blocks_start[]; +extern const unsigned char _binary_testnet_blocks_end[]; -const unsigned char *get_blocks_dat_start(void) +const unsigned char *get_blocks_dat_start(int testnet) { - return _binary_blocks_start; + if (testnet) + return _binary_testnet_blocks_start; + else + return _binary_blocks_start; } -size_t get_blocks_dat_size(void) +size_t get_blocks_dat_size(int testnet) { - return (size_t) (_binary_blocks_end - _binary_blocks_start); + if (testnet) + return (size_t) (_binary_testnet_blocks_end - _binary_testnet_blocks_start); + else + return (size_t) (_binary_blocks_end - _binary_blocks_start); } #endif diff --git a/src/blocks/blocks.h b/src/blocks/blocks.h index 76a08c89d..b842009a4 100644 --- a/src/blocks/blocks.h +++ b/src/blocks/blocks.h @@ -5,8 +5,8 @@ extern "C" { #endif -const unsigned char *get_blocks_dat_start(); -size_t get_blocks_dat_size(); +const unsigned char *get_blocks_dat_start(int testnet); +size_t get_blocks_dat_size(int testnet); #ifdef __cplusplus } diff --git a/src/blocks/testnet_blocks.dat b/src/blocks/testnet_blocks.dat new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/src/blocks/testnet_blocks.dat |