Skip to content

Commit 5204521

Browse files
committed
Add Microbadger badge
2 parents 463c8c9 + 4b926b0 commit 5204521

File tree

128 files changed

+6839
-3806
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

128 files changed

+6839
-3806
lines changed

CMakeLists.txt

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,14 @@ if(USE_SQLITE)
3939
# Requires dl on Linux, we add it unconditionally for simplicity.
4040
message(STATUS "Database selected: SQLite 3. Make sure it is put into ../sqlite/")
4141
include_directories(../sqlite)
42-
set(SRC_DB ../sqlite/sqlite3.c src/platform/DBsqlite3.cpp src/platform/DBsqlite3.hpp)
42+
set(SRC_WARNINGS_DB ../sqlite/sqlite3.c)
43+
set(SRC_DB src/platform/DBsqlite3.cpp src/platform/DBsqlite3.hpp)
4344
add_definitions(-Dplatform_USE_SQLITE=1)
4445
else()
4546
message(STATUS "Database selected: LMDB. Make sure it is put into ../lmdb/")
4647
include_directories(../lmdb/libraries/liblmdb)
47-
set(SRC_DB ../lmdb/libraries/liblmdb/mdb.c ../lmdb/libraries/liblmdb/midl.c src/platform/DBlmdb.cpp src/platform/DBlmdb.hpp)
48+
set(SRC_WARNINGS_DB ../lmdb/libraries/liblmdb/mdb.c ../lmdb/libraries/liblmdb/midl.c)
49+
set(SRC_DB src/platform/DBlmdb.cpp src/platform/DBlmdb.hpp)
4850
endif()
4951
if(USE_SSL)
5052
message(STATUS "SSL usage: ON. Make sure openssl headers are in " ${OPENSSL_ROOT} "/include and static libs are in " ${OPENSSL_ROOT} "/")
@@ -81,32 +83,36 @@ file(GLOB SRC_SERIALIZATION src/Serialization/*.cpp src/Serialization/*.hpp)
8183
file(GLOB SRC_SERIA src/seria/*.cpp src/seria/*.hpp)
8284
file(GLOB SRC_LOGGING src/logging/*.cpp src/logging/*.hpp)
8385
file(GLOB SRC_P2P src/p2p/*.cpp src/p2p/*.hpp)
84-
file(GLOB SRC_CORE src/Core/*.cpp src/Core/*.hpp src/Core/*.h)
86+
file(GLOB SRC_CORE src/Core/*.cpp src/Core/*.hpp)
8587
file(GLOB SRC_HTTP src/http/*.cpp src/http/*.hpp)
8688
file(GLOB SRC_PLATFORM
8789
src/platform/ExclusiveLock.cpp src/platform/ExclusiveLock.hpp
8890
src/platform/Files.cpp src/platform/Files.hpp
91+
src/platform/Time.cpp src/platform/Time.hpp
8992
src/platform/Network.cpp src/platform/Network.hpp
9093
src/platform/PathTools.cpp src/platform/PathTools.hpp
9194
src/platform/PreventSleep.cpp src/platform/PreventSleep.hpp
9295
src/platform/Windows.hpp src/platform/DB.hpp
9396
)
9497
if(WIN32)
9598
set_property(SOURCE ${SRC_CRYPTO} PROPERTY COMPILE_FLAGS -Ot)
96-
set_property(SOURCE ${SRC_DB} PROPERTY COMPILE_FLAGS "-Ot -w")
99+
set_property(SOURCE ${SRC_DB} PROPERTY COMPILE_FLAGS -Ot)
100+
set_property(SOURCE ${SRC_WARNINGS_DB} PROPERTY COMPILE_FLAGS "-Ot -w")
97101
set_property(SOURCE ${SRC_COMMON} PROPERTY COMPILE_FLAGS -Ot)
98102
set_property(SOURCE ${SRC_SERIALIZATION} PROPERTY COMPILE_FLAGS -Ot)
99103
set_property(SOURCE ${SRC_SERIA} PROPERTY COMPILE_FLAGS -Ot)
100104
else()
101105
set_property(SOURCE ${SRC_CRYPTO} PROPERTY COMPILE_FLAGS -O3)
102-
set_property(SOURCE ${SRC_DB} PROPERTY COMPILE_FLAGS "-O3 -w")
106+
set_property(SOURCE ${SRC_DB} PROPERTY COMPILE_FLAGS -O3)
107+
set_property(SOURCE ${SRC_WARNINGS_DB} PROPERTY COMPILE_FLAGS "-O3 -w")
103108
set_property(SOURCE ${SRC_COMMON} PROPERTY COMPILE_FLAGS -O3)
104109
set_property(SOURCE ${SRC_SERIALIZATION} PROPERTY COMPILE_FLAGS -O3)
105110
set_property(SOURCE ${SRC_SERIA} PROPERTY COMPILE_FLAGS -O3)
106111
endif()
107112
include_directories(src)
108113
set(SOURCE_FILES
109114
${SRC_DB}
115+
${SRC_WARNINGS_DB}
110116
${SRC_COMMON}
111117
${SRC_HTTP}
112118
${SRC_CORE}
@@ -140,10 +146,12 @@ else()
140146
add_executable(walletd src/main_walletd.cpp)
141147
add_executable(bytecoind src/main_bytecoind.cpp)
142148
endif()
143-
add_executable(tests src/main_tests.cpp tests/io.hpp
149+
add_executable(tests src/main_tests.cpp tests/io.hpp tests/Random.hpp
150+
tests/blockchain/test_blockchain.cpp tests/blockchain/test_blockchain.hpp
144151
tests/crypto/test_crypto.cpp tests/crypto/test_crypto.hpp
145152
tests/hash/test_hash.cpp tests/hash/test_hash.hpp
146153
tests/json/test_json.cpp tests/json/test_json.hpp
154+
tests/wallet_state/test_wallet_state.cpp tests/wallet_state/test_wallet_state.hpp
147155
tests/wallet_file/test_wallet_file.cpp tests/wallet_file/test_wallet_file.hpp)
148156
set(Boost_USE_STATIC_LIBS ON)
149157
add_definitions(-DBOOST_BIND_NO_PLACEHOLDERS=1 -DBOOST_CONFIG_SUPPRESS_OUTDATED_MESSAGE=1) # boost::_1 conflicts with std::_1

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,19 @@ Contents
1010
* Building on Windows
1111
* Building on other platforms
1212

13+
14+
## Docker image
15+
16+
[![](https://images.microbadger.com/badges/image/homdx/bytecoin.svg)](https://microbadger.com/images/homdx/bytecoin "Get your own image badge on microbadger.com")
17+
18+
[![](https://images.microbadger.com/badges/version/homdx/bytecoin.svg)](https://microbadger.com/images/homdx/bytecoin "Get your own version badge on microbadger.com")
19+
20+
- docker pull homdx/bytecoin
21+
22+
### You can check the result and build logs
23+
https://hub.docker.com/r/homdx/bytecoin/
24+
25+
1326
## Building on Linux 64-bit
1427

1528
All commands below are adapted for Ubuntu, other distributions may need an other command set.
@@ -255,3 +268,4 @@ Currently it is impossible to run Bytecoin on any Big-Endian platform, due to lo
255268
## Building with parameters
256269
257270
If you want to use tools like `clang-tidy`, run `cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON ..` instead of `cmake ..`
271+

ReleaseNotes.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,32 @@
11
## Release Notes
22

3+
### v3.2.0
4+
5+
- *Warning:* This version uses different format of `bytecoind` database and `walletd` caches, they will be upgraded to the new format on a first start of daemons. Prepare for downtime of up to 2 hours depending on your wallet size and computer performance.
6+
- __API change:__ Renamed methods `create_send_proof` and `check_send_proof` to `create_sendproof` and `check_sendproof` respectively (along with input parameter `send_proof` that became `sendproof`).
7+
- Fixed minor bugs found in the beta release.
8+
9+
### v3.2.0-beta-20180723
10+
11+
- *Warning:* This version uses different format of `bytecoind` database and `walletd` caches, they will be upgraded to the new format on a first start of daemons. Prepare for downtime of up to 2 hours depending on your wallet size and computer performance.
12+
- Reworked the wallet cache storage to use 3x less space and run 2x faster.
13+
- Intoduced the 'payment queue' which stores and resends all sent transactions until they are successfully confirmed. This fixes issues with sent transactions lost due to chain reorganizations under high loads.
14+
- Changed the logic of the `send_transaction` method: It never returns an error, its result is always `broadcast` because all transactions are first stored in the payment queue and later sent for sure.
15+
- Improved the downloader to reduce sync times.
16+
- Made the `params` argument optional in all JSON RPC calls according to the spec.
17+
- Improved error handling in the `create_transaction` and `send_transaction` methods (distinct error codes for common errors).
18+
- Fixed issue when requests to `walletd` with address is not in the wallet (it now fails with an appopriate error).
19+
- Changed the mechanism of the memory pool size adjustment to give miners more freedom in selecting transactions for including in blocks.
20+
- The `walletd` command line parameter `--backup-wallet` is renamed to `--backup-wallet-data` and now it makes a hot backup of the wallet cache, wallet history, and payment queue in bulk (backward compatibility is maintained).
21+
- Extended the number of bits of the cumulative difficulty parameter (it is now 128 bits).
22+
- Made entering passwords in terminals/consoles invisible on all major platforms.
23+
- Allowed entered passwords to contain Unicode characters on Windows (not recommended though).
24+
- Changed the logic of the `create_addresses` method when called with at least one existing spend key and without setting `creation_timestamp` (or setting it to `0`). `walletd` will perform rescan of the whole blockchain in this case.
25+
- Added a better error message when `walletd` fails to be authenticated at `bytecoind`.
26+
- Started versioning binary API methods for better detection of changes.
27+
328
### v3.1.1
29+
430
- Added `--backup-blockchain` `--backup-wallet` command-line flags to `bytecoind` and `walletd` resp. to hot-copy blockchain and wallet data (wallet file and wallet cache).
531
- Fixed behavior of the `walletd`'s methods such as `get_balance`, which until now returned zero balance for addresses not belonging to the opened wallet file.
632

244 KB
Binary file not shown.

src/Core/Archive.cpp

Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
// Copyright (c) 2012-2018, The CryptoNote developers, The Bytecoin developers.
2+
// Licensed under the GNU Lesser General Public License. See LICENSE for details.
3+
4+
#include "Archive.hpp"
5+
#include <boost/lexical_cast.hpp>
6+
#include <iostream>
7+
#include "CryptoNoteTools.hpp"
8+
#include "Currency.hpp"
9+
#include "common/StringTools.hpp"
10+
#include "common/Varint.hpp"
11+
#include "crypto/crypto.hpp"
12+
#include "platform/Time.hpp"
13+
#include "seria/BinaryInputStream.hpp"
14+
#include "seria/BinaryOutputStream.hpp"
15+
16+
using namespace bytecoin;
17+
using namespace platform;
18+
19+
static const std::string RECORDS_PREFIX = "r";
20+
static const std::string HASHES_PREFIX = "h";
21+
22+
const std::string Archive::BLOCK("b");
23+
const std::string Archive::TRANSACTION("t");
24+
const std::string Archive::CHECKPOINT("c");
25+
26+
Archive::Archive(bool read_only, const std::string &path) : read_only(read_only) {
27+
try {
28+
m_db = std::make_unique<DB>(read_only, path);
29+
if (!m_db->get("$unique_id", unique_id)) {
30+
DB::Cursor cur = m_db->begin(std::string());
31+
if (!cur.end())
32+
throw std::runtime_error("Archive database format unknown version, please delete " + m_db->get_path());
33+
unique_id = common::pod_to_hex(crypto::random_keypair().public_key);
34+
m_db->put("$unique_id", unique_id, true);
35+
std::cout << "Created archive with unique id: " << unique_id << std::endl;
36+
}
37+
DB::Cursor cur2 = m_db->rbegin(RECORDS_PREFIX);
38+
next_record_id = cur2.end() ? 0 : 1 + common::read_varint_sqlite4(cur2.get_suffix());
39+
} catch (const std::exception &) {
40+
if (read_only)
41+
m_db = nullptr;
42+
else
43+
throw;
44+
}
45+
}
46+
47+
// struct Record {
48+
// std::string type;
49+
// BinaryArray data;
50+
// Timestamp timestamp;
51+
//};
52+
53+
void Archive::add(const std::string &type,
54+
const BinaryArray &data,
55+
const Hash &hash,
56+
const std::string &source_address) {
57+
if (!m_db || read_only || source_address.empty())
58+
return;
59+
std::cout << "Adding to archive: " << type << " hash=" << hash << " size=" << data.size()
60+
<< " source_address=" << source_address << std::endl;
61+
auto hash_key = HASHES_PREFIX + DB::to_binary_key(hash.data, sizeof(hash.data));
62+
DB::Value value;
63+
if (!m_db->get(hash_key, value))
64+
m_db->put(hash_key, data, true);
65+
api::bytecoind::GetArchive::ArchiveRecord rec;
66+
rec.timestamp = now_unix_timestamp(&rec.timestamp_usec);
67+
rec.type = type;
68+
rec.hash = hash;
69+
rec.source_address = source_address;
70+
m_db->put(RECORDS_PREFIX + common::write_varint_sqlite4(next_record_id), seria::to_binary(rec), true);
71+
next_record_id += 1;
72+
}
73+
74+
void Archive::db_commit() {
75+
if (!m_db || read_only)
76+
return;
77+
m_db->commit_db_txn();
78+
}
79+
80+
void Archive::read_archive(api::bytecoind::GetArchive::Request &&req, api::bytecoind::GetArchive::Response &resp) {
81+
if (req.archive_id != unique_id) {
82+
api::bytecoind::GetArchive::Error err;
83+
err.code = api::bytecoind::GetArchive::WRONG_ARCHIVE_ID;
84+
err.message = "Archive id changed";
85+
err.archive_id = unique_id;
86+
throw err;
87+
}
88+
resp.from_record = req.from_record;
89+
if (resp.from_record > next_record_id)
90+
resp.from_record = next_record_id;
91+
if (req.max_count > api::bytecoind::GetArchive::Request::MAX_COUNT)
92+
req.max_count = api::bytecoind::GetArchive::Request::MAX_COUNT;
93+
if (!m_db)
94+
return;
95+
resp.records.reserve(static_cast<size_t>(req.max_count));
96+
for (DB::Cursor cur = m_db->begin(RECORDS_PREFIX, common::write_varint_sqlite4(resp.from_record)); !cur.end();
97+
cur.next()) {
98+
if (resp.records.size() >= req.max_count)
99+
break;
100+
api::bytecoind::GetArchive::ArchiveRecord rec;
101+
seria::from_binary(rec, cur.get_value_array());
102+
resp.records.push_back(rec);
103+
std::string str_hash = common::pod_to_hex(rec.hash);
104+
const auto hash_key = HASHES_PREFIX + DB::to_binary_key(rec.hash.data, sizeof(rec.hash.data));
105+
if (rec.type == BLOCK) {
106+
if (resp.blocks.count(str_hash) == 0) {
107+
BinaryArray data;
108+
invariant(m_db->get(hash_key, data), "");
109+
api::bytecoind::GetArchive::ArchiveBlock &bl = resp.blocks[str_hash];
110+
RawBlock raw_block;
111+
seria::from_binary(raw_block, data);
112+
Block block;
113+
invariant(block.from_raw_block(raw_block), "");
114+
bl.raw_header = block.header;
115+
bl.raw_transactions.reserve(block.transactions.size());
116+
for (size_t i = 0; i != block.transactions.size(); ++i) {
117+
bl.raw_transactions.push_back(static_cast<TransactionPrefix &>(block.transactions.at(i)));
118+
bl.transaction_binary_sizes.push_back(static_cast<uint32_t>(raw_block.transactions.at(i).size()));
119+
}
120+
bl.base_transaction_hash = get_transaction_hash(block.header.base_transaction);
121+
}
122+
}
123+
if (rec.type == TRANSACTION) {
124+
if (resp.transactions.count(str_hash) == 0) {
125+
BinaryArray data;
126+
invariant(m_db->get(hash_key, data), "");
127+
TransactionPrefix &tr = resp.transactions[str_hash];
128+
Transaction transaction;
129+
seria::from_binary(transaction, data);
130+
tr = static_cast<TransactionPrefix &>(transaction);
131+
}
132+
}
133+
if (rec.type == CHECKPOINT) {
134+
if (resp.checkpoints.count(str_hash) == 0) {
135+
BinaryArray data;
136+
invariant(m_db->get(hash_key, data), "");
137+
SignedCheckPoint &ch = resp.checkpoints[str_hash];
138+
seria::from_binary(ch, data);
139+
}
140+
}
141+
}
142+
}

src/Core/Archive.hpp

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// Copyright (c) 2012-2018, The CryptoNote developers, The Bytecoin developers.
2+
// Licensed under the GNU Lesser General Public License. See LICENSE for details.
3+
4+
#pragma once
5+
6+
#include "platform/DB.hpp"
7+
#include "rpc_api.hpp"
8+
9+
namespace bytecoin {
10+
11+
class Archive {
12+
const bool read_only;
13+
std::unique_ptr<platform::DB> m_db;
14+
uint64_t next_record_id = 0;
15+
std::string unique_id;
16+
17+
public:
18+
explicit Archive(bool read_only, const std::string &path);
19+
std::string get_unique_id() const { return unique_id; }
20+
void add(
21+
const std::string &type, const common::BinaryArray &data, const Hash &hash, const std::string &source_address);
22+
void read_archive(api::bytecoind::GetArchive::Request &&req, api::bytecoind::GetArchive::Response &resp);
23+
void db_commit();
24+
25+
static const std::string BLOCK;
26+
static const std::string TRANSACTION;
27+
static const std::string CHECKPOINT;
28+
};
29+
30+
} // namespace bytecoin

0 commit comments

Comments
 (0)