aboutsummaryrefslogtreecommitdiff
path: root/src/blocks/blockexports.c
diff options
context:
space:
mode:
authormoneromooo-monero <moneromooo-monero@users.noreply.github.com>2015-10-16 19:45:35 +0100
committermoneromooo-monero <moneromooo-monero@users.noreply.github.com>2015-10-17 00:11:26 +0100
commitb13e7f284b909df8ca54fe93c231910a130f9f3e (patch)
treea79e281f205a0578312aa3b7cfc9a488036b9078 /src/blocks/blockexports.c
parentbootstrap_file: do not try to create a directory with an empty name (diff)
downloadmonero-b13e7f284b909df8ca54fe93c231910a130f9f3e.tar.xz
blockchain_export can now export to a blocks.dat format
Also make the number of blocks endian independant, and add support for testnet
Diffstat (limited to 'src/blocks/blockexports.c')
-rw-r--r--src/blocks/blockexports.c34
1 files changed, 26 insertions, 8 deletions
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