From 2804a5dc2f2a3effaffc65a5436f3fb6b1da0b73 Mon Sep 17 00:00:00 2001 From: Jowen Date: Tue, 19 Jun 2018 13:50:01 +0800 Subject: [PATCH] replace \t with 4 spaces, and trim spaces at the end of line. --- include/metaverse/bitcoin.hpp | 2 +- .../attachment/asset/blockchain_asset.hpp | 30 +- .../chain/attachment/did/blockchain_did.hpp | 32 +- .../bitcoin/chain/attachment/did/did.hpp | 28 +- .../bitcoin/chain/attachment/etp/etp.hpp | 12 +- .../chain/attachment/etp/etp_award.hpp | 12 +- .../chain/attachment/message/message.hpp | 12 +- .../chain/attachment/variant_visitor.hpp | 128 +- .../metaverse/bitcoin/chain/script/script.hpp | 6 +- .../metaverse/bitcoin/chain/transaction.hpp | 14 +- .../metaverse/bitcoin/config/authority.hpp | 20 +- .../metaverse/bitcoin/config/checkpoint.hpp | 22 +- include/metaverse/bitcoin/config/endpoint.hpp | 24 +- include/metaverse/bitcoin/config/hash256.hpp | 4 +- .../metaverse/bitcoin/config/parameter.hpp | 4 +- include/metaverse/bitcoin/config/parser.hpp | 2 +- include/metaverse/bitcoin/config/printer.hpp | 14 +- include/metaverse/bitcoin/config/sodium.hpp | 4 +- include/metaverse/bitcoin/define.hpp | 2 +- .../metaverse/bitcoin/impl/math/checksum.ipp | 2 +- .../metaverse/bitcoin/impl/utility/track.ipp | 6 +- .../metaverse/bitcoin/math/elliptic_curve.hpp | 2 +- include/metaverse/bitcoin/math/uint256.hpp | 8 +- .../bitcoin/message/network_address.hpp | 32 +- include/metaverse/bitcoin/message/version.hpp | 2 +- .../metaverse/bitcoin/unicode/ifstream.hpp | 2 +- include/metaverse/bitcoin/unicode/unicode.hpp | 8 +- .../bitcoin/unicode/unicode_istream.hpp | 4 +- .../bitcoin/unicode/unicode_ostream.hpp | 2 +- .../bitcoin/utility/container_source.hpp | 2 +- include/metaverse/bitcoin/utility/data.hpp | 2 +- .../metaverse/bitcoin/utility/deadline.hpp | 2 +- .../metaverse/bitcoin/utility/delegates.hpp | 2 +- .../bitcoin/utility/istream_reader.hpp | 2 +- include/metaverse/bitcoin/utility/log.hpp | 2 +- include/metaverse/bitcoin/utility/logging.hpp | 8 +- include/metaverse/bitcoin/utility/path.hpp | 4 +- .../metaverse/bitcoin/utility/serializer.hpp | 2 +- .../metaverse/bitcoin/utility/threadpool.hpp | 4 +- include/metaverse/bitcoin/utility/timer.hpp | 2 +- include/metaverse/bitcoin/utility/work.hpp | 2 +- .../metaverse/bitcoin/wallet/ek_private.hpp | 2 +- include/metaverse/bitcoin/wallet/ek_token.hpp | 2 +- .../bitcoin/wallet/encrypted_keys.hpp | 12 +- .../metaverse/bitcoin/wallet/hd_public.hpp | 2 +- include/metaverse/bitcoin/wallet/message.hpp | 2 +- .../bitcoin/wallet/payment_address.hpp | 2 +- .../bitcoin/wallet/stealth_address.hpp | 2 +- include/metaverse/blockchain.hpp | 2 +- .../metaverse/blockchain/transaction_pool.hpp | 2 +- include/metaverse/client.hpp | 2 +- include/metaverse/client/define.hpp | 4 +- include/metaverse/consensus.hpp | 2 +- include/metaverse/consensus/consensus.hpp | 2 +- include/metaverse/consensus/export.hpp | 12 +- .../metaverse/consensus/libdevcore/Base64.h | 34 +- .../consensus/libdevcore/BasicType.h | 78 +- .../metaverse/consensus/libdevcore/Common.h | 170 +- .../consensus/libdevcore/CommonData.h | 236 +-- .../metaverse/consensus/libdevcore/CommonIO.h | 200 +-- .../consensus/libdevcore/Exceptions.h | 28 +- .../consensus/libdevcore/FixedHash.h | 532 +++--- .../metaverse/consensus/libdevcore/Guards.h | 96 +- include/metaverse/consensus/libdevcore/Log.h | 290 ++-- include/metaverse/consensus/libdevcore/RLP.h | 704 ++++---- include/metaverse/consensus/libdevcore/SHA3.h | 22 +- .../metaverse/consensus/libdevcore/Terminal.h | 124 +- .../metaverse/consensus/libdevcore/picosha2.h | 416 ++--- .../consensus/libdevcore/vector_ref.h | 164 +- .../consensus/libethash/data_sizes.h | 1474 ++++++++--------- .../metaverse/consensus/libethash/endian.h | 24 +- .../metaverse/consensus/libethash/ethash.h | 22 +- include/metaverse/consensus/libethash/fnv.h | 2 +- .../metaverse/consensus/libethash/internal.c | 760 ++++----- .../metaverse/consensus/libethash/internal.h | 96 +- include/metaverse/consensus/libethash/io.c | 166 +- include/metaverse/consensus/libethash/io.h | 46 +- .../metaverse/consensus/libethash/io_posix.c | 106 +- .../metaverse/consensus/libethash/io_win32.c | 82 +- .../consensus/libethash/mmap_win32.c | 92 +- include/metaverse/consensus/libethash/sha3.c | 192 +-- include/metaverse/consensus/libethash/sha3.h | 6 +- include/metaverse/consensus/libethash/util.c | 10 +- include/metaverse/consensus/libethash/util.h | 4 +- .../consensus/libethash/util_win32.c | 12 +- include/metaverse/consensus/miner/MinerAux.h | 20 +- include/metaverse/database.hpp | 2 +- .../databases/account_address_database.hpp | 18 +- .../databases/address_did_database.hpp | 88 +- .../database/databases/asset_database.hpp | 10 +- .../database/databases/block_database.hpp | 8 +- .../databases/blockchain_did_database.hpp | 12 +- .../database/impl/hash_table_header.ipp | 6 +- .../database/impl/record_hash_table.ipp | 8 +- .../database/impl/record_multimap.ipp | 12 +- .../database/impl/slab_hash_table.ipp | 16 +- include/metaverse/database/impl/slab_row.ipp | 4 +- .../database/primitives/record_hash_table.hpp | 2 +- .../database/primitives/record_multimap.hpp | 2 +- .../database/primitives/slab_hash_table.hpp | 10 +- .../result/account_address_result.hpp | 4 +- .../database/result/account_asset_result.hpp | 4 +- .../database/result/account_result.hpp | 4 +- .../database/result/asset_result.hpp | 4 +- .../metaverse/database/result/base_result.hpp | 22 +- .../database/result/transaction_result.hpp | 2 +- include/metaverse/database/version.hpp | 8 +- include/metaverse/explorer.hpp | 2 +- include/metaverse/explorer/callback_state.hpp | 24 +- .../explorer/commands/fetch-stealth.hpp | 6 +- .../commands/offline_commands_impl.hpp | 4 +- .../metaverse/explorer/commands/send-tx.hpp | 6 +- .../metaverse/explorer/commands/settings.hpp | 6 +- .../explorer/commands/stealth-decode.hpp | 6 +- .../explorer/commands/stealth-encode.hpp | 6 +- .../explorer/commands/stealth-public.hpp | 6 +- .../explorer/commands/stealth-secret.hpp | 6 +- .../explorer/commands/stealth-shared.hpp | 6 +- .../metaverse/explorer/commands/tx-decode.hpp | 6 +- .../explorer/commands/validate-tx.hpp | 6 +- include/metaverse/explorer/config/address.hpp | 2 +- include/metaverse/explorer/config/hd_key.hpp | 2 +- include/metaverse/explorer/config/header.hpp | 4 +- include/metaverse/explorer/config/input.hpp | 2 +- include/metaverse/explorer/config/output.hpp | 2 +- .../metaverse/explorer/config/transaction.hpp | 2 +- include/metaverse/explorer/config/wrapper.hpp | 2 +- include/metaverse/explorer/define.hpp | 8 +- include/metaverse/explorer/dispatch.hpp | 4 +- include/metaverse/explorer/display.hpp | 4 +- .../explorer/extensions/account_info.hpp | 10 +- .../explorer/extensions/command_assistant.hpp | 2 +- .../explorer/extensions/commands/addnode.hpp | 2 +- .../extensions/commands/changepasswd.hpp | 18 +- .../extensions/commands/decoderawtx.hpp | 2 +- .../extensions/commands/deleteaccount.hpp | 10 +- .../explorer/extensions/commands/deposit.hpp | 28 +- .../explorer/extensions/commands/didsend.hpp | 16 +- .../extensions/commands/didsendasset.hpp | 64 +- .../extensions/commands/didsendfrom.hpp | 56 +- .../extensions/commands/didsendmore.hpp | 16 +- .../extensions/commands/dumpkeyfile.hpp | 8 +- .../extensions/commands/getaccount.hpp | 10 +- .../extensions/commands/getaddressetp.hpp | 4 +- .../extensions/commands/getbalance.hpp | 8 +- .../extensions/commands/getblockheader.hpp | 4 +- .../explorer/extensions/commands/getdid.hpp | 14 +- .../extensions/commands/getheight.hpp | 8 +- .../explorer/extensions/commands/getinfo.hpp | 8 +- .../extensions/commands/getmemorypool.hpp | 8 +- .../extensions/commands/getmininginfo.hpp | 12 +- .../extensions/commands/getnewaccount.hpp | 8 +- .../extensions/commands/getpeerinfo.hpp | 8 +- .../extensions/commands/getpublickey.hpp | 20 +- .../explorer/extensions/commands/gettx.hpp | 8 +- .../explorer/extensions/commands/getwork.hpp | 8 +- .../extensions/commands/importaccount.hpp | 60 +- .../extensions/commands/importkeyfile.hpp | 2 +- .../extensions/commands/listaddresses.hpp | 8 +- .../extensions/commands/listbalances.hpp | 8 +- .../explorer/extensions/commands/listdids.hpp | 8 +- .../explorer/extensions/commands/listtxs.hpp | 34 +- .../extensions/commands/registerdid.hpp | 44 +- .../explorer/extensions/commands/send.hpp | 16 +- .../extensions/commands/sendasset.hpp | 64 +- .../extensions/commands/sendassetfrom.hpp | 68 +- .../explorer/extensions/commands/sendfrom.hpp | 56 +- .../explorer/extensions/commands/sendmore.hpp | 16 +- .../extensions/commands/sendwithmsg.hpp | 26 +- .../extensions/commands/sendwithmsgfrom.hpp | 68 +- .../extensions/commands/setminingaccount.hpp | 10 +- .../explorer/extensions/commands/shutdown.hpp | 8 +- .../extensions/commands/stopmining.hpp | 8 +- .../extensions/commands/submitwork.hpp | 2 +- .../extensions/commands/validateaddress.hpp | 2 +- .../extensions/node_method_wrapper.hpp | 2 +- include/metaverse/explorer/impl/utility.ipp | 8 +- include/metaverse/explorer/utility.hpp | 2 +- include/metaverse/mgbubble/HttpServ.hpp | 4 +- include/metaverse/mgbubble/MongooseCli.hpp | 32 +- include/metaverse/mgbubble/WsPushServ.hpp | 4 +- .../metaverse/mgbubble/compat/string_view.h | 2 +- include/metaverse/mgbubble/utility/Queue.hpp | 98 +- include/metaverse/network.hpp | 2 +- include/metaverse/network/connections.hpp | 4 +- include/metaverse/network/define.hpp | 6 +- include/metaverse/network/hosts.hpp | 8 +- .../metaverse/network/message_subscriber.hpp | 4 +- .../metaverse/network/pending_channels.hpp | 2 +- include/metaverse/network/pending_sockets.hpp | 2 +- .../network/protocols/protocol_version.hpp | 2 +- .../network/sessions/session_manual.hpp | 4 +- include/metaverse/node.hpp | 2 +- include/metaverse/node/configuration.hpp | 2 +- include/metaverse/node/define.hpp | 4 +- include/metaverse/node/parser.hpp | 2 +- .../node/protocols/protocol_block_out.hpp | 2 +- .../node/protocols/protocol_block_sync.hpp | 2 +- .../node/protocols/protocol_header_sync.hpp | 2 +- .../node/protocols/protocol_miner.hpp | 24 +- .../node/sessions/session_header_sync.hpp | 2 +- .../metaverse/node/utility/reservations.hpp | 4 +- include/metaverse/protocol.hpp | 2 +- include/metaverse/protocol/define.hpp | 4 +- .../metaverse/protocol/zmq/authenticator.hpp | 2 +- .../metaverse/protocol/zmq/certificate.hpp | 2 +- include/metaverse/protocol/zmq/context.hpp | 2 +- include/metaverse/protocol/zmq/frame.hpp | 2 +- .../metaverse/protocol/zmq/identifiers.hpp | 2 +- include/metaverse/protocol/zmq/message.hpp | 2 +- include/metaverse/protocol/zmq/poller.hpp | 2 +- include/metaverse/protocol/zmq/socket.hpp | 2 +- include/metaverse/protocol/zmq/worker.hpp | 2 +- include/metaverse/protocol/zmq/zeromq.hpp | 2 +- include/metaverse/server.hpp | 2 +- include/metaverse/server/define.hpp | 6 +- .../metaverse/server/interface/blockchain.hpp | 4 +- .../metaverse/server/interface/protocol.hpp | 2 +- include/metaverse/server/server_node.hpp | 2 +- include/metaverse/server/utility/coredump.hpp | 2 +- .../chain/attachment/asset/asset_transfer.cpp | 2 +- .../attachment/asset/blockchain_asset.cpp | 42 +- .../chain/attachment/did/blockchain_did.cpp | 44 +- src/lib/bitcoin/chain/attachment/did/did.cpp | 28 +- src/lib/bitcoin/chain/attachment/etp/etp.cpp | 26 +- .../chain/attachment/etp/etp_award.cpp | 18 +- src/lib/bitcoin/chain/transaction.cpp | 20 +- src/lib/bitcoin/config/base2.cpp | 2 +- src/lib/bitcoin/config/checkpoint.cpp | 2 +- src/lib/bitcoin/config/parameter.cpp | 4 +- src/lib/bitcoin/config/printer.cpp | 10 +- src/lib/bitcoin/formats/base_58.cpp | 2 +- src/lib/bitcoin/formats/base_64.cpp | 2 +- src/lib/bitcoin/formats/base_85.cpp | 30 +- src/lib/bitcoin/math/elliptic_curve.cpp | 2 +- src/lib/bitcoin/math/external/aes256.c | 20 +- src/lib/bitcoin/math/external/aes256.h | 8 +- src/lib/bitcoin/math/external/crypto_scrypt.h | 2 +- src/lib/bitcoin/math/external/hmac_sha256.c | 8 +- src/lib/bitcoin/math/external/hmac_sha256.h | 2 +- src/lib/bitcoin/math/external/hmac_sha512.c | 8 +- src/lib/bitcoin/math/external/hmac_sha512.h | 2 +- src/lib/bitcoin/math/external/ripemd160.c | 38 +- src/lib/bitcoin/math/external/sha256.c | 6 +- src/lib/bitcoin/math/external/sha256.h | 2 +- src/lib/bitcoin/math/external/sha512.c | 12 +- src/lib/bitcoin/math/external/sha512.h | 4 +- src/lib/bitcoin/math/external/zeroize.c | 2 +- src/lib/bitcoin/math/external/zeroize.h | 2 +- .../bitcoin/math/secp256k1_initializer.hpp | 2 +- src/lib/bitcoin/math/uint256.cpp | 8 +- src/lib/bitcoin/message/address.cpp | 2 +- src/lib/bitcoin/message/network_address.cpp | 68 +- src/lib/bitcoin/message/version.cpp | 2 +- src/lib/bitcoin/unicode/unicode.cpp | 12 +- src/lib/bitcoin/unicode/unicode_streambuf.cpp | 6 +- src/lib/bitcoin/utility/backtrace.cpp | 50 +- src/lib/bitcoin/utility/daemon.cpp | 70 +- src/lib/bitcoin/utility/log.cpp | 4 +- src/lib/bitcoin/utility/logging.cpp | 18 +- src/lib/bitcoin/utility/time.cpp | 10 +- src/lib/bitcoin/wallet/bitcoin_uri.cpp | 4 +- src/lib/bitcoin/wallet/ec_private.cpp | 4 +- src/lib/bitcoin/wallet/encrypted_keys.cpp | 216 +-- src/lib/bitcoin/wallet/hd_private.cpp | 4 +- src/lib/bitcoin/wallet/hd_public.cpp | 4 +- src/lib/bitcoin/wallet/message.cpp | 2 +- .../parse_encrypted_prefix.ipp | 2 +- .../parse_encrypted_private.cpp | 2 +- .../parse_encrypted_public.cpp | 2 +- src/lib/bitcoin/wallet/payment_address.cpp | 10 +- src/lib/blockchain/block.cpp | 2 +- src/lib/blockchain/organizer.cpp | 30 +- src/lib/blockchain/orphan_pool.cpp | 2 +- src/lib/blockchain/transaction_pool_index.cpp | 4 +- src/lib/blockchain/validate_block_impl.cpp | 6 +- src/lib/client/dealer.cpp | 2 +- src/lib/consensus/clone/pubkey.h | 4 +- .../consensus/clone/script/interpreter.cpp | 6 +- src/lib/consensus/clone/serialize.h | 14 +- .../consensus/common/libdevcore/Base64.cpp | 204 +-- .../consensus/common/libdevcore/Common.cpp | 116 +- .../common/libdevcore/CommonData.cpp | 180 +- .../consensus/common/libdevcore/CommonIO.cpp | 240 +-- .../consensus/common/libdevcore/FixedHash.cpp | 46 +- .../consensus/common/libdevcore/Guards.cpp | 22 +- src/lib/consensus/common/libdevcore/Log.cpp | 184 +- src/lib/consensus/common/libdevcore/RLP.cpp | 570 +++---- src/lib/consensus/common/libdevcore/SHA3.cpp | 132 +- src/lib/consensus/common/miner/MinerAux.cpp | 160 +- src/lib/consensus/consensus/consensus.cpp | 10 +- .../databases/address_did_database.cpp | 436 ++--- src/lib/database/databases/asset_database.cpp | 40 +- src/lib/database/databases/base_database.cpp | 2 +- src/lib/database/databases/block_database.cpp | 4 +- .../databases/blockchain_did_database.cpp | 58 +- .../database/databases/history_database.cpp | 2 +- src/lib/database/databases/spend_database.cpp | 2 +- .../databases/transaction_database.cpp | 2 +- src/lib/database/memory/memory_map.cpp | 2 +- src/lib/database/mman-win32/mman.c | 2 +- .../database/primitives/record_manager.cpp | 2 +- .../result/account_address_result.cpp | 16 +- src/lib/database/result/account_result.cpp | 16 +- src/lib/database/result/asset_result.cpp | 22 +- src/lib/explorer/callback_state.cpp | 6 +- src/lib/explorer/commands/fetch-stealth.cpp | 6 +- src/lib/explorer/commands/help.cpp | 6 +- .../commands/offline/stealth-decode.cpp | 6 +- .../commands/offline/stealth-encode.cpp | 6 +- .../commands/offline/stealth-public.cpp | 6 +- .../commands/offline/stealth-secret.cpp | 6 +- .../commands/offline/stealth-shared.cpp | 8 +- .../explorer/commands/offline/tx-decode.cpp | 6 +- .../commands/offline_commands_impl.cpp | 8 +- src/lib/explorer/commands/send-tx.cpp | 6 +- src/lib/explorer/commands/settings.cpp | 14 +- src/lib/explorer/commands/validate-tx.cpp | 6 +- src/lib/explorer/config/byte.cpp | 4 +- src/lib/explorer/config/endorsement.cpp | 2 +- src/lib/explorer/config/input.cpp | 2 +- src/lib/explorer/config/point.cpp | 2 +- src/lib/explorer/config/signature.cpp | 2 +- src/lib/explorer/config/wrapper.cpp | 2 +- src/lib/explorer/display.cpp | 6 +- src/lib/explorer/extensions/account_info.cpp | 56 +- .../explorer/extensions/command_assistant.cpp | 2 +- .../extensions/commands/didsendasset.cpp | 2 +- .../extensions/commands/didsendassetfrom.cpp | 4 +- .../extensions/commands/didsendfrom.cpp | 2 +- .../extensions/commands/didsendmore.cpp | 4 +- .../explorer/extensions/commands/getblock.cpp | 2 +- .../extensions/commands/getblockheader.cpp | 12 +- .../explorer/extensions/commands/getdid.cpp | 10 +- .../extensions/commands/importaccount.cpp | 6 +- .../extensions/commands/listbalances.cpp | 4 +- src/lib/explorer/extensions/exception.cpp | 2 +- .../extensions/node_method_wrapper.cpp | 12 +- src/lib/network/acceptor.cpp | 4 +- src/lib/network/channel.cpp | 12 +- src/lib/network/connections.cpp | 20 +- src/lib/network/connector.cpp | 48 +- src/lib/network/hosts.cpp | 196 +-- src/lib/network/p2p.cpp | 12 +- src/lib/network/protocols/protocol.cpp | 4 +- .../network/protocols/protocol_address.cpp | 4 +- src/lib/network/protocols/protocol_events.cpp | 4 +- src/lib/network/protocols/protocol_timer.cpp | 4 +- .../network/protocols/protocol_version.cpp | 8 +- src/lib/network/proxy.cpp | 4 +- src/lib/network/sessions/session.cpp | 6 +- src/lib/network/sessions/session_batch.cpp | 6 +- src/lib/network/sessions/session_inbound.cpp | 8 +- src/lib/network/sessions/session_manual.cpp | 34 +- src/lib/network/sessions/session_outbound.cpp | 32 +- src/lib/network/sessions/session_seed.cpp | 12 +- src/lib/network/settings.cpp | 2 +- src/lib/node/parser.cpp | 18 +- src/lib/node/protocols/protocol_block_in.cpp | 26 +- src/lib/node/protocols/protocol_block_out.cpp | 76 +- .../node/protocols/protocol_block_sync.cpp | 10 +- .../node/protocols/protocol_header_sync.cpp | 6 +- src/lib/node/protocols/protocol_miner.cpp | 24 +- .../protocols/protocol_transaction_in.cpp | 6 +- .../protocols/protocol_transaction_out.cpp | 6 +- src/lib/node/sessions/session_block_sync.cpp | 30 +- src/lib/node/sessions/session_header_sync.cpp | 48 +- src/lib/node/sessions/session_inbound.cpp | 4 +- src/lib/node/sessions/session_manual.cpp | 10 +- src/lib/node/sessions/session_outbound.cpp | 10 +- src/lib/node/utility/header_queue.cpp | 4 +- src/lib/protocol/response_packet.cpp | 2 +- src/lib/protocol/zmq/authenticator.cpp | 2 +- src/lib/protocol/zmq/certificate.cpp | 2 +- src/lib/protocol/zmq/context.cpp | 2 +- src/lib/protocol/zmq/frame.cpp | 2 +- src/lib/protocol/zmq/identifiers.cpp | 2 +- src/lib/protocol/zmq/message.cpp | 2 +- src/lib/protocol/zmq/poller.cpp | 2 +- src/lib/protocol/zmq/socket.cpp | 4 +- src/lib/protocol/zmq/worker.cpp | 2 +- src/lib/protocol/zmq/zeromq.cpp | 2 +- src/mvsd/executor.cpp | 42 +- src/mvsd/executor.hpp | 2 +- src/mvsd/mgbubble/HttpServ.cpp | 4 +- src/mvsd/mgbubble/MgServer.cpp | 2 +- src/mvsd/mgbubble/WsPushServ.cpp | 8 +- src/mvsd/server/interface/protocol.cpp | 10 +- src/mvsd/server/messages/message.cpp | 2 +- src/mvsd/server/parser.cpp | 52 +- src/mvsd/server/server_node.cpp | 4 +- src/mvsd/server/services/block_service.cpp | 2 +- .../server/services/transaction_service.cpp | 6 +- src/mvsd/server/utility/fetch_helpers.cpp | 12 +- .../server/workers/notification_worker.cpp | 16 +- src/windows/mvstray/mvstray.cpp | 20 +- 396 files changed, 6385 insertions(+), 6383 deletions(-) diff --git a/include/metaverse/bitcoin.hpp b/include/metaverse/bitcoin.hpp index 3c8b4eca6..581bbf589 100644 --- a/include/metaverse/bitcoin.hpp +++ b/include/metaverse/bitcoin.hpp @@ -8,7 +8,7 @@ #define MVS_BITCOIN_HPP /** - * API Users: Include only this header. Direct use of other headers is fragile + * API Users: Include only this header. Direct use of other headers is fragile * and unsupported as header organization is subject to change. * * Maintainers: Do not include this header internal to this library. diff --git a/include/metaverse/bitcoin/chain/attachment/asset/blockchain_asset.hpp b/include/metaverse/bitcoin/chain/attachment/asset/blockchain_asset.hpp index 3eadc4b75..c49f30bdf 100644 --- a/include/metaverse/bitcoin/chain/attachment/asset/blockchain_asset.hpp +++ b/include/metaverse/bitcoin/chain/attachment/asset/blockchain_asset.hpp @@ -35,10 +35,10 @@ namespace chain { class BC_API blockchain_asset { public: - typedef std::vector list; - blockchain_asset(); - blockchain_asset(uint32_t version, const output_point& tx_point, - uint64_t height, const asset_detail& asset); + typedef std::vector list; + blockchain_asset(); + blockchain_asset(uint32_t version, const output_point& tx_point, + uint64_t height, const asset_detail& asset); static blockchain_asset factory_from_data(const data_chunk& data); static blockchain_asset factory_from_data(std::istream& stream); static blockchain_asset factory_from_data(reader& source); @@ -58,20 +58,20 @@ class BC_API blockchain_asset bool is_valid() const; void reset(); uint64_t serialized_size() const; - const uint32_t& get_version() const; - void set_version(const uint32_t& version_); - const output_point& get_tx_point() const; - void set_tx_point(const output_point& tx_point_); - const uint64_t& get_height() const; - void set_height(const uint64_t& height_); - const asset_detail& get_asset() const; - void set_asset(const asset_detail& asset_); + const uint32_t& get_version() const; + void set_version(const uint32_t& version_); + const output_point& get_tx_point() const; + void set_tx_point(const output_point& tx_point_); + const uint64_t& get_height() const; + void set_height(const uint64_t& height_); + const asset_detail& get_asset() const; + void set_asset(const asset_detail& asset_); -private: +private: uint32_t version_; output_point tx_point_; - uint64_t height_; - asset_detail asset_; + uint64_t height_; + asset_detail asset_; }; } // namespace chain diff --git a/include/metaverse/bitcoin/chain/attachment/did/blockchain_did.hpp b/include/metaverse/bitcoin/chain/attachment/did/blockchain_did.hpp index 688ebcf56..8d487de01 100644 --- a/include/metaverse/bitcoin/chain/attachment/did/blockchain_did.hpp +++ b/include/metaverse/bitcoin/chain/attachment/did/blockchain_did.hpp @@ -41,10 +41,10 @@ class BC_API blockchain_did address_current, address_history }; - typedef std::vector list; - blockchain_did(); - blockchain_did( uint32_t version, const output_point& tx_point, - uint64_t height, uint32_t status, const did_detail& did); + typedef std::vector list; + blockchain_did(); + blockchain_did( uint32_t version, const output_point& tx_point, + uint64_t height, uint32_t status, const did_detail& did); static blockchain_did factory_from_data(const data_chunk& data); static blockchain_did factory_from_data(std::istream& stream); static blockchain_did factory_from_data(reader& source); @@ -64,23 +64,23 @@ class BC_API blockchain_did bool is_valid() const; void reset(); uint64_t serialized_size() const; - const uint32_t& get_version() const; - void set_version(const uint32_t& version_); - const output_point& get_tx_point() const; - void set_tx_point(const output_point& tx_point_); - const uint64_t& get_height() const; - void set_height(const uint64_t& height_); - const did_detail& get_did() const; - void set_did(const did_detail& did_); + const uint32_t& get_version() const; + void set_version(const uint32_t& version_); + const output_point& get_tx_point() const; + void set_tx_point(const output_point& tx_point_); + const uint64_t& get_height() const; + void set_height(const uint64_t& height_); + const did_detail& get_did() const; + void set_did(const did_detail& did_); void set_status(const uint32_t & status); - const uint32_t& get_status() const; + const uint32_t& get_status() const; std::string get_status_string() const; private: uint32_t version_; output_point tx_point_; - uint64_t height_; - uint32_t status_; - did_detail did_; + uint64_t height_; + uint32_t status_; + did_detail did_; }; } // namespace chain diff --git a/include/metaverse/bitcoin/chain/attachment/did/did.hpp b/include/metaverse/bitcoin/chain/attachment/did/did.hpp index 086770aa3..5b22073cd 100644 --- a/include/metaverse/bitcoin/chain/attachment/did/did.hpp +++ b/include/metaverse/bitcoin/chain/attachment/did/did.hpp @@ -44,15 +44,15 @@ namespace chain { class BC_API did { public: - enum class did_status : uint32_t - { - did_none, - did_locked, - did_transferable, - }; + enum class did_status : uint32_t + { + did_none, + did_locked, + did_transferable, + }; - did(); - did(uint32_t status, const did_detail& detail); + did(); + did(uint32_t status, const did_detail& detail); static did factory_from_data(const data_chunk& data); static did factory_from_data(std::istream& stream); static did factory_from_data(reader& source); @@ -65,15 +65,15 @@ class BC_API did void to_data(std::ostream& stream) const; void to_data(writer& sink) const; std::string to_string() const; - bool is_valid_type() const; + bool is_valid_type() const; bool is_valid() const; void reset(); uint64_t serialized_size() const; - uint32_t get_status() const; - void set_status(uint32_t status); - void set_data(const did_detail& detail); - const did_detail& get_data() const; - + uint32_t get_status() const; + void set_status(uint32_t status); + void set_data(const did_detail& detail); + const did_detail& get_data() const; + private: uint32_t status; did_detail data; diff --git a/include/metaverse/bitcoin/chain/attachment/etp/etp.hpp b/include/metaverse/bitcoin/chain/attachment/etp/etp.hpp index 281883ca3..7e46f0cb9 100644 --- a/include/metaverse/bitcoin/chain/attachment/etp/etp.hpp +++ b/include/metaverse/bitcoin/chain/attachment/etp/etp.hpp @@ -30,14 +30,14 @@ namespace libbitcoin { namespace chain { - + BC_CONSTEXPR size_t ETP_FIX_SIZE = 8; class BC_API etp { public: - etp(); - etp(uint64_t value); + etp(); + etp(uint64_t value); static etp factory_from_data(const data_chunk& data); static etp factory_from_data(std::istream& stream); static etp factory_from_data(reader& source); @@ -53,9 +53,9 @@ class BC_API etp bool is_valid() const; void reset(); uint64_t serialized_size() const; - uint64_t get_value() const; - void set_value(uint64_t value); - + uint64_t get_value() const; + void set_value(uint64_t value); + private: uint64_t value; }; diff --git a/include/metaverse/bitcoin/chain/attachment/etp/etp_award.hpp b/include/metaverse/bitcoin/chain/attachment/etp/etp_award.hpp index 1894901c2..758cfb8a4 100644 --- a/include/metaverse/bitcoin/chain/attachment/etp/etp_award.hpp +++ b/include/metaverse/bitcoin/chain/attachment/etp/etp_award.hpp @@ -30,14 +30,14 @@ namespace libbitcoin { namespace chain { - + BC_CONSTEXPR size_t ETP_AWARD_FIX_SIZE = 8; class BC_API etp_award { public: - etp_award(); - etp_award(uint64_t height); + etp_award(); + etp_award(uint64_t height); static etp_award factory_from_data(const data_chunk& data); static etp_award factory_from_data(std::istream& stream); static etp_award factory_from_data(reader& source); @@ -53,9 +53,9 @@ class BC_API etp_award bool is_valid() const; void reset(); uint64_t serialized_size() const; - uint64_t get_height() const; - void set_height(uint64_t height); - + uint64_t get_height() const; + void set_height(uint64_t height); + private: uint64_t height; }; diff --git a/include/metaverse/bitcoin/chain/attachment/message/message.hpp b/include/metaverse/bitcoin/chain/attachment/message/message.hpp index 1c1b659d1..1c7eee6c8 100644 --- a/include/metaverse/bitcoin/chain/attachment/message/message.hpp +++ b/include/metaverse/bitcoin/chain/attachment/message/message.hpp @@ -30,15 +30,15 @@ namespace libbitcoin { namespace chain { - + BC_CONSTEXPR size_t BLOCKCHAIN_MESSAGE_FIX_SIZE = 256; class BC_API blockchain_message { public: //BC_CONSTEXPR static size_t blockchain_message_FIX_SIZE = 64; - blockchain_message(); - blockchain_message(std::string content); + blockchain_message(); + blockchain_message(std::string content); static blockchain_message factory_from_data(const data_chunk& data); static blockchain_message factory_from_data(std::istream& stream); static blockchain_message factory_from_data(reader& source); @@ -54,9 +54,9 @@ class BC_API blockchain_message bool is_valid() const; void reset(); uint64_t serialized_size() const; - const std::string& get_content() const; - void set_content(const std::string& content); - + const std::string& get_content() const; + void set_content(const std::string& content); + private: std::string content_; }; diff --git a/include/metaverse/bitcoin/chain/attachment/variant_visitor.hpp b/include/metaverse/bitcoin/chain/attachment/variant_visitor.hpp index a440aa0d4..b454611ed 100644 --- a/include/metaverse/bitcoin/chain/attachment/variant_visitor.hpp +++ b/include/metaverse/bitcoin/chain/attachment/variant_visitor.hpp @@ -30,95 +30,95 @@ namespace chain { class from_data_visitor : public boost::static_visitor { public: - from_data_visitor(reader& src): source(src) - { - - } - - template - bool operator()(T &t) - { - return t.from_data(source); - } - - reader& source; + from_data_visitor(reader& src): source(src) + { + + } + + template + bool operator()(T &t) + { + return t.from_data(source); + } + + reader& source; }; class to_data_visitor : public boost::static_visitor { public: - to_data_visitor(writer& dst): sink(dst) - { - - } - - template - void operator()(T &t) const - { - return t.to_data(sink); - } - - writer& sink; + to_data_visitor(writer& dst): sink(dst) + { + + } + + template + void operator()(T &t) const + { + return t.to_data(sink); + } + + writer& sink; }; class serialized_size_visitor : public boost::static_visitor { public: - serialized_size_visitor() - { - - } - - template - uint64_t operator()(T &t) const - { - return t.serialized_size(); - } + serialized_size_visitor() + { + + } + + template + uint64_t operator()(T &t) const + { + return t.serialized_size(); + } }; class to_string_visitor : public boost::static_visitor { public: - to_string_visitor() - { - - } - - template - std::string operator()(T &t) const - { - return t.to_string(); - } + to_string_visitor() + { + + } + + template + std::string operator()(T &t) const + { + return t.to_string(); + } }; class reset_visitor : public boost::static_visitor { public: - reset_visitor() - { - - } - - template - void operator()(T &t) - { - return t.reset(); - } + reset_visitor() + { + + } + + template + void operator()(T &t) + { + return t.reset(); + } }; class is_valid_visitor : public boost::static_visitor { public: - is_valid_visitor() - { - - } - - template - bool operator()(T &t) const - { - return t.is_valid(); - } + is_valid_visitor() + { + + } + + template + bool operator()(T &t) const + { + return t.is_valid(); + } }; } // namespace chain diff --git a/include/metaverse/bitcoin/chain/script/script.hpp b/include/metaverse/bitcoin/chain/script/script.hpp index 9eb18c342..20de51bbb 100644 --- a/include/metaverse/bitcoin/chain/script/script.hpp +++ b/include/metaverse/bitcoin/chain/script/script.hpp @@ -46,14 +46,14 @@ enum signature_hash_algorithm : uint32_t all = 0x01, /// Signs all of the inputs but none of the outputs, allowing anyone to - /// change where the satoshis are going unless other signatures using + /// change where the satoshis are going unless other signatures using /// other signature hash flags protect the outputs. none = 0x02, /// The only output signed is the one corresponding to this input (the /// output with the same output index number as this input), ensuring - /// nobody can change your part of the transaction but allowing other - /// signers to change their part of the transaction. The corresponding + /// nobody can change your part of the transaction but allowing other + /// signers to change their part of the transaction. The corresponding /// output must exist or the value '1' will be signed, breaking the /// security scheme. This input, as well as other inputs, are included /// in the signature. The sequence numbers of other inputs are not diff --git a/include/metaverse/bitcoin/chain/transaction.hpp b/include/metaverse/bitcoin/chain/transaction.hpp index 5916dc47e..12fd39839 100644 --- a/include/metaverse/bitcoin/chain/transaction.hpp +++ b/include/metaverse/bitcoin/chain/transaction.hpp @@ -91,15 +91,15 @@ class BC_API transaction bool is_locktime_conflict() const; uint64_t total_output_value() const; uint64_t serialized_size() const; - uint64_t total_output_transfer_amount() const; - bool has_asset_issue() const; - bool has_asset_secondary_issue() const; - bool has_asset_transfer() const; - bool has_asset_cert() const; - bool has_asset_mit_transfer() const; + uint64_t total_output_transfer_amount() const; + bool has_asset_issue() const; + bool has_asset_secondary_issue() const; + bool has_asset_transfer() const; + bool has_asset_cert() const; + bool has_asset_mit_transfer() const; bool has_did_register() const; - bool has_did_transfer() const; + bool has_did_transfer() const; std::string get_did_transfer_old_address() const; uint32_t version; diff --git a/include/metaverse/bitcoin/config/authority.hpp b/include/metaverse/bitcoin/config/authority.hpp index 2ff4b6836..c3fe39b91 100644 --- a/include/metaverse/bitcoin/config/authority.hpp +++ b/include/metaverse/bitcoin/config/authority.hpp @@ -41,7 +41,7 @@ class BC_API authority public: /** * A list of authorities. - * This must provide operator<< for ostream in order to be used as a + * This must provide operator<< for ostream in order to be used as a * boost::program_options default_value. */ typedef std::vector list; @@ -51,13 +51,13 @@ class BC_API authority * Default constructor. */ authority(); - + /** * Copy constructor. * @param[in] other The object to copy into self on construct. */ authority(const authority& other); - + /** * Initialization constructor. * Deserialize a IPv4 or IPv6 address-based hostname[:port]. @@ -66,20 +66,20 @@ class BC_API authority * [2001:db8::2]:port or 1.2.240.1:port */ authority(const std::string& authority); - + /** * Initialization constructor. * @param[in] net The network address (ip and port) to initialize with. */ authority(const message::network_address& address); - + /** * Initialization constructor. * @param[in] ip The ip addresss to initialize with. * @param[in] port The port to initialize with. */ authority(const message::ip_address& ip, uint16_t port); - + /** * Initialization constructor. * @param[in] host The host to initialize with in one of three forms: @@ -87,14 +87,14 @@ class BC_API authority * @param[in] port The port to initialize with. */ authority(const std::string& host, uint16_t port); - + /** * Initialization constructor. * @param[in] ip The boost ip addresss to initialize with. * @param[in] port The port to initialize with. */ authority(const asio::address& ip, uint16_t port); - + /** * Initialization constructor. * @param[in] endpoint The boost endpoint addresss to initialize with. @@ -112,14 +112,14 @@ class BC_API authority * @return The tcp port of the authority. */ uint16_t port() const; - + /** * Get the hostname of the authority as a string. * The form of the return is determined by the type of address. * @return The hostname in one of two forms: 2001:db8::2 or 1.2.240.1 */ std::string to_hostname() const; - + /** * Get the authority as a string. * The form of the return is determined by the type of address. diff --git a/include/metaverse/bitcoin/config/checkpoint.hpp b/include/metaverse/bitcoin/config/checkpoint.hpp index 93dd9b02a..3b30abce6 100644 --- a/include/metaverse/bitcoin/config/checkpoint.hpp +++ b/include/metaverse/bitcoin/config/checkpoint.hpp @@ -40,7 +40,7 @@ class BC_API checkpoint public: /** * A list of checkpoints. - * This must provide operator<< for ostream in order to be used as a + * This must provide operator<< for ostream in order to be used as a * boost::program_options default_value. */ typedef std::vector list; @@ -51,7 +51,7 @@ class BC_API checkpoint * @return The sorted list of checkpoints. */ static list sort(const list& checks); - + /** * Validate a checkpoint against a list of checkpoints. * @param[in] hash The hash of the checkpoint. @@ -60,51 +60,51 @@ class BC_API checkpoint */ static bool validate(const hash_digest& hash, size_t height, const list& checks); - + /** * Default constructor. */ checkpoint(); - + /** * Copy constructor. * @param[in] other The object to copy into self on construct. */ checkpoint(const checkpoint& other); - + /** * Initialization constructor. * The height is optional and will be set to zero if not provided. * @param[in] value The value of the hash[:height] form. */ checkpoint(const std::string& value); - + /** * Initialization constructor. * @param[in] hash The string block hash for the checkpoint. * @param[in] height The height of the hash. */ checkpoint(const std::string& hash, size_t height); - + /** * Initialization constructor. * @param[in] hash The block hash for the checkpoint. * @param[in] height The height of the hash. */ checkpoint(const hash_digest& hash, size_t height); - + /** * Getter. * @return The block hash of the checkpoint. */ hash_digest hash() const; - + /** * Getter. * @return The block height of the checkpoint. */ size_t height() const; - + /** * Get the checkpoint as a string. * @return The ip address of the authority in the hash:height form. @@ -116,7 +116,7 @@ class BC_API checkpoint * @param[in] other The other object with which to compare. */ bool operator==(const checkpoint& other) const; - + /** * Define stream in. Throws if input is invalid. * @param[in] input The input stream to read the value from. diff --git a/include/metaverse/bitcoin/config/endpoint.hpp b/include/metaverse/bitcoin/config/endpoint.hpp index 158981a1c..180557e33 100644 --- a/include/metaverse/bitcoin/config/endpoint.hpp +++ b/include/metaverse/bitcoin/config/endpoint.hpp @@ -42,22 +42,22 @@ class BC_API endpoint public: /** * A list of endpoints. - * This must provide operator<< for ostream in order to be used as a + * This must provide operator<< for ostream in order to be used as a * boost::program_options default_value. */ typedef std::vector list; - + /** * Default constructor. */ endpoint(); - + /** * Copy constructor. * @param[in] other The object to copy into self on construct. */ endpoint(const endpoint& other); - + /** * Initialization constructor. * The scheme and port may be undefined, in which case the port is reported @@ -65,26 +65,26 @@ class BC_API endpoint * @param[in] value The initial value of the [scheme://]host[:port] form. */ endpoint(const std::string& value); - + /** * Initialization constructor. * @param[in] authority The value to initialize with. */ endpoint(const authority& authority); - + /** * Initialization constructor. * @param[in] host The host name or ip address to initialize with. * @param[in] port The port to initialize with. */ endpoint(const std::string& host, uint16_t port); - + /** * Initialization constructor. * @param[in] endpoint The endpoint addresss to initialize with. */ endpoint(const asio::endpoint& host); - + /** * Initialization constructor. * @param[in] ip The boost ip addresss to initialize with. @@ -103,19 +103,19 @@ class BC_API endpoint * @return The scheme of the endpoint or empty string. */ const std::string& scheme() const; - + /** * Getter. * @return The host name or ip address of the endpoint. */ const std::string& host() const; - + /** * Getter. * @return The tcp port of the endpoint. */ uint16_t port() const; - + /** * Get the endpoint as a string. * An empty scheme and/or empty port is omitted. @@ -128,7 +128,7 @@ class BC_API endpoint * @param[in] other The other object with which to compare. */ bool operator==(const endpoint& other) const; - + /** * Define stream in. Throws if input is invalid. * @param[in] input The input stream to read the value from. diff --git a/include/metaverse/bitcoin/config/hash256.hpp b/include/metaverse/bitcoin/config/hash256.hpp index d81dd62bc..7f4020563 100644 --- a/include/metaverse/bitcoin/config/hash256.hpp +++ b/include/metaverse/bitcoin/config/hash256.hpp @@ -37,7 +37,7 @@ class BC_API hash256 public: /** * A list of bitcoin 256 bit hashes. - * This must provide operator<< for ostream in order to be used as a + * This must provide operator<< for ostream in order to be used as a * boost::program_options default_value. */ typedef std::vector list; @@ -64,7 +64,7 @@ class BC_API hash256 * @param[in] value The hash value to initialize with. */ hash256(const hash_digest& value); - + /** * Get the hash as a string. * @return The hash in the string hexidecimal form. diff --git a/include/metaverse/bitcoin/config/parameter.hpp b/include/metaverse/bitcoin/config/parameter.hpp index 44e22c53e..05f238905 100644 --- a/include/metaverse/bitcoin/config/parameter.hpp +++ b/include/metaverse/bitcoin/config/parameter.hpp @@ -106,7 +106,7 @@ class BC_API parameter const argument_list& arguments); /** - * Determine if the option is an argument by testing for it by name in the + * Determine if the option is an argument by testing for it by name in the * positional options collection and if so return the position. * @param[in] option The metadata of the option to position. * @param[in] arguments The list of supported positional arguments. @@ -123,7 +123,7 @@ class BC_API parameter * @param[in] arguments The argument names list. * @return The arguments limit value for the option. */ - unsigned arguments_limit(int position, + unsigned arguments_limit(int position, const boost::program_options::option_description& option, const argument_list& arguments) const; diff --git a/include/metaverse/bitcoin/config/parser.hpp b/include/metaverse/bitcoin/config/parser.hpp index 0ad175816..b21fa6dbe 100644 --- a/include/metaverse/bitcoin/config/parser.hpp +++ b/include/metaverse/bitcoin/config/parser.hpp @@ -58,7 +58,7 @@ class BC_API parser /// Load configuration file settings. virtual options_metadata load_settings() = 0; - + protected: virtual void load_command_variables(variables_map& variables, int argc, const char* argv[]); diff --git a/include/metaverse/bitcoin/config/printer.hpp b/include/metaverse/bitcoin/config/printer.hpp index b9b379bfe..fefa0cc71 100644 --- a/include/metaverse/bitcoin/config/printer.hpp +++ b/include/metaverse/bitcoin/config/printer.hpp @@ -72,7 +72,7 @@ class BC_API printer */ printer(const boost::program_options::options_description& options, const boost::program_options::positional_options_description& arguments, - const std::string& application, const std::string& description="", + const std::string& application, const std::string& description="", const std::string& command=""); /** @@ -91,14 +91,14 @@ class BC_API printer * @return The command description. */ virtual std::string format_description(); - + /** * Format the parameters table. * @param[in] positional True for positional otherwize named. * @return The formatted help arguments table. */ virtual std::string format_parameters_table(bool positional); - + /** * Format the settings table. * @return The formatted settings table. @@ -107,7 +107,7 @@ class BC_API printer /** * Format a paragraph. - * @param[in] paragraph The text to format. + * @param[in] paragraph The text to format. * @return The formatted paragraph. */ virtual std::string format_paragraph(const std::string& paragraph); @@ -123,7 +123,7 @@ class BC_API printer * @return The formatted command line parameters. */ virtual std::string format_usage_parameters(); - + /** * Build the list of argument name/count tuples. */ @@ -141,13 +141,13 @@ class BC_API printer /** * Serialize command line help (full details). - * @param[out] output Stream that is sink for output. + * @param[out] output Stream that is sink for output. */ virtual void commandline(std::ostream& output); /** * Serialize as config settings (full details). - * @param[out] output Stream that is sink for output. + * @param[out] output Stream that is sink for output. */ virtual void settings(std::ostream& output); diff --git a/include/metaverse/bitcoin/config/sodium.hpp b/include/metaverse/bitcoin/config/sodium.hpp index a688ffc68..1ee8a4eef 100644 --- a/include/metaverse/bitcoin/config/sodium.hpp +++ b/include/metaverse/bitcoin/config/sodium.hpp @@ -39,7 +39,7 @@ class BC_API sodium public: /** * A list of base85 values. - * This must provide operator<< for ostream in order to be used as a + * This must provide operator<< for ostream in order to be used as a * boost::program_options default_value. */ typedef std::vector list; @@ -76,7 +76,7 @@ class BC_API sodium /** * Overload cast to internal type. * @return This object's value cast to internal type. - * chenhao + * chenhao */ operator hash_digest() const; diff --git a/include/metaverse/bitcoin/define.hpp b/include/metaverse/bitcoin/define.hpp index b492c2740..c5f5c09e6 100644 --- a/include/metaverse/bitcoin/define.hpp +++ b/include/metaverse/bitcoin/define.hpp @@ -78,7 +78,7 @@ namespace mvs = libbitcoin; // for mvs // Log name. #define LOG_SYSTEM "system" -// Avoid namespace conflict between boost::placeholders and std::placeholders. +// Avoid namespace conflict between boost::placeholders and std::placeholders. #define BOOST_BIND_NO_PLACEHOLDERS // Define so we can have better visibility of lcov exclusion ranges. diff --git a/include/metaverse/bitcoin/impl/math/checksum.ipp b/include/metaverse/bitcoin/impl/math/checksum.ipp index 14f99b29a..c5387adba 100644 --- a/include/metaverse/bitcoin/impl/math/checksum.ipp +++ b/include/metaverse/bitcoin/impl/math/checksum.ipp @@ -64,7 +64,7 @@ template bool unwrap(uint8_t& out_version, std::array& out_payload, uint32_t& out_checksum, const std::array& wrapped) -{ +{ if (!verify_checksum(wrapped)) return false; diff --git a/include/metaverse/bitcoin/impl/utility/track.ipp b/include/metaverse/bitcoin/impl/utility/track.ipp index f1db7867b..6ae29455e 100644 --- a/include/metaverse/bitcoin/impl/utility/track.ipp +++ b/include/metaverse/bitcoin/impl/utility/track.ipp @@ -38,12 +38,12 @@ track::track(const std::string& DEBUG_ONLY(class_name)) { #ifndef NDEBUG #ifndef RESOURCE_INSCREASE - count_ = ++instances; + count_ = ++instances; bc::log::trace(LOG_SYSTEM) << class_ << "(" << count_ << ")"; #else bc::log::trace(LOG_SYSTEM) - << class_ << "(" << ++instances << ")"; + << class_ << "(" << ++instances << ")"; #endif #endif } @@ -56,7 +56,7 @@ track::~track() #ifndef RESOURCE_INSCREASE << "~" << class_ << "(" << count_ << ")"; #else - << "~" << class_ << "(" << --instances << ")"; + << "~" << class_ << "(" << --instances << ")"; #endif #endif } diff --git a/include/metaverse/bitcoin/math/elliptic_curve.hpp b/include/metaverse/bitcoin/math/elliptic_curve.hpp index 4a856fff1..0b40c7e67 100644 --- a/include/metaverse/bitcoin/math/elliptic_curve.hpp +++ b/include/metaverse/bitcoin/math/elliptic_curve.hpp @@ -147,7 +147,7 @@ bool is_public_key(data_slice point); /// Parse a DER encoded signature with optional strict DER enforcement. /// Treat an empty DER signature as invalid, in accordance with BIP66. -BC_API bool parse_signature(ec_signature& out, +BC_API bool parse_signature(ec_signature& out, const der_signature& der_signature, bool strict); /// Encode an EC signature as DER (strict). diff --git a/include/metaverse/bitcoin/math/uint256.hpp b/include/metaverse/bitcoin/math/uint256.hpp index bea3ed354..00ba55dda 100644 --- a/include/metaverse/bitcoin/math/uint256.hpp +++ b/include/metaverse/bitcoin/math/uint256.hpp @@ -18,7 +18,7 @@ namespace libbitcoin { -class BC_API uint_error +class BC_API uint_error : public std::runtime_error { public: @@ -32,8 +32,8 @@ template class BC_API base_uint { protected: - enum - { + enum + { WIDTH = BITS / 32 }; @@ -301,7 +301,7 @@ class BC_API uint256_t : public base_uint<256> { } - explicit uint256_t(const std::vector& vch) + explicit uint256_t(const std::vector& vch) : base_uint<256>(vch) { } diff --git a/include/metaverse/bitcoin/message/network_address.hpp b/include/metaverse/bitcoin/message/network_address.hpp index 9ba7b67c8..e4e282121 100644 --- a/include/metaverse/bitcoin/message/network_address.hpp +++ b/include/metaverse/bitcoin/message/network_address.hpp @@ -70,22 +70,22 @@ class BC_API network_address unsigned int get_byte(int n) const; bool is_ipv4() const; // IPv4 mapped address (::FFFF:0:0/96, 0.0.0.0/0) - bool is_ipv6() const; // IPv6 address (not mapped IPv4, not Tor) - bool is_private_network(); - bool is_RFC1918() const; // IPv4 private networks (10.0.0.0/8, 192.168.0.0/16, 172.16.0.0/12) - bool is_RFC3849() const; // IPv6 documentation address (2001:0DB8::/32) - bool is_RFC3927() const; // IPv4 autoconfig (169.254.0.0/16) - bool is_RFC3964() const; // IPv6 6to4 tunnelling (2002::/16) - bool is_RFC4193() const; // IPv6 unique local (FC00::/15) - bool is_RFC4380() const; // IPv6 Teredo tunnelling (2001::/32) - bool is_RFC4843() const; // IPv6 ORCHID (2001:10::/28) - bool is_RFC4862() const; // IPv6 autoconfig (FE80::/64) - bool is_RFC6052() const; // IPv6 well-known prefix (64:FF9B::/96) - bool is_RFC6145() const; // IPv6 IPv4-translated address (::FFFF:0:0:0/96) - bool is_tor() const; - bool is_local() const; - bool is_routable() const; - bool is_ulticast() const; + bool is_ipv6() const; // IPv6 address (not mapped IPv4, not Tor) + bool is_private_network(); + bool is_RFC1918() const; // IPv4 private networks (10.0.0.0/8, 192.168.0.0/16, 172.16.0.0/12) + bool is_RFC3849() const; // IPv6 documentation address (2001:0DB8::/32) + bool is_RFC3927() const; // IPv4 autoconfig (169.254.0.0/16) + bool is_RFC3964() const; // IPv6 6to4 tunnelling (2002::/16) + bool is_RFC4193() const; // IPv6 unique local (FC00::/15) + bool is_RFC4380() const; // IPv6 Teredo tunnelling (2001::/32) + bool is_RFC4843() const; // IPv6 ORCHID (2001:10::/28) + bool is_RFC4862() const; // IPv6 autoconfig (FE80::/64) + bool is_RFC6052() const; // IPv6 well-known prefix (64:FF9B::/96) + bool is_RFC6145() const; // IPv6 IPv4-translated address (::FFFF:0:0:0/96) + bool is_tor() const; + bool is_local() const; + bool is_routable() const; + bool is_ulticast() const; void reset(); uint64_t serialized_size(uint32_t version, diff --git a/include/metaverse/bitcoin/message/version.hpp b/include/metaverse/bitcoin/message/version.hpp index e7550792a..11d9a8add 100644 --- a/include/metaverse/bitcoin/message/version.hpp +++ b/include/metaverse/bitcoin/message/version.hpp @@ -33,7 +33,7 @@ namespace libbitcoin { namespace message { - + // The checksum is ignored by the version command. class BC_API version { diff --git a/include/metaverse/bitcoin/unicode/ifstream.hpp b/include/metaverse/bitcoin/unicode/ifstream.hpp index 801a29a7f..e04266d1e 100644 --- a/include/metaverse/bitcoin/unicode/ifstream.hpp +++ b/include/metaverse/bitcoin/unicode/ifstream.hpp @@ -40,7 +40,7 @@ class BC_API ifstream * @param[in] path The utf8 path to the file. * @param[in] mode The file opening mode. */ - ifstream(const std::string& path, + ifstream(const std::string& path, std::ifstream::openmode mode=std::ifstream::in); }; diff --git a/include/metaverse/bitcoin/unicode/unicode.hpp b/include/metaverse/bitcoin/unicode/unicode.hpp index 27493217e..faef05f2f 100644 --- a/include/metaverse/bitcoin/unicode/unicode.hpp +++ b/include/metaverse/bitcoin/unicode/unicode.hpp @@ -53,9 +53,9 @@ // Regarding Unicode in console applications: // // BC_USE_MVS_MAIN should be declared prior to bc::main() in a console -// application. This enables Unicode argument and environment processing in -// Windows. This macro implements main() and forwards to bc::main(), which -// should be implemented as if it was main() with the expectation that argv +// application. This enables Unicode argument and environment processing in +// Windows. This macro implements main() and forwards to bc::main(), which +// should be implemented as if it was main() with the expectation that argv // is utf8. // // Do not use std::cout|std::cerr|std::cin (aborts on assertion): @@ -72,7 +72,7 @@ // // When working with boost and utf8 narrow characters on Windows the thread // must be configured for utf8. When working with boost::filesystem::path the -// static path object must be imbued with the utf8 locale or paths will be +// static path object must be imbued with the utf8 locale or paths will be // incorrectly translated. #define BC_LOCALE_BACKEND "icu" diff --git a/include/metaverse/bitcoin/unicode/unicode_istream.hpp b/include/metaverse/bitcoin/unicode/unicode_istream.hpp index bfb2cda61..8cf47e23a 100644 --- a/include/metaverse/bitcoin/unicode/unicode_istream.hpp +++ b/include/metaverse/bitcoin/unicode/unicode_istream.hpp @@ -26,7 +26,7 @@ #include namespace libbitcoin { - + /** * Class to expose a narrowing input stream. * std::wcin must be patched by console_streambuf if used for Windows input. @@ -43,7 +43,7 @@ class BC_API unicode_istream */ unicode_istream(std::istream& narrow_stream, std::wistream& wide_stream, size_t size); - + /** * Delete the unicode_streambuf that wraps wide_stream. */ diff --git a/include/metaverse/bitcoin/unicode/unicode_ostream.hpp b/include/metaverse/bitcoin/unicode/unicode_ostream.hpp index 450a9c308..9cb979607 100644 --- a/include/metaverse/bitcoin/unicode/unicode_ostream.hpp +++ b/include/metaverse/bitcoin/unicode/unicode_ostream.hpp @@ -42,7 +42,7 @@ class BC_API unicode_ostream */ unicode_ostream(std::ostream& narrow_stream, std::wostream& wide_stream, size_t size); - + /** * Delete the unicode_streambuf that wraps wide_stream. */ diff --git a/include/metaverse/bitcoin/utility/container_source.hpp b/include/metaverse/bitcoin/utility/container_source.hpp index 4bd00de7f..629589244 100644 --- a/include/metaverse/bitcoin/utility/container_source.hpp +++ b/include/metaverse/bitcoin/utility/container_source.hpp @@ -55,7 +55,7 @@ class BC_API container_source return -1; const auto value = static_cast(result); - DEBUG_ONLY(const auto maximum = + DEBUG_ONLY(const auto maximum = std::numeric_limits::max()); BITCOIN_ASSERT(value < maximum); BITCOIN_ASSERT(position_ + value < maximum); diff --git a/include/metaverse/bitcoin/utility/data.hpp b/include/metaverse/bitcoin/utility/data.hpp index 0f89135dc..7311099c2 100644 --- a/include/metaverse/bitcoin/utility/data.hpp +++ b/include/metaverse/bitcoin/utility/data.hpp @@ -128,7 +128,7 @@ data_chunk to_chunk(const Source& bytes); /** * Perform an exclusive or (xor) across two buffers to the length specified. - * Return the resulting buffer. Caller must ensure length does not exceed + * Return the resulting buffer. Caller must ensure length does not exceed * either buffer. */ template diff --git a/include/metaverse/bitcoin/utility/deadline.hpp b/include/metaverse/bitcoin/utility/deadline.hpp index a8363a6c9..e6b41af4f 100644 --- a/include/metaverse/bitcoin/utility/deadline.hpp +++ b/include/metaverse/bitcoin/utility/deadline.hpp @@ -43,7 +43,7 @@ class BC_API deadline public: typedef std::shared_ptr ptr; typedef std::function handler; - + /** * Construct a deadline timer. * @param[in] pool The thread pool used by the timer. diff --git a/include/metaverse/bitcoin/utility/delegates.hpp b/include/metaverse/bitcoin/utility/delegates.hpp index 4f87ac6a4..e25fc91fb 100644 --- a/include/metaverse/bitcoin/utility/delegates.hpp +++ b/include/metaverse/bitcoin/utility/delegates.hpp @@ -26,7 +26,7 @@ namespace libbitcoin { namespace delegates { - + #define FORWARD_ARGS(args) \ std::forward(args)... #define FORWARD_HANDLER(handler) \ diff --git a/include/metaverse/bitcoin/utility/istream_reader.hpp b/include/metaverse/bitcoin/utility/istream_reader.hpp index 463ececf3..a2375350c 100644 --- a/include/metaverse/bitcoin/utility/istream_reader.hpp +++ b/include/metaverse/bitcoin/utility/istream_reader.hpp @@ -45,7 +45,7 @@ class BC_API istream_reader short_hash read_short_hash(); mini_hash read_mini_hash(); - // These read data in little endian format: + // These read data in little endian format: uint16_t read_2_bytes_little_endian(); uint32_t read_4_bytes_little_endian(); uint64_t read_8_bytes_little_endian(); diff --git a/include/metaverse/bitcoin/utility/log.hpp b/include/metaverse/bitcoin/utility/log.hpp index 32d486abf..ea352d7fc 100644 --- a/include/metaverse/bitcoin/utility/log.hpp +++ b/include/metaverse/bitcoin/utility/log.hpp @@ -34,7 +34,7 @@ class BC_API log public: enum class level { - trace, + trace, debug, info, warning, diff --git a/include/metaverse/bitcoin/utility/logging.hpp b/include/metaverse/bitcoin/utility/logging.hpp index af701000f..f2495c2bc 100644 --- a/include/metaverse/bitcoin/utility/logging.hpp +++ b/include/metaverse/bitcoin/utility/logging.hpp @@ -42,14 +42,14 @@ class Logger{ initialize_logging(debug_log_, error_log_, std::cout, std::cerr); } - self(const self&) = delete; - self(const self&&) = delete; + self(const self&) = delete; + self(const self&&) = delete; ~self() noexcept { log::clear(); - debug_log_.close(); - error_log_.close(); + debug_log_.close(); + error_log_.close(); } public: diff --git a/include/metaverse/bitcoin/utility/path.hpp b/include/metaverse/bitcoin/utility/path.hpp index 268bffee9..37a61d821 100644 --- a/include/metaverse/bitcoin/utility/path.hpp +++ b/include/metaverse/bitcoin/utility/path.hpp @@ -25,9 +25,9 @@ namespace libbitcoin { - const boost::filesystem::path& default_data_path(); + const boost::filesystem::path& default_data_path(); - boost::filesystem::path webpage_path(); + boost::filesystem::path webpage_path(); }//namespace libbitcoin diff --git a/include/metaverse/bitcoin/utility/serializer.hpp b/include/metaverse/bitcoin/utility/serializer.hpp index ac54b438f..af0de7933 100644 --- a/include/metaverse/bitcoin/utility/serializer.hpp +++ b/include/metaverse/bitcoin/utility/serializer.hpp @@ -97,7 +97,7 @@ class serializer */ template void write_little_endian(T n); - + /** * Encodes a list of bytes. */ diff --git a/include/metaverse/bitcoin/utility/threadpool.hpp b/include/metaverse/bitcoin/utility/threadpool.hpp index 0269d6f09..b4b7152bf 100644 --- a/include/metaverse/bitcoin/utility/threadpool.hpp +++ b/include/metaverse/bitcoin/utility/threadpool.hpp @@ -42,7 +42,7 @@ class BC_API threadpool * @param[in] number_threads Number of threads to spawn. * @param[in] priority Priority of threads to spawn. */ - threadpool(size_t number_threads=0, + threadpool(size_t number_threads=0, thread_priority priority=thread_priority::normal); ~threadpool(); @@ -55,7 +55,7 @@ class BC_API threadpool * @param[in] number_threads Number of threads to add. * @param[in] priority Priority of threads to add. */ - void spawn(size_t number_threads=1, + void spawn(size_t number_threads=1, thread_priority priority=thread_priority::normal); /** diff --git a/include/metaverse/bitcoin/utility/timer.hpp b/include/metaverse/bitcoin/utility/timer.hpp index 5bbc0eadf..cecc1afdf 100644 --- a/include/metaverse/bitcoin/utility/timer.hpp +++ b/include/metaverse/bitcoin/utility/timer.hpp @@ -31,7 +31,7 @@ namespace libbitcoin { // From: github.com/picanumber/bureaucrat/blob/master/time_lapse.h /// Class to measure the execution time of a callable. -template +template struct timer { /// Returns the quantity (count) of the elapsed time as TimeT units. diff --git a/include/metaverse/bitcoin/utility/work.hpp b/include/metaverse/bitcoin/utility/work.hpp index 28aa0d992..f6279f519 100644 --- a/include/metaverse/bitcoin/utility/work.hpp +++ b/include/metaverse/bitcoin/utility/work.hpp @@ -34,7 +34,7 @@ namespace libbitcoin { #define ORDERED "ordered" #define UNORDERED "unordered" #define CONCURRENT "concurrent" - + #define FORWARD_ARGS(args) \ std::forward(args)... #define FORWARD_HANDLER(handler) \ diff --git a/include/metaverse/bitcoin/wallet/ek_private.hpp b/include/metaverse/bitcoin/wallet/ek_private.hpp index 64d89eee8..141ecabbd 100644 --- a/include/metaverse/bitcoin/wallet/ek_private.hpp +++ b/include/metaverse/bitcoin/wallet/ek_private.hpp @@ -46,7 +46,7 @@ class BC_API ek_private ek_private& operator=(const ek_private& other); friend std::istream& operator>>(std::istream& in, ek_private& to); friend std::ostream& operator<<(std::ostream& out, const ek_private& of); - + /// Cast operators. operator const bool() const; operator const encrypted_private&() const; diff --git a/include/metaverse/bitcoin/wallet/ek_token.hpp b/include/metaverse/bitcoin/wallet/ek_token.hpp index abf11cb55..c3c45e3a1 100644 --- a/include/metaverse/bitcoin/wallet/ek_token.hpp +++ b/include/metaverse/bitcoin/wallet/ek_token.hpp @@ -48,7 +48,7 @@ class BC_API ek_token ek_token& operator=(const ek_token& other); friend std::istream& operator>>(std::istream& in, ek_token& to); friend std::ostream& operator<<(std::ostream& out, const ek_token& of); - + /// Cast operators. operator const bool() const; operator const encrypted_token&() const; diff --git a/include/metaverse/bitcoin/wallet/encrypted_keys.hpp b/include/metaverse/bitcoin/wallet/encrypted_keys.hpp index 274ee2339..3d65debee 100644 --- a/include/metaverse/bitcoin/wallet/encrypted_keys.hpp +++ b/include/metaverse/bitcoin/wallet/encrypted_keys.hpp @@ -119,7 +119,7 @@ BC_API bool create_token(encrypted_token& out_token, /** * Create an encrypted private key from an intermediate passphrase. - * The `out_point` paramter is always compressed, so to use it it should be + * The `out_point` paramter is always compressed, so to use it it should be * decompressed as necessary to match the state of the `compressed` parameter. * @param[out] out_private The new encrypted private key. * @param[out] out_point The ec compressed public key of the new key pair. @@ -136,7 +136,7 @@ BC_API bool create_key_pair(encrypted_private& out_private, /** * DEPRECATED * Create an encrypted key pair from an intermediate passphrase. - * The `out_point` paramter is always compressed, so to use it it should be + * The `out_point` paramter is always compressed, so to use it it should be * decompressed as necessary to match the state of the `compressed` parameter. * @param[out] out_private The new encrypted private key. * @param[out] out_public The new encrypted public key. @@ -155,11 +155,11 @@ BC_API bool create_key_pair(encrypted_private& out_private, void aes256_common_encrypt(data_chunk& mnemonic, data_chunk& passphrase, data_chunk& encry_output); void aes256_common_decrypt(const data_chunk& mnemonic, data_chunk& passphrase, data_chunk& decry_output); -void encrypt_string(const std::string& mnemonic, - std::string& passphrase, std::string& encry_output); +void encrypt_string(const std::string& mnemonic, + std::string& passphrase, std::string& encry_output); -void decrypt_string(const std::string& mnemonic, - std::string& passphrase, std::string& decry_output); +void decrypt_string(const std::string& mnemonic, + std::string& passphrase, std::string& decry_output); #ifdef WITH_ICU diff --git a/include/metaverse/bitcoin/wallet/hd_public.hpp b/include/metaverse/bitcoin/wallet/hd_public.hpp index 440b35d2f..8fba264c1 100644 --- a/include/metaverse/bitcoin/wallet/hd_public.hpp +++ b/include/metaverse/bitcoin/wallet/hd_public.hpp @@ -30,7 +30,7 @@ namespace libbitcoin { namespace wallet { - + /// A constant used in key derivation. static BC_CONSTEXPR uint32_t hd_first_hardened_key = 1 << 31; diff --git a/include/metaverse/bitcoin/wallet/message.hpp b/include/metaverse/bitcoin/wallet/message.hpp index beb3f0cf7..2fba0def8 100644 --- a/include/metaverse/bitcoin/wallet/message.hpp +++ b/include/metaverse/bitcoin/wallet/message.hpp @@ -30,7 +30,7 @@ namespace libbitcoin { namespace wallet { - + /** * A message signature is an EC signature with one prefix byte. */ diff --git a/include/metaverse/bitcoin/wallet/payment_address.hpp b/include/metaverse/bitcoin/wallet/payment_address.hpp index 61e32b90c..7de5beeaf 100644 --- a/include/metaverse/bitcoin/wallet/payment_address.hpp +++ b/include/metaverse/bitcoin/wallet/payment_address.hpp @@ -36,7 +36,7 @@ namespace libbitcoin { namespace wallet { - + static BC_CONSTEXPR size_t payment_size = 1u + short_hash_size + checksum_size; typedef byte_array payment; diff --git a/include/metaverse/bitcoin/wallet/stealth_address.hpp b/include/metaverse/bitcoin/wallet/stealth_address.hpp index 75d3ce1d4..cd3c2c1ee 100644 --- a/include/metaverse/bitcoin/wallet/stealth_address.hpp +++ b/include/metaverse/bitcoin/wallet/stealth_address.hpp @@ -32,7 +32,7 @@ namespace libbitcoin { namespace wallet { - + /// A class for working with stealth payment addresses. class BC_API stealth_address { diff --git a/include/metaverse/blockchain.hpp b/include/metaverse/blockchain.hpp index 830531b21..9e539d3b9 100644 --- a/include/metaverse/blockchain.hpp +++ b/include/metaverse/blockchain.hpp @@ -8,7 +8,7 @@ #define MVS_BLOCKCHAIN_HPP /** - * API Users: Include only this header. Direct use of other headers is fragile + * API Users: Include only this header. Direct use of other headers is fragile * and unsupported as header organization is subject to change. * * Maintainers: Do not include this header internal to this library. diff --git a/include/metaverse/blockchain/transaction_pool.hpp b/include/metaverse/blockchain/transaction_pool.hpp index bad5d2e8a..d1fced6a3 100644 --- a/include/metaverse/blockchain/transaction_pool.hpp +++ b/include/metaverse/blockchain/transaction_pool.hpp @@ -105,7 +105,7 @@ class BCB_API transaction_pool bool stopped(); const_iterator find(const hash_digest& tx_hash) const; - + bool handle_reorganized(const code& ec, size_t fork_point, const block_list& new_blocks, const block_list& replaced_blocks); void handle_validated(const code& ec, transaction_ptr tx, diff --git a/include/metaverse/client.hpp b/include/metaverse/client.hpp index 78a7db251..f6ad04cc3 100644 --- a/include/metaverse/client.hpp +++ b/include/metaverse/client.hpp @@ -8,7 +8,7 @@ #define MVS_CLIENT_HPP /** - * API Users: Include only this header. Direct use of other headers is fragile + * API Users: Include only this header. Direct use of other headers is fragile * and unsupported as header organization is subject to change. * * Maintainers: Do not include this header internal to this library. diff --git a/include/metaverse/client/define.hpp b/include/metaverse/client/define.hpp index b9d8a32f6..899f04903 100644 --- a/include/metaverse/client/define.hpp +++ b/include/metaverse/client/define.hpp @@ -23,9 +23,9 @@ #include -// We use the generic helper definitions in libbitcoin to define BCX_API +// We use the generic helper definitions in libbitcoin to define BCX_API // and BCX_INTERNAL. BCX_API is used for the public API symbols. It either DLL -// imports or DLL exports (or does nothing for static build) BCX_INTERNAL is +// imports or DLL exports (or does nothing for static build) BCX_INTERNAL is // used for non-api symbols. #if defined BCC_STATIC diff --git a/include/metaverse/consensus.hpp b/include/metaverse/consensus.hpp index 0b31c3a98..9462f0890 100644 --- a/include/metaverse/consensus.hpp +++ b/include/metaverse/consensus.hpp @@ -8,7 +8,7 @@ #define MVS_CONSENSUS_HPP /** - * API Users: Include only this header. Direct use of other headers is fragile + * API Users: Include only this header. Direct use of other headers is fragile * and unsupported as header organization is subject to change. * * Maintainers: Do not include this header internal to this library. diff --git a/include/metaverse/consensus/consensus.hpp b/include/metaverse/consensus/consensus.hpp index 5f6d76ff6..bfa395105 100644 --- a/include/metaverse/consensus/consensus.hpp +++ b/include/metaverse/consensus/consensus.hpp @@ -29,7 +29,7 @@ namespace libbitcoin { namespace consensus { - + // Helper class, not published. This is tested internal to verify_script. class BCK_API TxInputStream { diff --git a/include/metaverse/consensus/export.hpp b/include/metaverse/consensus/export.hpp index 388d6e409..be3efb773 100644 --- a/include/metaverse/consensus/export.hpp +++ b/include/metaverse/consensus/export.hpp @@ -29,7 +29,7 @@ namespace libbitcoin { namespace consensus { /** - * Result values from calling verify_script. + * Result values from calling verify_script. */ typedef enum verify_result_type { @@ -87,7 +87,7 @@ typedef enum verify_result_type } verify_result; /** - * Flags to use when calling verify_script. + * Flags to use when calling verify_script. */ typedef enum verify_flags_type { @@ -103,8 +103,8 @@ typedef enum verify_flags_type /** * Passing a non-strict-DER signature or one with undefined hashtype to a - * checksig operation causes script failure. Evaluating a pubkey that is - * not (0x04 + 64 bytes) or (0x02 or 0x03 + 32 bytes) by checksig causes + * checksig operation causes script failure. Evaluating a pubkey that is + * not (0x04 + 64 bytes) or (0x02 or 0x03 + 32 bytes) by checksig causes * script failure. (softfork safe, but not used or intended as a consensus * rule). */ @@ -184,14 +184,14 @@ typedef enum verify_flags_type * @param[in] transaction_size The byte length of the transaction. * @param[in] prevout_script The script public key to verify against. * @param[in] prevout_script_size The byte length of the script public key. - * @param[in] tx_input_index The zero-based index of the transaction + * @param[in] tx_input_index The zero-based index of the transaction * input with signature to be verified. * @param[in] flags Verification constraint flags. * @returns A script verification result code. */ BCK_API verify_result_type verify_script(const unsigned char* transaction, size_t transaction_size, const unsigned char* prevout_script, - size_t prevout_script_size, unsigned int tx_input_index, + size_t prevout_script_size, unsigned int tx_input_index, unsigned int flags); } // namespace consensus diff --git a/include/metaverse/consensus/libdevcore/Base64.h b/include/metaverse/consensus/libdevcore/Base64.h index 516766382..201da5f6e 100644 --- a/include/metaverse/consensus/libdevcore/Base64.h +++ b/include/metaverse/consensus/libdevcore/Base64.h @@ -12,12 +12,12 @@ freely, subject to the following restrictions: 1. The origin of this source code must not be misrepresented; you must not - claim that you wrote the original source code. If you use this source code - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. + claim that you wrote the original source code. If you use this source code + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original source code. + misrepresented as being the original source code. 3. This notice may not be removed or altered from any source distribution. @@ -40,23 +40,23 @@ bytes fromBase64(std::string const& _in); template inline std::string toBase36(FixedHash const& _h) { - static char const* c_alphabet = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; - typename FixedHash::Arith a = _h; - std::string ret; - for (; a > 0; a /= 36) - { - unsigned r = (unsigned)(a - a / 36 * 36); // boost's % is broken - ret = c_alphabet[r] + ret; - } - return ret; + static char const* c_alphabet = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; + typename FixedHash::Arith a = _h; + std::string ret; + for (; a > 0; a /= 36) + { + unsigned r = (unsigned)(a - a / 36 * 36); // boost's % is broken + ret = c_alphabet[r] + ret; + } + return ret; } template inline FixedHash fromBase36(std::string const& _h) { - typename FixedHash::Arith ret = 0; - for (char c: _h) - ret = ret * 36 + (c < 'A' ? c - '0' : (c - 'A' + 10)); - return ret; + typename FixedHash::Arith ret = 0; + for (char c: _h) + ret = ret * 36 + (c < 'A' ? c - '0' : (c - 'A' + 10)); + return ret; } } diff --git a/include/metaverse/consensus/libdevcore/BasicType.h b/include/metaverse/consensus/libdevcore/BasicType.h index 5c7a4956a..b48d7671f 100644 --- a/include/metaverse/consensus/libdevcore/BasicType.h +++ b/include/metaverse/consensus/libdevcore/BasicType.h @@ -17,24 +17,24 @@ namespace libbitcoin class HeaderAux { public: - static HeaderAux* get(); - static h256 seedHash(libbitcoin::chain::header& _bi); - static h256 hashHead(libbitcoin::chain::header& _bi); - static h256 boundary(libbitcoin::chain::header& _bi) { auto d = _bi.bits; return d ? (h256)u256(((bigint(1) << 255)-bigint(1) +(bigint(1) << 255) ) / d) : h256(); } - static u256 calculateDifficulty(libbitcoin::chain::header& _bi, libbitcoin::chain::header& _parent); - static uint64_t number(h256& _seedHash); - static uint64_t cacheSize(libbitcoin::chain::header& _header); - static uint64_t dataSize(uint64_t _blockNumber); + static HeaderAux* get(); + static h256 seedHash(libbitcoin::chain::header& _bi); + static h256 hashHead(libbitcoin::chain::header& _bi); + static h256 boundary(libbitcoin::chain::header& _bi) { auto d = _bi.bits; return d ? (h256)u256(((bigint(1) << 255)-bigint(1) +(bigint(1) << 255) ) / d) : h256(); } + static u256 calculateDifficulty(libbitcoin::chain::header& _bi, libbitcoin::chain::header& _parent); + static uint64_t number(h256& _seedHash); + static uint64_t cacheSize(libbitcoin::chain::header& _header); + static uint64_t dataSize(uint64_t _blockNumber); static void set_as_testnet(){ is_testnet = true; } private: - HeaderAux() {} - Mutex x_epochs; - h256s m_seedHashes; - std::unordered_map m_epochs; - static HeaderAux* s_this; - static bool is_testnet; + HeaderAux() {} + Mutex x_epochs; + h256s m_seedHashes; + std::unordered_map m_epochs; + static HeaderAux* s_this; + static bool is_testnet; }; struct Solution { @@ -79,37 +79,37 @@ using FullType = std::shared_ptr; struct ChainOperationParams { - ChainOperationParams(); + ChainOperationParams(); - explicit operator bool() const { return accountStartNonce != Invalid256; } + explicit operator bool() const { return accountStartNonce != Invalid256; } - /// The chain sealer name: e.g. Ethash, NoProof, BasicAuthority - std::string sealEngineName = "NoProof"; + /// The chain sealer name: e.g. Ethash, NoProof, BasicAuthority + std::string sealEngineName = "NoProof"; - /// General chain params. - u256 blockReward = 0; - u256 maximumExtraDataSize = 1024; - u256 accountStartNonce = 0; - bool tieBreakingGas = true; + /// General chain params. + u256 blockReward = 0; + u256 maximumExtraDataSize = 1024; + u256 accountStartNonce = 0; + bool tieBreakingGas = true; - /// Precompiled contracts as specified in the chain params. + /// Precompiled contracts as specified in the chain params. // std::unordered_map precompiled; - /** - * @brief Additional parameters. - * - * e.g. Ethash specific: - * - minGasLimit - * - maxGasLimit - * - gasLimitBoundDivisor - * - minimumDifficulty - * - difficultyBoundDivisor - * - durationLimit - */ - std::unordered_map otherParams; - - /// Convenience method to get an otherParam as a u256 int. - u256 u256Param(std::string const& _name); + /** + * @brief Additional parameters. + * + * e.g. Ethash specific: + * - minGasLimit + * - maxGasLimit + * - gasLimitBoundDivisor + * - minimumDifficulty + * - difficultyBoundDivisor + * - durationLimit + */ + std::unordered_map otherParams; + + /// Convenience method to get an otherParam as a u256 int. + u256 u256Param(std::string const& _name); }; } diff --git a/include/metaverse/consensus/libdevcore/Common.h b/include/metaverse/consensus/libdevcore/Common.h index 500e57c8a..9e9310ea9 100644 --- a/include/metaverse/consensus/libdevcore/Common.h +++ b/include/metaverse/consensus/libdevcore/Common.h @@ -1,18 +1,18 @@ /* - This file is part of cpp-ethereum. + This file is part of cpp-ethereum. - cpp-ethereum is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. + cpp-ethereum is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. - cpp-ethereum is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. + cpp-ethereum is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. - You should have received a copy of the GNU General Public License - along with cpp-ethereum. If not, see . + You should have received a copy of the GNU General Public License + along with cpp-ethereum. If not, see . */ /** @file Common.h * @author Gav Wood @@ -50,7 +50,7 @@ //#pragma GCC diagnostic ignored "-Wunused-parameter" #include #if (BOOST_VERSION == 105800) - #include "boost_multiprecision_number_compare_bug_workaround.hpp" + #include "boost_multiprecision_number_compare_bug_workaround.hpp" #endif //#include #include @@ -87,39 +87,39 @@ template class secure_vector { public: - secure_vector() {} - secure_vector(secure_vector const& /*_c*/) = default; // See https://github.com/ethereum/libweb3core/pull/44 - explicit secure_vector(unsigned _size): m_data(_size) {} - explicit secure_vector(unsigned _size, T _item): m_data(_size, _item) {} - explicit secure_vector(std::vector const& _c): m_data(_c) {} - explicit secure_vector(vector_ref _c): m_data(_c.data(), _c.data() + _c.size()) {} - explicit secure_vector(vector_ref _c): m_data(_c.data(), _c.data() + _c.size()) {} - ~secure_vector() { ref().cleanse(); } + secure_vector() {} + secure_vector(secure_vector const& /*_c*/) = default; // See https://github.com/ethereum/libweb3core/pull/44 + explicit secure_vector(unsigned _size): m_data(_size) {} + explicit secure_vector(unsigned _size, T _item): m_data(_size, _item) {} + explicit secure_vector(std::vector const& _c): m_data(_c) {} + explicit secure_vector(vector_ref _c): m_data(_c.data(), _c.data() + _c.size()) {} + explicit secure_vector(vector_ref _c): m_data(_c.data(), _c.data() + _c.size()) {} + ~secure_vector() { ref().cleanse(); } - secure_vector& operator=(secure_vector const& _c) - { - if (&_c == this) - return *this; + secure_vector& operator=(secure_vector const& _c) + { + if (&_c == this) + return *this; - ref().cleanse(); - m_data = _c.m_data; - return *this; - } - std::vector& writable() { clear(); return m_data; } - std::vector const& makeInsecure() const { return m_data; } + ref().cleanse(); + m_data = _c.m_data; + return *this; + } + std::vector& writable() { clear(); return m_data; } + std::vector const& makeInsecure() const { return m_data; } - void clear() { ref().cleanse(); } + void clear() { ref().cleanse(); } - vector_ref ref() { return vector_ref(&m_data); } - vector_ref ref() const { return vector_ref(&m_data); } + vector_ref ref() { return vector_ref(&m_data); } + vector_ref ref() const { return vector_ref(&m_data); } - size_t size() const { return m_data.size(); } - bool empty() const { return m_data.empty(); } + size_t size() const { return m_data.size(); } + bool empty() const { return m_data.empty(); } - void swap(secure_vector& io_other) { m_data.swap(io_other.m_data); } + void swap(secure_vector& io_other) { m_data.swap(io_other.m_data); } private: - std::vector m_data; + std::vector m_data; }; using bytesSec = secure_vector; @@ -164,21 +164,21 @@ extern const u256 Invalid256; /// Interprets @a _u as a two's complement signed number and returns the resulting s256. inline s256 u2s(u256 _u) { - static const bigint c_end = bigint(1) << 256; - if (boost::multiprecision::bit_test(_u, 255)) - return s256(-(c_end - _u)); - else - return s256(_u); + static const bigint c_end = bigint(1) << 256; + if (boost::multiprecision::bit_test(_u, 255)) + return s256(-(c_end - _u)); + else + return s256(_u); } /// @returns the two's complement signed representation of the signed number _u. inline u256 s2u(s256 _u) { - static const bigint c_end = bigint(1) << 256; + static const bigint c_end = bigint(1) << 256; if (_u >= 0) - return u256(_u); + return u256(_u); else - return u256(c_end + _u); + return u256(c_end + _u); } /// Converts given int to a string and appends one of a series of units according to its size. @@ -187,61 +187,61 @@ std::string inUnits(bigint const& _b, strings const& _units); /// @returns the smallest n >= 0 such that (1 << n) >= _x inline unsigned int toLog2(u256 _x) { - unsigned ret; - for (ret = 0; _x >>= 1; ++ret) {} - return ret; + unsigned ret; + for (ret = 0; _x >>= 1; ++ret) {} + return ret; } template inline u256 exp10() { - return exp10() * u256(10); + return exp10() * u256(10); } template <> inline u256 exp10<0>() { - return u256(1); + return u256(1); } /// @returns the absolute distance between _a and _b. template inline N diff(N const& _a, N const& _b) { - return std::max(_a, _b) - std::min(_a, _b); + return std::max(_a, _b) - std::min(_a, _b); } /// RAII utility class whose destructor calls a given function. class ScopeGuard { public: - ScopeGuard(std::function _f): m_f(_f) {} - ~ScopeGuard() { m_f(); } + ScopeGuard(std::function _f): m_f(_f) {} + ~ScopeGuard() { m_f(); } private: - std::function m_f; + std::function m_f; }; /// Inheritable for classes that have invariants. class HasInvariants { public: - /// Reimplement to specify the invariants. - virtual bool invariants() const = 0; + /// Reimplement to specify the invariants. + virtual bool invariants() const = 0; }; /// RAII checker for invariant assertions. class InvariantChecker { public: - InvariantChecker(HasInvariants* _this, char const* _fn, char const* _file, int _line): m_this(_this), m_function(_fn), m_file(_file), m_line(_line) { checkInvariants(_this, _fn , _file, _line, true); } - ~InvariantChecker() { checkInvariants(m_this, m_function, m_file, m_line, false); } - /// Check invariants are met, throw if not. - static void checkInvariants(HasInvariants const* _this, char const* _fn, char const* _file, int line, bool _pre); + InvariantChecker(HasInvariants* _this, char const* _fn, char const* _file, int _line): m_this(_this), m_function(_fn), m_file(_file), m_line(_line) { checkInvariants(_this, _fn , _file, _line, true); } + ~InvariantChecker() { checkInvariants(m_this, m_function, m_file, m_line, false); } + /// Check invariants are met, throw if not. + static void checkInvariants(HasInvariants const* _this, char const* _fn, char const* _file, int line, bool _pre); private: - HasInvariants const* m_this; - char const* m_function; - char const* m_file; - int m_line; + HasInvariants const* m_this; + char const* m_function; + char const* m_file; + int m_line; }; /// Scope guard for invariant check in a class derived from HasInvariants. @@ -257,26 +257,26 @@ class InvariantChecker class TimerHelper { public: - TimerHelper(std::string const& _id, unsigned _msReportWhenGreater = 0): m_t(std::chrono::high_resolution_clock::now()), m_id(_id), m_ms(_msReportWhenGreater) {} - ~TimerHelper(); + TimerHelper(std::string const& _id, unsigned _msReportWhenGreater = 0): m_t(std::chrono::high_resolution_clock::now()), m_id(_id), m_ms(_msReportWhenGreater) {} + ~TimerHelper(); private: - std::chrono::high_resolution_clock::time_point m_t; - std::string m_id; - unsigned m_ms; + std::chrono::high_resolution_clock::time_point m_t; + std::string m_id; + unsigned m_ms; }; class Timer { public: - Timer() { restart(); } + Timer() { restart(); } - std::chrono::high_resolution_clock::duration duration() const { return std::chrono::high_resolution_clock::now() - m_t; } - double elapsed() const { return std::chrono::duration_cast(duration()).count() / 1000000.0; } - void restart() { m_t = std::chrono::high_resolution_clock::now(); } + std::chrono::high_resolution_clock::duration duration() const { return std::chrono::high_resolution_clock::now() - m_t; } + double elapsed() const { return std::chrono::duration_cast(duration()).count() / 1000000.0; } + void restart() { m_t = std::chrono::high_resolution_clock::now(); } private: - std::chrono::high_resolution_clock::time_point m_t; + std::chrono::high_resolution_clock::time_point m_t; }; #define DEV_TIMED(S) for (::std::pair<::dev::TimerHelper, bool> __eth_t(S, true); __eth_t.second; __eth_t.second = false) @@ -304,10 +304,10 @@ class Timer enum class WithExisting: int { - Trust = 0, - Verify, - Rescue, - Kill + Trust = 0, + Verify, + Rescue, + Kill }; /// Get the current time in seconds since the epoch in UTC @@ -320,17 +320,17 @@ namespace std inline libbitcoin::WithExisting max(libbitcoin::WithExisting _a, libbitcoin::WithExisting _b) { - return static_cast(max(static_cast(_a), static_cast(_b))); + return static_cast(max(static_cast(_a), static_cast(_b))); } template <> struct hash { - size_t operator()(libbitcoin::u256 const& _a) const - { - unsigned size = _a.backend().size(); - auto limbs = _a.backend().limbs(); - return libbitcoin::hash_range(limbs, limbs + size); - } + size_t operator()(libbitcoin::u256 const& _a) const + { + unsigned size = _a.backend().size(); + auto limbs = _a.backend().limbs(); + return libbitcoin::hash_range(limbs, limbs + size); + } }; } diff --git a/include/metaverse/consensus/libdevcore/CommonData.h b/include/metaverse/consensus/libdevcore/CommonData.h index 89bb3100c..53a477a50 100644 --- a/include/metaverse/consensus/libdevcore/CommonData.h +++ b/include/metaverse/consensus/libdevcore/CommonData.h @@ -1,18 +1,18 @@ /* - This file is part of cpp-ethereum. + This file is part of cpp-ethereum. - cpp-ethereum is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. + cpp-ethereum is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. - cpp-ethereum is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. + cpp-ethereum is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. - You should have received a copy of the GNU General Public License - along with cpp-ethereum. If not, see . + You should have received a copy of the GNU General Public License + along with cpp-ethereum. If not, see . */ /** @file CommonData.h * @author Gav Wood @@ -38,14 +38,14 @@ namespace libbitcoin enum class WhenError { - DontThrow = 0, - Throw = 1, + DontThrow = 0, + Throw = 1, }; enum class HexPrefix { - DontAdd = 0, - Add = 1, + DontAdd = 0, + Add = 1, }; /// Convert a series of bytes to the corresponding string of hex duplets. /// @param _w specifies the width of the first of the elements. Defaults to two - enough to represent a byte. @@ -53,11 +53,11 @@ enum class HexPrefix template std::string toHex(T const& _data, int _w = 2, HexPrefix _prefix = HexPrefix::DontAdd) { - std::ostringstream ret; - unsigned ii = 0; - for (auto i: _data) - ret << std::hex << std::setfill('0') << std::setw(ii++ ? 2 : _w) << (int)(typename std::make_unsigned::type)i; - return (_prefix == HexPrefix::Add) ? "0x" + ret.str() : ret.str(); + std::ostringstream ret; + unsigned ii = 0; + for (auto i: _data) + ret << std::hex << std::setfill('0') << std::setw(ii++ ? 2 : _w) << (int)(typename std::make_unsigned::type)i; + return (_prefix == HexPrefix::Add) ? "0x" + ret.str() : ret.str(); } /// Converts a (printable) ASCII hex string into the corresponding byte stream. @@ -71,27 +71,27 @@ bool isHex(std::string const& _s) noexcept; /// @returns true if @a _hash is a hash conforming to FixedHash type @a T. template static bool isHash(std::string const& _hash) { - return (_hash.size() == T::size * 2 || (_hash.size() == T::size * 2 + 2 && _hash.substr(0, 2) == "0x")) && isHex(_hash); + return (_hash.size() == T::size * 2 || (_hash.size() == T::size * 2 + 2 && _hash.substr(0, 2) == "0x")) && isHex(_hash); } /// Converts byte array to a string containing the same (binary) data. Unless /// the byte array happens to contain ASCII data, this won't be printable. inline std::string asString(bytes const& _b) { - return std::string((char const*)_b.data(), (char const*)(_b.data() + _b.size())); + return std::string((char const*)_b.data(), (char const*)(_b.data() + _b.size())); } /// Converts byte array ref to a string containing the same (binary) data. Unless /// the byte array happens to contain ASCII data, this won't be printable. inline std::string asString(bytesConstRef _b) { - return std::string((char const*)_b.data(), (char const*)(_b.data() + _b.size())); + return std::string((char const*)_b.data(), (char const*)(_b.data() + _b.size())); } /// Converts a string to a byte array containing the string's (byte) data. inline bytes asBytes(std::string const& _b) { - return bytes((byte const*)_b.data(), (byte const*)(_b.data() + _b.size())); + return bytes((byte const*)_b.data(), (byte const*)(_b.data() + _b.size())); } /// Converts a string into the big-endian base-16 stream of integers (NOT ASCII). @@ -109,12 +109,12 @@ bytes asNibbles(bytesConstRef const& _s); template inline void toBigEndian(T _val, Out& o_out) { - static_assert(std::is_same::value || !std::numeric_limits::is_signed, "only unsigned types or bigint supported"); //bigint does not carry sign bit on shift - for (auto i = o_out.size(); i != 0; _val >>= 8, i--) - { - T v = _val & (T)0xff; - o_out[i - 1] = (typename Out::value_type)(uint8_t)v; - } + static_assert(std::is_same::value || !std::numeric_limits::is_signed, "only unsigned types or bigint supported"); //bigint does not carry sign bit on shift + for (auto i = o_out.size(); i != 0; _val >>= 8, i--) + { + T v = _val & (T)0xff; + o_out[i - 1] = (typename Out::value_type)(uint8_t)v; + } } /// Converts a big-endian byte-stream represented on a templated collection to a templated integer value. @@ -123,10 +123,10 @@ inline void toBigEndian(T _val, Out& o_out) template inline T fromBigEndian(_In const& _bytes) { - T ret = (T)0; - for (auto i: _bytes) - ret = (T)((ret << 8) | (byte)(typename std::make_unsigned::type)i); - return ret; + T ret = (T)0; + for (auto i: _bytes) + ret = (T)((ret << 8) | (byte)(typename std::make_unsigned::type)i); + return ret; } /// Convenience functions for toBigEndian @@ -140,16 +140,16 @@ inline bytes toBigEndian(u160 _val) { bytes ret(20); toBigEndian(_val, ret); ret template inline bytes toCompactBigEndian(T _val, unsigned _min = 0) { - static_assert(std::is_same::value || !std::numeric_limits::is_signed, "only unsigned types or bigint supported"); //bigint does not carry sign bit on shift - int i = 0; - for (T v = _val; v; ++i, v >>= 8) {} - bytes ret(std::max(_min, i), 0); - toBigEndian(_val, ret); - return ret; + static_assert(std::is_same::value || !std::numeric_limits::is_signed, "only unsigned types or bigint supported"); //bigint does not carry sign bit on shift + int i = 0; + for (T v = _val; v; ++i, v >>= 8) {} + bytes ret(std::max(_min, i), 0); + toBigEndian(_val, ret); + return ret; } inline bytes toCompactBigEndian(byte _val, unsigned _min = 0) { - return (_min || _val) ? bytes{ _val } : bytes{}; + return (_min || _val) ? bytes{ _val } : bytes{}; } /// Convenience function for toBigEndian. @@ -157,25 +157,25 @@ inline bytes toCompactBigEndian(byte _val, unsigned _min = 0) template inline std::string toCompactBigEndianString(T _val, unsigned _min = 0) { - static_assert(std::is_same::value || !std::numeric_limits::is_signed, "only unsigned types or bigint supported"); //bigint does not carry sign bit on shift - int i = 0; - for (T v = _val; v; ++i, v >>= 8) {} - std::string ret(std::max(_min, i), '\0'); - toBigEndian(_val, ret); - return ret; + static_assert(std::is_same::value || !std::numeric_limits::is_signed, "only unsigned types or bigint supported"); //bigint does not carry sign bit on shift + int i = 0; + for (T v = _val; v; ++i, v >>= 8) {} + std::string ret(std::max(_min, i), '\0'); + toBigEndian(_val, ret); + return ret; } /// Convenience function for conversion of a u256 to hex inline std::string toHex(u256 val, HexPrefix prefix = HexPrefix::DontAdd) { - std::string str = toHex(toBigEndian(val)); - return (prefix == HexPrefix::Add) ? "0x" + str : str; + std::string str = toHex(toBigEndian(val)); + return (prefix == HexPrefix::Add) ? "0x" + str : str; } inline std::string toCompactHex(u256 val, HexPrefix prefix = HexPrefix::DontAdd, unsigned _min = 0) { - std::string str = toHex(toCompactBigEndian(val, _min)); - return (prefix == HexPrefix::Add) ? "0x" + str : str; + std::string str = toHex(toCompactBigEndian(val, _min)); + return (prefix == HexPrefix::Add) ? "0x" + str : str; } // Algorithms for string and string-like collections. @@ -190,11 +190,11 @@ std::string escaped(std::string const& _s, bool _all = true); template unsigned commonPrefix(T const& _t, _U const& _u) { - unsigned s = std::min(_t.size(), _u.size()); - for (unsigned i = 0;; ++i) - if (i == s || _t[i] != _u[i]) - return i; - return s; + unsigned s = std::min(_t.size(), _u.size()); + for (unsigned i = 0;; ++i) + if (i == s || _t[i] != _u[i]) + return i; + return s; } /// Creates a random, printable, word. @@ -204,10 +204,10 @@ std::string randomWord(); template inline unsigned bytesRequired(T _i) { - static_assert(std::is_same::value || !std::numeric_limits::is_signed, "only unsigned types or bigint supported"); //bigint does not carry sign bit on shift - unsigned i = 0; - for (; _i != 0; ++i, _i >>= 8) {} - return i; + static_assert(std::is_same::value || !std::numeric_limits::is_signed, "only unsigned types or bigint supported"); //bigint does not carry sign bit on shift + unsigned i = 0; + for (; _i != 0; ++i, _i >>= 8) {} + return i; } /// Trims a given number of elements from the front of a collection. @@ -215,9 +215,9 @@ inline unsigned bytesRequired(T _i) template void trimFront(T& _t, unsigned _elements) { - static_assert(std::is_pod::value, ""); - memmove(_t.data(), _t.data() + _elements, (_t.size() - _elements) * sizeof(_t[0])); - _t.resize(_t.size() - _elements); + static_assert(std::is_pod::value, ""); + memmove(_t.data(), _t.data() + _elements, (_t.size() - _elements) * sizeof(_t[0])); + _t.resize(_t.size() - _elements); } /// Pushes an element on to the front of a collection. @@ -225,20 +225,20 @@ void trimFront(T& _t, unsigned _elements) template void pushFront(T& _t, _U _e) { - static_assert(std::is_pod::value, ""); - _t.push_back(_e); - memmove(_t.data() + 1, _t.data(), (_t.size() - 1) * sizeof(_e)); - _t[0] = _e; + static_assert(std::is_pod::value, ""); + _t.push_back(_e); + memmove(_t.data() + 1, _t.data(), (_t.size() - 1) * sizeof(_e)); + _t[0] = _e; } /// Concatenate two vectors of elements of POD types. template inline std::vector& operator+=(std::vector::value, T>::type>& _a, std::vector const& _b) { - auto s = _a.size(); - _a.resize(_a.size() + _b.size()); - memcpy(_a.data() + s, _b.data(), _b.size() * sizeof(T)); - return _a; + auto s = _a.size(); + _a.resize(_a.size() + _b.size()); + memcpy(_a.data() + s, _b.data(), _b.size() * sizeof(T)); + return _a; } @@ -246,92 +246,92 @@ inline std::vector& operator+=(std::vector inline std::vector& operator+=(std::vector::value, T>::type>& _a, std::vector const& _b) { - _a.reserve(_a.size() + _b.size()); - for (auto& i: _b) - _a.push_back(i); - return _a; + _a.reserve(_a.size() + _b.size()); + for (auto& i: _b) + _a.push_back(i); + return _a; } /// Insert the contents of a container into a set template std::set& operator+=(std::set& _a, U const& _b) { - for (auto const& i: _b) - _a.insert(i); - return _a; + for (auto const& i: _b) + _a.insert(i); + return _a; } /// Insert the contents of a container into an unordered_set template std::unordered_set& operator+=(std::unordered_set& _a, U const& _b) { - for (auto const& i: _b) - _a.insert(i); - return _a; + for (auto const& i: _b) + _a.insert(i); + return _a; } /// Concatenate the contents of a container onto a vector template std::vector& operator+=(std::vector& _a, U const& _b) { - for (auto const& i: _b) - _a.push_back(i); - return _a; + for (auto const& i: _b) + _a.push_back(i); + return _a; } /// Insert the contents of a container into a set template std::set operator+(std::set _a, U const& _b) { - return _a += _b; + return _a += _b; } /// Insert the contents of a container into an unordered_set template std::unordered_set operator+(std::unordered_set _a, U const& _b) { - return _a += _b; + return _a += _b; } /// Concatenate the contents of a container onto a vector template std::vector operator+(std::vector _a, U const& _b) { - return _a += _b; + return _a += _b; } /// Concatenate two vectors of elements. template inline std::vector operator+(std::vector const& _a, std::vector const& _b) { - std::vector ret(_a); - return ret += _b; + std::vector ret(_a); + return ret += _b; } /// Merge two sets of elements. template inline std::set& operator+=(std::set& _a, std::set const& _b) { - for (auto& i: _b) - _a.insert(i); - return _a; + for (auto& i: _b) + _a.insert(i); + return _a; } /// Merge two sets of elements. template inline std::set operator+(std::set const& _a, std::set const& _b) { - std::set ret(_a); - return ret += _b; + std::set ret(_a); + return ret += _b; } template std::unordered_map& operator+=(std::unordered_map& _x, std::unordered_map const& _y) { - for (auto const& i: _y) - _x.insert(i); - return _x; + for (auto const& i: _y) + _x.insert(i); + return _x; } template std::unordered_map operator+(std::unordered_map const& _x, std::unordered_map const& _y) { - std::unordered_map ret(_x); - return ret += _y; + std::unordered_map ret(_x); + return ret += _y; } /// Make normal string from fixed-length string. @@ -340,45 +340,45 @@ std::string toString(string32 const& _s); template std::vector keysOf(std::map const& _m) { - std::vector ret; - for (auto const& i: _m) - ret.push_back(i.first); - return ret; + std::vector ret; + for (auto const& i: _m) + ret.push_back(i.first); + return ret; } template std::vector keysOf(std::unordered_map const& _m) { - std::vector ret; - for (auto const& i: _m) - ret.push_back(i.first); - return ret; + std::vector ret; + for (auto const& i: _m) + ret.push_back(i.first); + return ret; } template std::vector valuesOf(std::map const& _m) { - std::vector ret; - ret.reserve(_m.size()); - for (auto const& i: _m) - ret.push_back(i.second); - return ret; + std::vector ret; + ret.reserve(_m.size()); + for (auto const& i: _m) + ret.push_back(i.second); + return ret; } template std::vector valuesOf(std::unordered_map const& _m) { - std::vector ret; - ret.reserve(_m.size()); - for (auto const& i: _m) - ret.push_back(i.second); - return ret; + std::vector ret; + ret.reserve(_m.size()); + for (auto const& i: _m) + ret.push_back(i.second); + return ret; } template bool contains(T const& _t, V const& _v) { - return std::end(_t) != std::find(std::begin(_t), std::end(_t), _v); + return std::end(_t) != std::find(std::begin(_t), std::end(_t), _v); } } diff --git a/include/metaverse/consensus/libdevcore/CommonIO.h b/include/metaverse/consensus/libdevcore/CommonIO.h index 6555b1300..fcc70150b 100644 --- a/include/metaverse/consensus/libdevcore/CommonIO.h +++ b/include/metaverse/consensus/libdevcore/CommonIO.h @@ -1,18 +1,18 @@ /* - This file is part of cpp-ethereum. + This file is part of cpp-ethereum. - cpp-ethereum is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. + cpp-ethereum is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. - cpp-ethereum is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. + cpp-ethereum is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. - You should have received a copy of the GNU General Public License - along with cpp-ethereum. If not, see . + You should have received a copy of the GNU General Public License + along with cpp-ethereum. If not, see . */ /** @file CommonIO.h * @author Gav Wood @@ -94,37 +94,37 @@ template inline std::string toString(std::chrono::time_point const& template inline std::string toString(std::chrono::time_point const& _e, std::string _format = "%F %T") #endif { - unsigned long milliSecondsSinceEpoch = std::chrono::duration_cast(_e.time_since_epoch()).count(); - auto const durationSinceEpoch = std::chrono::milliseconds(milliSecondsSinceEpoch); - std::chrono::time_point const tpAfterDuration(durationSinceEpoch); + unsigned long milliSecondsSinceEpoch = std::chrono::duration_cast(_e.time_since_epoch()).count(); + auto const durationSinceEpoch = std::chrono::milliseconds(milliSecondsSinceEpoch); + std::chrono::time_point const tpAfterDuration(durationSinceEpoch); - tm timeValue; - auto time = std::chrono::system_clock::to_time_t(tpAfterDuration); + tm timeValue; + auto time = std::chrono::system_clock::to_time_t(tpAfterDuration); #if defined(_WIN32) - gmtime_s(&timeValue, &time); + gmtime_s(&timeValue, &time); #else - gmtime_r(&time, &timeValue); + gmtime_r(&time, &timeValue); #endif - unsigned const millisRemainder = milliSecondsSinceEpoch % 1000; - char buffer[1024]; - if (strftime(buffer, sizeof(buffer), _format.c_str(), &timeValue)) - return std::string(buffer) + "." + (millisRemainder < 1 ? "000" : millisRemainder < 10 ? "00" : millisRemainder < 100 ? "0" : "") + std::to_string(millisRemainder) + "Z"; - return std::string(); + unsigned const millisRemainder = milliSecondsSinceEpoch % 1000; + char buffer[1024]; + if (strftime(buffer, sizeof(buffer), _format.c_str(), &timeValue)) + return std::string(buffer) + "." + (millisRemainder < 1 ? "000" : millisRemainder < 10 ? "00" : millisRemainder < 100 ? "0" : "") + std::to_string(millisRemainder) + "Z"; + return std::string(); } template inline S& streamout(S& _out, std::vector const& _e) { - _out << "["; - if (!_e.empty()) - { - StreamOut::bypass(_out, _e.front()); - for (auto i = ++_e.begin(); i != _e.end(); ++i) - StreamOut::bypass(_out << ",", *i); - } - _out << "]"; - return _out; + _out << "["; + if (!_e.empty()) + { + StreamOut::bypass(_out, _e.front()); + for (auto i = ++_e.begin(); i != _e.end(); ++i) + StreamOut::bypass(_out << ",", *i); + } + _out << "]"; + return _out; } template inline std::ostream& operator<<(std::ostream& _out, std::vector const& _e) { streamout(_out, _e); return _out; } @@ -132,125 +132,125 @@ template inline std::ostream& operator<<(std::ostream& _out, std::vect template inline S& streamout(S& _out, std::array const& _e) { - _out << "["; - if (!_e.empty()) - { - StreamOut::bypass(_out, _e.front()); - auto i = _e.begin(); - for (++i; i != _e.end(); ++i) - StreamOut::bypass(_out << ",", *i); - } - _out << "]"; - return _out; + _out << "["; + if (!_e.empty()) + { + StreamOut::bypass(_out, _e.front()); + auto i = _e.begin(); + for (++i; i != _e.end(); ++i) + StreamOut::bypass(_out << ",", *i); + } + _out << "]"; + return _out; } template inline std::ostream& operator<<(std::ostream& _out, std::array const& _e) { streamout(_out, _e); return _out; } template inline S& streamout(S& _out, std::list const& _e) { - _out << "["; - if (!_e.empty()) - { - _out << _e.front(); - for (auto i = ++_e.begin(); i != _e.end(); ++i) - _out << "," << *i; - } - _out << "]"; - return _out; + _out << "["; + if (!_e.empty()) + { + _out << _e.front(); + for (auto i = ++_e.begin(); i != _e.end(); ++i) + _out << "," << *i; + } + _out << "]"; + return _out; } template inline std::ostream& operator<<(std::ostream& _out, std::list const& _e) { streamout(_out, _e); return _out; } template inline S& streamout(S& _out, std::pair const& _e) { - _out << "(" << _e.first << "," << _e.second << ")"; - return _out; + _out << "(" << _e.first << "," << _e.second << ")"; + return _out; } template inline std::ostream& operator<<(std::ostream& _out, std::pair const& _e) { streamout(_out, _e); return _out; } template inline S& streamout(S& _out, std::tuple const& _t) { - _out << "(" << std::get<0>(_t) << "," << std::get<1>(_t) << "," << std::get<2>(_t) << ")"; - return _out; + _out << "(" << std::get<0>(_t) << "," << std::get<1>(_t) << "," << std::get<2>(_t) << ")"; + return _out; } template inline std::ostream& operator<<(std::ostream& _out, std::tuple const& _e) { streamout(_out, _e); return _out; } template S& streamout(S& _out, std::map const& _v) { - if (_v.empty()) - return _out << "{}"; - int i = 0; - for (auto p: _v) - _out << (!(i++) ? "{ " : "; ") << p.first << " => " << p.second; - return _out << " }"; + if (_v.empty()) + return _out << "{}"; + int i = 0; + for (auto p: _v) + _out << (!(i++) ? "{ " : "; ") << p.first << " => " << p.second; + return _out << " }"; } template inline std::ostream& operator<<(std::ostream& _out, std::map const& _e) { streamout(_out, _e); return _out; } template S& streamout(S& _out, std::unordered_map const& _v) { - if (_v.empty()) - return _out << "{}"; - int i = 0; - for (auto p: _v) - _out << (!(i++) ? "{ " : "; ") << p.first << " => " << p.second; - return _out << " }"; + if (_v.empty()) + return _out << "{}"; + int i = 0; + for (auto p: _v) + _out << (!(i++) ? "{ " : "; ") << p.first << " => " << p.second; + return _out << " }"; } template inline std::ostream& operator<<(std::ostream& _out, std::unordered_map const& _e) { streamout(_out, _e); return _out; } template S& streamout(S& _out, std::set const& _v) { - if (_v.empty()) - return _out << "{}"; - int i = 0; - for (auto p: _v) - _out << (!(i++) ? "{ " : ", ") << p; - return _out << " }"; + if (_v.empty()) + return _out << "{}"; + int i = 0; + for (auto p: _v) + _out << (!(i++) ? "{ " : ", ") << p; + return _out << " }"; } template inline std::ostream& operator<<(std::ostream& _out, std::set const& _e) { streamout(_out, _e); return _out; } template S& streamout(S& _out, std::unordered_set const& _v) { - if (_v.empty()) - return _out << "{}"; - int i = 0; - for (auto p: _v) - _out << (!(i++) ? "{ " : ", ") << p; - return _out << " }"; + if (_v.empty()) + return _out << "{}"; + int i = 0; + for (auto p: _v) + _out << (!(i++) ? "{ " : ", ") << p; + return _out << " }"; } template inline std::ostream& operator<<(std::ostream& _out, std::unordered_set const& _e) { streamout(_out, _e); return _out; } template S& streamout(S& _out, std::multiset const& _v) { - if (_v.empty()) - return _out << "{}"; - int i = 0; - for (auto p: _v) - _out << (!(i++) ? "{ " : ", ") << p; - return _out << " }"; + if (_v.empty()) + return _out << "{}"; + int i = 0; + for (auto p: _v) + _out << (!(i++) ? "{ " : ", ") << p; + return _out << " }"; } template inline std::ostream& operator<<(std::ostream& _out, std::multiset const& _e) { streamout(_out, _e); return _out; } template S& streamout(S& _out, std::multimap const& _v) { - if (_v.empty()) - return _out << "{}"; - T l; - int i = 0; - for (auto p: _v) - if (!(i++)) - _out << "{ " << (l = p.first) << " => " << p.second; - else if (l == p.first) - _out << ", " << p.second; - else - _out << "; " << (l = p.first) << " => " << p.second; - return _out << " }"; + if (_v.empty()) + return _out << "{}"; + T l; + int i = 0; + for (auto p: _v) + if (!(i++)) + _out << "{ " << (l = p.first) << " => " << p.second; + else if (l == p.first) + _out << ", " << p.second; + else + _out << "; " << (l = p.first) << " => " << p.second; + return _out << " }"; } template inline std::ostream& operator<<(std::ostream& _out, std::multimap const& _e) { streamout(_out, _e); return _out; } @@ -262,9 +262,9 @@ template _S& operator<<(_S& _out, std::shared_ptr<_T> const template std::string toString(_T const& _t) { - std::ostringstream o; - o << _t; - return o.str(); + std::ostringstream o; + o << _t; + return o.str(); } } diff --git a/include/metaverse/consensus/libdevcore/Exceptions.h b/include/metaverse/consensus/libdevcore/Exceptions.h index 7aab3a43f..cddd14376 100644 --- a/include/metaverse/consensus/libdevcore/Exceptions.h +++ b/include/metaverse/consensus/libdevcore/Exceptions.h @@ -1,18 +1,18 @@ /* - This file is part of cpp-ethereum. + This file is part of cpp-ethereum. - cpp-ethereum is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. + cpp-ethereum is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. - cpp-ethereum is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. + cpp-ethereum is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. - You should have received a copy of the GNU General Public License - along with cpp-ethereum. If not, see . + You should have received a copy of the GNU General Public License + along with cpp-ethereum. If not, see . */ /** @file Exceptions.h * @author Gav Wood @@ -38,11 +38,11 @@ namespace libbitcoin /// Base class for all exceptions. struct Exception: virtual std::exception, virtual boost::exception { - Exception(std::string _message = std::string()): m_message(std::move(_message)) {} - const char* what() const noexcept override { return m_message.empty() ? std::exception::what() : m_message.c_str(); } + Exception(std::string _message = std::string()): m_message(std::move(_message)) {} + const char* what() const noexcept override { return m_message.empty() ? std::exception::what() : m_message.c_str(); } private: - std::string m_message; + std::string m_message; }; #define DEV_SIMPLE_EXCEPTION(X) struct X: virtual Exception { const char* what() const noexcept override { return #X; } } diff --git a/include/metaverse/consensus/libdevcore/FixedHash.h b/include/metaverse/consensus/libdevcore/FixedHash.h index 0c1ace8da..3b50f48ef 100644 --- a/include/metaverse/consensus/libdevcore/FixedHash.h +++ b/include/metaverse/consensus/libdevcore/FixedHash.h @@ -1,18 +1,18 @@ /* - This file is part of cpp-ethereum. + This file is part of cpp-ethereum. - cpp-ethereum is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. + cpp-ethereum is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. - cpp-ethereum is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. + cpp-ethereum is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. - You should have received a copy of the GNU General Public License - along with cpp-ethereum. If not, see . + You should have received a copy of the GNU General Public License + along with cpp-ethereum. If not, see . */ /** @file FixedHash.h * @author Gav Wood @@ -46,289 +46,289 @@ template class FixedHash { public: - /// The corresponding arithmetic type. - using Arith = boost::multiprecision::number>; + /// The corresponding arithmetic type. + using Arith = boost::multiprecision::number>; - /// The size of the container. - enum { size = N }; + /// The size of the container. + enum { size = N }; - /// A dummy flag to avoid accidental construction from pointer. - enum ConstructFromPointerType { ConstructFromPointer }; + /// A dummy flag to avoid accidental construction from pointer. + enum ConstructFromPointerType { ConstructFromPointer }; - /// Method to convert from a string. - enum ConstructFromStringType { FromHex, FromBinary }; + /// Method to convert from a string. + enum ConstructFromStringType { FromHex, FromBinary }; - /// Method to convert from a string. - enum ConstructFromHashType { AlignLeft, AlignRight, FailIfDifferent }; + /// Method to convert from a string. + enum ConstructFromHashType { AlignLeft, AlignRight, FailIfDifferent }; - /// Construct an empty hash. - FixedHash() { m_data.fill(0); } + /// Construct an empty hash. + FixedHash() { m_data.fill(0); } - /// Construct from another hash, filling with zeroes or cropping as necessary. - template explicit FixedHash(FixedHash const& _h, ConstructFromHashType _t = AlignLeft) { m_data.fill(0); unsigned c = std::min(M, N); for (unsigned i = 0; i < c; ++i) m_data[_t == AlignRight ? N - 1 - i : i] = _h[_t == AlignRight ? M - 1 - i : i]; } + /// Construct from another hash, filling with zeroes or cropping as necessary. + template explicit FixedHash(FixedHash const& _h, ConstructFromHashType _t = AlignLeft) { m_data.fill(0); unsigned c = std::min(M, N); for (unsigned i = 0; i < c; ++i) m_data[_t == AlignRight ? N - 1 - i : i] = _h[_t == AlignRight ? M - 1 - i : i]; } - /// Convert from the corresponding arithmetic type. - FixedHash(Arith const& _arith) { toBigEndian(_arith, m_data); } + /// Convert from the corresponding arithmetic type. + FixedHash(Arith const& _arith) { toBigEndian(_arith, m_data); } - /// Convert from unsigned - explicit FixedHash(unsigned _u) { toBigEndian(_u, m_data); } + /// Convert from unsigned + explicit FixedHash(unsigned _u) { toBigEndian(_u, m_data); } - /// Explicitly construct, copying from a byte array. - explicit FixedHash(bytes const& _b, ConstructFromHashType _t = FailIfDifferent) { if (_b.size() == N) memcpy(m_data.data(), _b.data(), std::min(_b.size(), N)); else { m_data.fill(0); if (_t != FailIfDifferent) { auto c = std::min(_b.size(), N); for (unsigned i = 0; i < c; ++i) m_data[_t == AlignRight ? N - 1 - i : i] = _b[_t == AlignRight ? _b.size() - 1 - i : i]; } } } + /// Explicitly construct, copying from a byte array. + explicit FixedHash(bytes const& _b, ConstructFromHashType _t = FailIfDifferent) { if (_b.size() == N) memcpy(m_data.data(), _b.data(), std::min(_b.size(), N)); else { m_data.fill(0); if (_t != FailIfDifferent) { auto c = std::min(_b.size(), N); for (unsigned i = 0; i < c; ++i) m_data[_t == AlignRight ? N - 1 - i : i] = _b[_t == AlignRight ? _b.size() - 1 - i : i]; } } } - /// Explicitly construct, copying from a byte array. - explicit FixedHash(bytesConstRef _b, ConstructFromHashType _t = FailIfDifferent) { if (_b.size() == N) memcpy(m_data.data(), _b.data(), std::min(_b.size(), N)); else { m_data.fill(0); if (_t != FailIfDifferent) { auto c = std::min(_b.size(), N); for (unsigned i = 0; i < c; ++i) m_data[_t == AlignRight ? N - 1 - i : i] = _b[_t == AlignRight ? _b.size() - 1 - i : i]; } } } + /// Explicitly construct, copying from a byte array. + explicit FixedHash(bytesConstRef _b, ConstructFromHashType _t = FailIfDifferent) { if (_b.size() == N) memcpy(m_data.data(), _b.data(), std::min(_b.size(), N)); else { m_data.fill(0); if (_t != FailIfDifferent) { auto c = std::min(_b.size(), N); for (unsigned i = 0; i < c; ++i) m_data[_t == AlignRight ? N - 1 - i : i] = _b[_t == AlignRight ? _b.size() - 1 - i : i]; } } } - /// Explicitly construct, copying from a bytes in memory with given pointer. - explicit FixedHash(byte const* _bs, ConstructFromPointerType) { memcpy(m_data.data(), _bs, N); } + /// Explicitly construct, copying from a bytes in memory with given pointer. + explicit FixedHash(byte const* _bs, ConstructFromPointerType) { memcpy(m_data.data(), _bs, N); } - /// Explicitly construct, copying from a string. - explicit FixedHash(std::string const& _s, ConstructFromStringType _t = FromHex, ConstructFromHashType _ht = FailIfDifferent): FixedHash(_t == FromHex ? fromHex(_s, WhenError::Throw) : libbitcoin::asBytes(_s), _ht) {} + /// Explicitly construct, copying from a string. + explicit FixedHash(std::string const& _s, ConstructFromStringType _t = FromHex, ConstructFromHashType _ht = FailIfDifferent): FixedHash(_t == FromHex ? fromHex(_s, WhenError::Throw) : libbitcoin::asBytes(_s), _ht) {} - /// Convert to arithmetic type. - operator Arith() const { return fromBigEndian(m_data); } + /// Convert to arithmetic type. + operator Arith() const { return fromBigEndian(m_data); } - /// @returns true iff this is the empty hash. - explicit operator bool() const { return std::any_of(m_data.begin(), m_data.end(), [](byte _b) { return _b != 0; }); } + /// @returns true iff this is the empty hash. + explicit operator bool() const { return std::any_of(m_data.begin(), m_data.end(), [](byte _b) { return _b != 0; }); } - // The obvious comparison operators. - bool operator==(FixedHash const& _c) const { return m_data == _c.m_data; } - bool operator!=(FixedHash const& _c) const { return m_data != _c.m_data; } - bool operator<(FixedHash const& _c) const { for (unsigned i = 0; i < N; ++i) if (m_data[i] < _c.m_data[i]) return true; else if (m_data[i] > _c.m_data[i]) return false; return false; } - bool operator>=(FixedHash const& _c) const { return !operator<(_c); } - bool operator<=(FixedHash const& _c) const { return operator==(_c) || operator<(_c); } - bool operator>(FixedHash const& _c) const { return !operator<=(_c); } + // The obvious comparison operators. + bool operator==(FixedHash const& _c) const { return m_data == _c.m_data; } + bool operator!=(FixedHash const& _c) const { return m_data != _c.m_data; } + bool operator<(FixedHash const& _c) const { for (unsigned i = 0; i < N; ++i) if (m_data[i] < _c.m_data[i]) return true; else if (m_data[i] > _c.m_data[i]) return false; return false; } + bool operator>=(FixedHash const& _c) const { return !operator<(_c); } + bool operator<=(FixedHash const& _c) const { return operator==(_c) || operator<(_c); } + bool operator>(FixedHash const& _c) const { return !operator<=(_c); } - // The obvious binary operators. - FixedHash& operator^=(FixedHash const& _c) { for (unsigned i = 0; i < N; ++i) m_data[i] ^= _c.m_data[i]; return *this; } - FixedHash operator^(FixedHash const& _c) const { return FixedHash(*this) ^= _c; } - FixedHash& operator|=(FixedHash const& _c) { for (unsigned i = 0; i < N; ++i) m_data[i] |= _c.m_data[i]; return *this; } - FixedHash operator|(FixedHash const& _c) const { return FixedHash(*this) |= _c; } - FixedHash& operator&=(FixedHash const& _c) { for (unsigned i = 0; i < N; ++i) m_data[i] &= _c.m_data[i]; return *this; } - FixedHash operator&(FixedHash const& _c) const { return FixedHash(*this) &= _c; } - FixedHash operator~() const { FixedHash ret; for (unsigned i = 0; i < N; ++i) ret[i] = ~m_data[i]; return ret; } - - // Big-endian increment. - FixedHash& operator++() { for (unsigned i = size; i > 0 && !++m_data[--i]; ) {} return *this; } - - /// @returns true if all one-bits in @a _c are set in this object. - bool contains(FixedHash const& _c) const { return (*this & _c) == _c; } - - /// @returns a particular byte from the hash. - byte& operator[](unsigned _i) { return m_data[_i]; } - /// @returns a particular byte from the hash. - byte operator[](unsigned _i) const { return m_data[_i]; } - - /// @returns an abridged version of the hash as a user-readable hex string. - std::string abridged() const { return toHex(ref().cropped(0, 4)) + "\342\200\246"; } - - /// @returns a version of the hash as a user-readable hex string that leaves out the middle part. - std::string abridgedMiddle() const { return toHex(ref().cropped(0, 4)) + "\342\200\246" + toHex(ref().cropped(N - 4)); } - - /// @returns the hash as a user-readable hex string. - std::string hex() const { return toHex(ref()); } - - /// @returns a mutable byte vector_ref to the object's data. - bytesRef ref() { return bytesRef(m_data.data(), N); } - - /// @returns a constant byte vector_ref to the object's data. - bytesConstRef ref() const { return bytesConstRef(m_data.data(), N); } - - /// @returns a mutable byte pointer to the object's data. - byte* data() { return m_data.data(); } - - /// @returns a constant byte pointer to the object's data. - byte const* data() const { return m_data.data(); } - - /// @returns a copy of the object's data as a byte vector. - bytes asBytes() const { return bytes(data(), data() + N); } - - /// @returns a mutable reference to the object's data as an STL array. - std::array& asArray() { return m_data; } - - /// @returns a constant reference to the object's data as an STL array. - std::array const& asArray() const { return m_data; } - - /// Populate with random data. - template - void randomize(Engine& _eng) - { - for (auto& i: m_data) - i = (uint8_t)boost::random::uniform_int_distribution(0, 255)(_eng); - } - - /// @returns a random valued object. - static FixedHash random() { FixedHash ret; ret.randomize(s_fixedHashEngine); return ret; } - - struct hash - { - /// Make a hash of the object's data. - size_t operator()(FixedHash const& _value) const { return libbitcoin::hash_range(_value.m_data.cbegin(), _value.m_data.cend()); } - }; - - template inline FixedHash& shiftBloom(FixedHash const& _h) - { - return (*this |= _h.template bloomPart()); - } - - template inline bool containsBloom(FixedHash const& _h) - { - return contains(_h.template bloomPart()); - } - - template inline FixedHash bloomPart() const - { - unsigned const c_bloomBits = M * 8; - unsigned const c_mask = c_bloomBits - 1; - unsigned const c_bloomBytes = (StaticLog2::result + 7) / 8; - - static_assert((M & (M - 1)) == 0, "M must be power-of-two"); - static_assert(P * c_bloomBytes <= N, "out of range"); - - FixedHash ret; - byte const* p = data(); - for (unsigned i = 0; i < P; ++i) - { - unsigned index = 0; - for (unsigned j = 0; j < c_bloomBytes; ++j, ++p) - index = (index << 8) | *p; - index &= c_mask; - ret[M - 1 - index / 8] |= (1 << (index % 8)); - } - return ret; - } - - /// Returns the index of the first bit set to one, or size() * 8 if no bits are set. - inline unsigned firstBitSet() const - { - unsigned ret = 0; - for (auto d: m_data) - if (d) - for (;; ++ret, d <<= 1) - if (d & 0x80) - return ret; - else {} - else - ret += 8; - return ret; - } - - void clear() { m_data.fill(0); } + // The obvious binary operators. + FixedHash& operator^=(FixedHash const& _c) { for (unsigned i = 0; i < N; ++i) m_data[i] ^= _c.m_data[i]; return *this; } + FixedHash operator^(FixedHash const& _c) const { return FixedHash(*this) ^= _c; } + FixedHash& operator|=(FixedHash const& _c) { for (unsigned i = 0; i < N; ++i) m_data[i] |= _c.m_data[i]; return *this; } + FixedHash operator|(FixedHash const& _c) const { return FixedHash(*this) |= _c; } + FixedHash& operator&=(FixedHash const& _c) { for (unsigned i = 0; i < N; ++i) m_data[i] &= _c.m_data[i]; return *this; } + FixedHash operator&(FixedHash const& _c) const { return FixedHash(*this) &= _c; } + FixedHash operator~() const { FixedHash ret; for (unsigned i = 0; i < N; ++i) ret[i] = ~m_data[i]; return ret; } + + // Big-endian increment. + FixedHash& operator++() { for (unsigned i = size; i > 0 && !++m_data[--i]; ) {} return *this; } + + /// @returns true if all one-bits in @a _c are set in this object. + bool contains(FixedHash const& _c) const { return (*this & _c) == _c; } + + /// @returns a particular byte from the hash. + byte& operator[](unsigned _i) { return m_data[_i]; } + /// @returns a particular byte from the hash. + byte operator[](unsigned _i) const { return m_data[_i]; } + + /// @returns an abridged version of the hash as a user-readable hex string. + std::string abridged() const { return toHex(ref().cropped(0, 4)) + "\342\200\246"; } + + /// @returns a version of the hash as a user-readable hex string that leaves out the middle part. + std::string abridgedMiddle() const { return toHex(ref().cropped(0, 4)) + "\342\200\246" + toHex(ref().cropped(N - 4)); } + + /// @returns the hash as a user-readable hex string. + std::string hex() const { return toHex(ref()); } + + /// @returns a mutable byte vector_ref to the object's data. + bytesRef ref() { return bytesRef(m_data.data(), N); } + + /// @returns a constant byte vector_ref to the object's data. + bytesConstRef ref() const { return bytesConstRef(m_data.data(), N); } + + /// @returns a mutable byte pointer to the object's data. + byte* data() { return m_data.data(); } + + /// @returns a constant byte pointer to the object's data. + byte const* data() const { return m_data.data(); } + + /// @returns a copy of the object's data as a byte vector. + bytes asBytes() const { return bytes(data(), data() + N); } + + /// @returns a mutable reference to the object's data as an STL array. + std::array& asArray() { return m_data; } + + /// @returns a constant reference to the object's data as an STL array. + std::array const& asArray() const { return m_data; } + + /// Populate with random data. + template + void randomize(Engine& _eng) + { + for (auto& i: m_data) + i = (uint8_t)boost::random::uniform_int_distribution(0, 255)(_eng); + } + + /// @returns a random valued object. + static FixedHash random() { FixedHash ret; ret.randomize(s_fixedHashEngine); return ret; } + + struct hash + { + /// Make a hash of the object's data. + size_t operator()(FixedHash const& _value) const { return libbitcoin::hash_range(_value.m_data.cbegin(), _value.m_data.cend()); } + }; + + template inline FixedHash& shiftBloom(FixedHash const& _h) + { + return (*this |= _h.template bloomPart()); + } + + template inline bool containsBloom(FixedHash const& _h) + { + return contains(_h.template bloomPart()); + } + + template inline FixedHash bloomPart() const + { + unsigned const c_bloomBits = M * 8; + unsigned const c_mask = c_bloomBits - 1; + unsigned const c_bloomBytes = (StaticLog2::result + 7) / 8; + + static_assert((M & (M - 1)) == 0, "M must be power-of-two"); + static_assert(P * c_bloomBytes <= N, "out of range"); + + FixedHash ret; + byte const* p = data(); + for (unsigned i = 0; i < P; ++i) + { + unsigned index = 0; + for (unsigned j = 0; j < c_bloomBytes; ++j, ++p) + index = (index << 8) | *p; + index &= c_mask; + ret[M - 1 - index / 8] |= (1 << (index % 8)); + } + return ret; + } + + /// Returns the index of the first bit set to one, or size() * 8 if no bits are set. + inline unsigned firstBitSet() const + { + unsigned ret = 0; + for (auto d: m_data) + if (d) + for (;; ++ret, d <<= 1) + if (d & 0x80) + return ret; + else {} + else + ret += 8; + return ret; + } + + void clear() { m_data.fill(0); } private: - std::array m_data; ///< The binary data. + std::array m_data; ///< The binary data. }; template class SecureFixedHash: private FixedHash { public: - using ConstructFromHashType = typename FixedHash::ConstructFromHashType; - using ConstructFromStringType = typename FixedHash::ConstructFromStringType; - using ConstructFromPointerType = typename FixedHash::ConstructFromPointerType; - SecureFixedHash() = default; - explicit SecureFixedHash(bytes const& _b, ConstructFromHashType _t = FixedHash::FailIfDifferent): FixedHash(_b, _t) {} - explicit SecureFixedHash(bytesConstRef _b, ConstructFromHashType _t = FixedHash::FailIfDifferent): FixedHash(_b, _t) {} - explicit SecureFixedHash(bytesSec const& _b, ConstructFromHashType _t = FixedHash::FailIfDifferent): FixedHash(_b.ref(), _t) {} - template explicit SecureFixedHash(FixedHash const& _h, ConstructFromHashType _t = FixedHash::AlignLeft): FixedHash(_h, _t) {} - template explicit SecureFixedHash(SecureFixedHash const& _h, ConstructFromHashType _t = FixedHash::AlignLeft): FixedHash(_h.makeInsecure(), _t) {} - explicit SecureFixedHash(std::string const& _s, ConstructFromStringType _t = FixedHash::FromHex, ConstructFromHashType _ht = FixedHash::FailIfDifferent): FixedHash(_s, _t, _ht) {} - explicit SecureFixedHash(bytes const* _d, ConstructFromPointerType _t): FixedHash(_d, _t) {} - ~SecureFixedHash() { ref().cleanse(); } - - SecureFixedHash& operator=(SecureFixedHash const& _c) - { - if (&_c == this) - return *this; - ref().cleanse(); - FixedHash::operator=(static_cast const&>(_c)); - return *this; - } - - using FixedHash::size; - - bytesSec asBytesSec() const { return bytesSec(ref()); } - - FixedHash const& makeInsecure() const { return static_cast const&>(*this); } - FixedHash& writable() { clear(); return static_cast&>(*this); } - - using FixedHash::operator bool; - - // The obvious comparison operators. - bool operator==(SecureFixedHash const& _c) const { return static_cast const&>(*this).operator==(static_cast const&>(_c)); } - bool operator!=(SecureFixedHash const& _c) const { return static_cast const&>(*this).operator!=(static_cast const&>(_c)); } - bool operator<(SecureFixedHash const& _c) const { return static_cast const&>(*this).operator<(static_cast const&>(_c)); } - bool operator>=(SecureFixedHash const& _c) const { return static_cast const&>(*this).operator>=(static_cast const&>(_c)); } - bool operator<=(SecureFixedHash const& _c) const { return static_cast const&>(*this).operator<=(static_cast const&>(_c)); } - bool operator>(SecureFixedHash const& _c) const { return static_cast const&>(*this).operator>(static_cast const&>(_c)); } - - using FixedHash::operator==; - using FixedHash::operator!=; - using FixedHash::operator<; - using FixedHash::operator>=; - using FixedHash::operator<=; - using FixedHash::operator>; - - // The obvious binary operators. - SecureFixedHash& operator^=(FixedHash const& _c) { static_cast&>(*this).operator^=(_c); return *this; } - SecureFixedHash operator^(FixedHash const& _c) const { return SecureFixedHash(*this) ^= _c; } - SecureFixedHash& operator|=(FixedHash const& _c) { static_cast&>(*this).operator^=(_c); return *this; } - SecureFixedHash operator|(FixedHash const& _c) const { return SecureFixedHash(*this) |= _c; } - SecureFixedHash& operator&=(FixedHash const& _c) { static_cast&>(*this).operator^=(_c); return *this; } - SecureFixedHash operator&(FixedHash const& _c) const { return SecureFixedHash(*this) &= _c; } - - SecureFixedHash& operator^=(SecureFixedHash const& _c) { static_cast&>(*this).operator^=(static_cast const&>(_c)); return *this; } - SecureFixedHash operator^(SecureFixedHash const& _c) const { return SecureFixedHash(*this) ^= _c; } - SecureFixedHash& operator|=(SecureFixedHash const& _c) { static_cast&>(*this).operator^=(static_cast const&>(_c)); return *this; } - SecureFixedHash operator|(SecureFixedHash const& _c) const { return SecureFixedHash(*this) |= _c; } - SecureFixedHash& operator&=(SecureFixedHash const& _c) { static_cast&>(*this).operator^=(static_cast const&>(_c)); return *this; } - SecureFixedHash operator&(SecureFixedHash const& _c) const { return SecureFixedHash(*this) &= _c; } - SecureFixedHash operator~() const { auto r = ~static_cast const&>(*this); return static_cast(r); } - - using FixedHash::abridged; - using FixedHash::abridgedMiddle; - - bytesConstRef ref() const { return FixedHash::ref(); } - byte const* data() const { return FixedHash::data(); } - - static SecureFixedHash random() { SecureFixedHash ret; ret.randomize(s_fixedHashEngine); return ret; } - using FixedHash::firstBitSet; - - void clear() { ref().cleanse(); } + using ConstructFromHashType = typename FixedHash::ConstructFromHashType; + using ConstructFromStringType = typename FixedHash::ConstructFromStringType; + using ConstructFromPointerType = typename FixedHash::ConstructFromPointerType; + SecureFixedHash() = default; + explicit SecureFixedHash(bytes const& _b, ConstructFromHashType _t = FixedHash::FailIfDifferent): FixedHash(_b, _t) {} + explicit SecureFixedHash(bytesConstRef _b, ConstructFromHashType _t = FixedHash::FailIfDifferent): FixedHash(_b, _t) {} + explicit SecureFixedHash(bytesSec const& _b, ConstructFromHashType _t = FixedHash::FailIfDifferent): FixedHash(_b.ref(), _t) {} + template explicit SecureFixedHash(FixedHash const& _h, ConstructFromHashType _t = FixedHash::AlignLeft): FixedHash(_h, _t) {} + template explicit SecureFixedHash(SecureFixedHash const& _h, ConstructFromHashType _t = FixedHash::AlignLeft): FixedHash(_h.makeInsecure(), _t) {} + explicit SecureFixedHash(std::string const& _s, ConstructFromStringType _t = FixedHash::FromHex, ConstructFromHashType _ht = FixedHash::FailIfDifferent): FixedHash(_s, _t, _ht) {} + explicit SecureFixedHash(bytes const* _d, ConstructFromPointerType _t): FixedHash(_d, _t) {} + ~SecureFixedHash() { ref().cleanse(); } + + SecureFixedHash& operator=(SecureFixedHash const& _c) + { + if (&_c == this) + return *this; + ref().cleanse(); + FixedHash::operator=(static_cast const&>(_c)); + return *this; + } + + using FixedHash::size; + + bytesSec asBytesSec() const { return bytesSec(ref()); } + + FixedHash const& makeInsecure() const { return static_cast const&>(*this); } + FixedHash& writable() { clear(); return static_cast&>(*this); } + + using FixedHash::operator bool; + + // The obvious comparison operators. + bool operator==(SecureFixedHash const& _c) const { return static_cast const&>(*this).operator==(static_cast const&>(_c)); } + bool operator!=(SecureFixedHash const& _c) const { return static_cast const&>(*this).operator!=(static_cast const&>(_c)); } + bool operator<(SecureFixedHash const& _c) const { return static_cast const&>(*this).operator<(static_cast const&>(_c)); } + bool operator>=(SecureFixedHash const& _c) const { return static_cast const&>(*this).operator>=(static_cast const&>(_c)); } + bool operator<=(SecureFixedHash const& _c) const { return static_cast const&>(*this).operator<=(static_cast const&>(_c)); } + bool operator>(SecureFixedHash const& _c) const { return static_cast const&>(*this).operator>(static_cast const&>(_c)); } + + using FixedHash::operator==; + using FixedHash::operator!=; + using FixedHash::operator<; + using FixedHash::operator>=; + using FixedHash::operator<=; + using FixedHash::operator>; + + // The obvious binary operators. + SecureFixedHash& operator^=(FixedHash const& _c) { static_cast&>(*this).operator^=(_c); return *this; } + SecureFixedHash operator^(FixedHash const& _c) const { return SecureFixedHash(*this) ^= _c; } + SecureFixedHash& operator|=(FixedHash const& _c) { static_cast&>(*this).operator^=(_c); return *this; } + SecureFixedHash operator|(FixedHash const& _c) const { return SecureFixedHash(*this) |= _c; } + SecureFixedHash& operator&=(FixedHash const& _c) { static_cast&>(*this).operator^=(_c); return *this; } + SecureFixedHash operator&(FixedHash const& _c) const { return SecureFixedHash(*this) &= _c; } + + SecureFixedHash& operator^=(SecureFixedHash const& _c) { static_cast&>(*this).operator^=(static_cast const&>(_c)); return *this; } + SecureFixedHash operator^(SecureFixedHash const& _c) const { return SecureFixedHash(*this) ^= _c; } + SecureFixedHash& operator|=(SecureFixedHash const& _c) { static_cast&>(*this).operator^=(static_cast const&>(_c)); return *this; } + SecureFixedHash operator|(SecureFixedHash const& _c) const { return SecureFixedHash(*this) |= _c; } + SecureFixedHash& operator&=(SecureFixedHash const& _c) { static_cast&>(*this).operator^=(static_cast const&>(_c)); return *this; } + SecureFixedHash operator&(SecureFixedHash const& _c) const { return SecureFixedHash(*this) &= _c; } + SecureFixedHash operator~() const { auto r = ~static_cast const&>(*this); return static_cast(r); } + + using FixedHash::abridged; + using FixedHash::abridgedMiddle; + + bytesConstRef ref() const { return FixedHash::ref(); } + byte const* data() const { return FixedHash::data(); } + + static SecureFixedHash random() { SecureFixedHash ret; ret.randomize(s_fixedHashEngine); return ret; } + using FixedHash::firstBitSet; + + void clear() { ref().cleanse(); } }; /// Fast equality operator for h256. template<> inline bool FixedHash<32>::operator==(FixedHash<32> const& _other) const { - const uint64_t* hash1 = (const uint64_t*)data(); - const uint64_t* hash2 = (const uint64_t*)_other.data(); - return (hash1[0] == hash2[0]) && (hash1[1] == hash2[1]) && (hash1[2] == hash2[2]) && (hash1[3] == hash2[3]); + const uint64_t* hash1 = (const uint64_t*)data(); + const uint64_t* hash2 = (const uint64_t*)_other.data(); + return (hash1[0] == hash2[0]) && (hash1[1] == hash2[1]) && (hash1[2] == hash2[2]) && (hash1[3] == hash2[3]); } /// Fast std::hash compatible hash function object for h256. template<> inline size_t FixedHash<32>::hash::operator()(FixedHash<32> const& value) const { - uint64_t const* data = reinterpret_cast(value.data()); - return libbitcoin::hash_range(data, data + 4); + uint64_t const* data = reinterpret_cast(value.data()); + return libbitcoin::hash_range(data, data + 4); } /// Stream I/O for the FixedHash class. template inline std::ostream& operator<<(std::ostream& _out, FixedHash const& _h) { - _out << std::noshowbase << std::hex << std::setfill('0'); - for (unsigned i = 0; i < N; ++i) - _out << std::setw(2) << (int)_h[i]; - _out << std::dec; - return _out; + _out << std::noshowbase << std::hex << std::setfill('0'); + for (unsigned i = 0; i < N; ++i) + _out << std::setw(2) << (int)_h[i]; + _out << std::dec; + return _out; } /// Stream I/O for the SecureFixedHash class. template inline std::ostream& operator<<(std::ostream& _out, SecureFixedHash const& _h) { - _out << "SecureFixedHash#" << std::hex << typename FixedHash::hash()(_h.makeInsecure()) << std::dec; - return _out; + _out << "SecureFixedHash#" << std::hex << typename FixedHash::hash()(_h.makeInsecure()) << std::dec; + return _out; } // Common types of FixedHash. @@ -354,17 +354,17 @@ using Secret = SecureFixedHash<32>; /// Convert the given value into h160 (160-bit unsigned integer) using the right 20 bytes. inline h160 right160(h256 const& _t) { - h160 ret; - memcpy(ret.data(), _t.data() + 12, 20); - return ret; + h160 ret; + memcpy(ret.data(), _t.data() + 12, 20); + return ret; } /// Convert the given value into h160 (160-bit unsigned integer) using the left 20 bytes. inline h160 left160(h256 const& _t) { - h160 ret; - memcpy(&ret[0], _t.data(), 20); - return ret; + h160 ret; + memcpy(&ret[0], _t.data(), 20); + return ret; } h128 fromUUID(std::string const& _uuid); @@ -373,22 +373,22 @@ std::string toUUID(h128 const& _uuid); inline std::string toString(h256s const& _bs) { - std::ostringstream out; - out << "[ "; - for (auto i: _bs) - out << i.abridged() << ", "; - out << "]"; - return out.str(); + std::ostringstream out; + out << "[ "; + for (auto i: _bs) + out << i.abridged() << ", "; + out << "]"; + return out.str(); } } namespace std { - /// Forward std::hash to dev::FixedHash::hash. - template<> struct hash: libbitcoin::h64::hash {}; - template<> struct hash: libbitcoin::h128::hash {}; - template<> struct hash: libbitcoin::h160::hash {}; - template<> struct hash: libbitcoin::h256::hash {}; - template<> struct hash: libbitcoin::h512::hash {}; + /// Forward std::hash to dev::FixedHash::hash. + template<> struct hash: libbitcoin::h64::hash {}; + template<> struct hash: libbitcoin::h128::hash {}; + template<> struct hash: libbitcoin::h160::hash {}; + template<> struct hash: libbitcoin::h256::hash {}; + template<> struct hash: libbitcoin::h512::hash {}; } diff --git a/include/metaverse/consensus/libdevcore/Guards.h b/include/metaverse/consensus/libdevcore/Guards.h index 71a1e86cd..64c131334 100644 --- a/include/metaverse/consensus/libdevcore/Guards.h +++ b/include/metaverse/consensus/libdevcore/Guards.h @@ -1,18 +1,18 @@ /* - This file is part of cpp-ethereum. + This file is part of cpp-ethereum. - cpp-ethereum is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. + cpp-ethereum is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. - cpp-ethereum is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. + cpp-ethereum is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. - You should have received a copy of the GNU General Public License - along with cpp-ethereum. If not, see . + You should have received a copy of the GNU General Public License + along with cpp-ethereum. If not, see . */ /** @file Guards.h * @author Gav Wood @@ -49,35 +49,35 @@ using WriteGuard = boost::unique_lock; template struct GenericGuardBool: GuardType { - GenericGuardBool(MutexType& _m): GuardType(_m) {} - bool b = true; + GenericGuardBool(MutexType& _m): GuardType(_m) {} + bool b = true; }; template struct GenericUnguardBool { - GenericUnguardBool(MutexType& _m): m(_m) { m.unlock(); } - ~GenericUnguardBool() { m.lock(); } - bool b = true; - MutexType& m; + GenericUnguardBool(MutexType& _m): m(_m) { m.unlock(); } + ~GenericUnguardBool() { m.lock(); } + bool b = true; + MutexType& m; }; template struct GenericUnguardSharedBool { - GenericUnguardSharedBool(MutexType& _m): m(_m) { m.unlock_shared(); } - ~GenericUnguardSharedBool() { m.lock_shared(); } - bool b = true; - MutexType& m; + GenericUnguardSharedBool(MutexType& _m): m(_m) { m.unlock_shared(); } + ~GenericUnguardSharedBool() { m.lock_shared(); } + bool b = true; + MutexType& m; }; /** @brief Simple lock that waits for release without making context switch */ class SpinLock { public: - SpinLock() { m_lock.clear(); } - void lock() { while (m_lock.test_and_set(std::memory_order_acquire)) {} } - void unlock() { m_lock.clear(std::memory_order_release); } + SpinLock() { m_lock.clear(); } + void lock() { while (m_lock.test_and_set(std::memory_order_acquire)) {} } + void unlock() { m_lock.clear(std::memory_order_release); } private: - std::atomic_flag m_lock; + std::atomic_flag m_lock; }; using SpinGuard = std::lock_guard; @@ -85,27 +85,27 @@ template class Notified { public: - Notified() {} - Notified(N const& _v): m_value(_v) {} - Notified(Notified const&) = delete; - Notified& operator=(N const& _v) { UniqueGuard l(m_mutex); m_value = _v; m_cv.notify_all(); return *this; } + Notified() {} + Notified(N const& _v): m_value(_v) {} + Notified(Notified const&) = delete; + Notified& operator=(N const& _v) { UniqueGuard l(m_mutex); m_value = _v; m_cv.notify_all(); return *this; } - operator N() const { UniqueGuard l(m_mutex); return m_value; } + operator N() const { UniqueGuard l(m_mutex); return m_value; } - void wait() const { N old; { UniqueGuard l(m_mutex); old = m_value; } waitNot(old); } - void wait(N const& _v) const { UniqueGuard l(m_mutex); m_cv.wait(l, [&](){return m_value == _v;}); } - void waitNot(N const& _v) const { UniqueGuard l(m_mutex); m_cv.wait(l, [&](){return m_value != _v;}); } - template void wait(F const& _f) const { UniqueGuard l(m_mutex); m_cv.wait(l, _f); } + void wait() const { N old; { UniqueGuard l(m_mutex); old = m_value; } waitNot(old); } + void wait(N const& _v) const { UniqueGuard l(m_mutex); m_cv.wait(l, [&](){return m_value == _v;}); } + void waitNot(N const& _v) const { UniqueGuard l(m_mutex); m_cv.wait(l, [&](){return m_value != _v;}); } + template void wait(F const& _f) const { UniqueGuard l(m_mutex); m_cv.wait(l, _f); } - template void wait(std::chrono::duration _d) const { N old; { UniqueGuard l(m_mutex); old = m_value; } waitNot(_d, old); } - template void wait(std::chrono::duration _d, N const& _v) const { UniqueGuard l(m_mutex); m_cv.wait_for(l, _d, [&](){return m_value == _v;}); } - template void waitNot(std::chrono::duration _d, N const& _v) const { UniqueGuard l(m_mutex); m_cv.wait_for(l, _d, [&](){return m_value != _v;}); } - template void wait(std::chrono::duration _d, F const& _f) const { UniqueGuard l(m_mutex); m_cv.wait_for(l, _d, _f); } + template void wait(std::chrono::duration _d) const { N old; { UniqueGuard l(m_mutex); old = m_value; } waitNot(_d, old); } + template void wait(std::chrono::duration _d, N const& _v) const { UniqueGuard l(m_mutex); m_cv.wait_for(l, _d, [&](){return m_value == _v;}); } + template void waitNot(std::chrono::duration _d, N const& _v) const { UniqueGuard l(m_mutex); m_cv.wait_for(l, _d, [&](){return m_value != _v;}); } + template void wait(std::chrono::duration _d, F const& _f) const { UniqueGuard l(m_mutex); m_cv.wait_for(l, _d, _f); } private: - mutable Mutex m_mutex; - mutable std::condition_variable m_cv; - N m_value; + mutable Mutex m_mutex; + mutable std::condition_variable m_cv; + N m_value; }; /** @brief Simple block guard. @@ -142,18 +142,18 @@ class Notified */ #define DEV_GUARDED(MUTEX) \ - for (GenericGuardBool __eth_l(MUTEX); __eth_l.b; __eth_l.b = false) + for (GenericGuardBool __eth_l(MUTEX); __eth_l.b; __eth_l.b = false) #define DEV_READ_GUARDED(MUTEX) \ - for (GenericGuardBool __eth_l(MUTEX); __eth_l.b; __eth_l.b = false) + for (GenericGuardBool __eth_l(MUTEX); __eth_l.b; __eth_l.b = false) #define DEV_WRITE_GUARDED(MUTEX) \ - for (GenericGuardBool __eth_l(MUTEX); __eth_l.b; __eth_l.b = false) + for (GenericGuardBool __eth_l(MUTEX); __eth_l.b; __eth_l.b = false) #define DEV_RECURSIVE_GUARDED(MUTEX) \ - for (GenericGuardBool __eth_l(MUTEX); __eth_l.b; __eth_l.b = false) + for (GenericGuardBool __eth_l(MUTEX); __eth_l.b; __eth_l.b = false) #define DEV_UNGUARDED(MUTEX) \ - for (GenericUnguardBool __eth_l(MUTEX); __eth_l.b; __eth_l.b = false) + for (GenericUnguardBool __eth_l(MUTEX); __eth_l.b; __eth_l.b = false) #define DEV_READ_UNGUARDED(MUTEX) \ - for (GenericUnguardSharedBool __eth_l(MUTEX); __eth_l.b; __eth_l.b = false) + for (GenericUnguardSharedBool __eth_l(MUTEX); __eth_l.b; __eth_l.b = false) #define DEV_WRITE_UNGUARDED(MUTEX) \ - for (GenericUnguardBool __eth_l(MUTEX); __eth_l.b; __eth_l.b = false) + for (GenericUnguardBool __eth_l(MUTEX); __eth_l.b; __eth_l.b = false) } diff --git a/include/metaverse/consensus/libdevcore/Log.h b/include/metaverse/consensus/libdevcore/Log.h index c51a8b7d9..e1a106011 100644 --- a/include/metaverse/consensus/libdevcore/Log.h +++ b/include/metaverse/consensus/libdevcore/Log.h @@ -1,18 +1,18 @@ /* - This file is part of cpp-ethereum. + This file is part of cpp-ethereum. - cpp-ethereum is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. + cpp-ethereum is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. - cpp-ethereum is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. + cpp-ethereum is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. - You should have received a copy of the GNU General Public License - along with cpp-ethereum. If not, see . + You should have received a copy of the GNU General Public License + along with cpp-ethereum. If not, see . */ /** @file Log.h * @author Gav Wood @@ -41,7 +41,7 @@ namespace libbitcoin class NullOutputStream { public: - template NullOutputStream& operator<<(T const&) { return *this; } + template NullOutputStream& operator<<(T const&) { return *this; } }; /// A simple log-output function that prints log messages to stdout. @@ -56,20 +56,20 @@ extern std::function g_logPost; class LogOverrideAux { protected: - LogOverrideAux(std::type_info const* _ch, bool _value); - ~LogOverrideAux(); + LogOverrideAux(std::type_info const* _ch, bool _value); + ~LogOverrideAux(); private: - std::type_info const* m_ch; - static const int c_null = -1; - int m_old; + std::type_info const* m_ch; + static const int c_null = -1; + int m_old; }; template class LogOverride: LogOverrideAux { public: - LogOverride(bool _value): LogOverrideAux(&typeid(Channel), _value) {} + LogOverride(bool _value): LogOverrideAux(&typeid(Channel), _value) {} }; bool isChannelVisible(std::type_info const* _ch, bool _default); @@ -79,9 +79,9 @@ template bool isChannelVisible() { return isChannelVisible(&type /// Not thread-safe, use with caution! struct VerbosityHolder { - VerbosityHolder(int _temporaryValue, bool _force = false): oldLogVerbosity(g_logVerbosity) { if (g_logVerbosity >= 0 || _force) g_logVerbosity = _temporaryValue; } - ~VerbosityHolder() { g_logVerbosity = oldLogVerbosity; } - int oldLogVerbosity; + VerbosityHolder(int _temporaryValue, bool _force = false): oldLogVerbosity(g_logVerbosity) { if (g_logVerbosity >= 0 || _force) g_logVerbosity = _temporaryValue; } + ~VerbosityHolder() { g_logVerbosity = oldLogVerbosity; } + int oldLogVerbosity; }; #define ETH_THREAD_CONTEXT(name) for (std::pair __eth_thread_context(name, true); p.second; p.second = false) @@ -89,12 +89,12 @@ struct VerbosityHolder class ThreadContext { public: - ThreadContext(std::string const& _info) { push(_info); } - ~ThreadContext() { pop(); } + ThreadContext(std::string const& _info) { push(_info); } + ~ThreadContext() { pop(); } - static void push(std::string const& _n); - static void pop(); - static std::string join(std::string const& _prior); + static void push(std::string const& _n); + static void pop(); + static std::string join(std::string const& _prior); }; /// Set the current thread's log name. @@ -137,125 +137,125 @@ struct TraceChannel: public LogChannel { static const char* name(); static const enum class LogTag { - None, - Url, - Error, - Special + None, + Url, + Error, + Special }; class LogOutputStreamBase { public: - LogOutputStreamBase(char const* _id, std::type_info const* _info, unsigned _v, bool _autospacing); - - void comment(std::string const& _t) - { - switch (m_logTag) - { - case LogTag::Url: m_sstr << EthNavyUnder; break; - case LogTag::Error: m_sstr << EthRedBold; break; - case LogTag::Special: m_sstr << EthWhiteBold; break; - default:; - } - m_sstr << _t << EthReset; - m_logTag = LogTag::None; - } - - void append(unsigned long _t) { m_sstr << EthBlue << _t << EthReset; } - void append(long _t) { m_sstr << EthBlue << _t << EthReset; } - void append(unsigned int _t) { m_sstr << EthBlue << _t << EthReset; } - void append(int _t) { m_sstr << EthBlue << _t << EthReset; } - void append(bigint const& _t) { m_sstr << EthNavy << _t << EthReset; } - void append(u256 const& _t) { m_sstr << EthNavy << _t << EthReset; } - void append(u160 const& _t) { m_sstr << EthNavy << _t << EthReset; } - void append(double _t) { m_sstr << EthBlue << _t << EthReset; } - template void append(FixedHash const& _t) { m_sstr << EthTeal "#" << _t.abridged() << EthReset; } - void append(h160 const& _t) { m_sstr << EthRed "@" << _t.abridged() << EthReset; } - void append(h256 const& _t) { m_sstr << EthCyan "#" << _t.abridged() << EthReset; } - void append(h512 const& _t) { m_sstr << EthTeal "##" << _t.abridged() << EthReset; } - void append(std::string const& _t) { m_sstr << EthGreen "\"" + _t + "\"" EthReset; } - void append(bytes const& _t) { m_sstr << EthYellow "%" << toHex(_t) << EthReset; } - void append(bytesConstRef _t) { m_sstr << EthYellow "%" << toHex(_t) << EthReset; } + LogOutputStreamBase(char const* _id, std::type_info const* _info, unsigned _v, bool _autospacing); + + void comment(std::string const& _t) + { + switch (m_logTag) + { + case LogTag::Url: m_sstr << EthNavyUnder; break; + case LogTag::Error: m_sstr << EthRedBold; break; + case LogTag::Special: m_sstr << EthWhiteBold; break; + default:; + } + m_sstr << _t << EthReset; + m_logTag = LogTag::None; + } + + void append(unsigned long _t) { m_sstr << EthBlue << _t << EthReset; } + void append(long _t) { m_sstr << EthBlue << _t << EthReset; } + void append(unsigned int _t) { m_sstr << EthBlue << _t << EthReset; } + void append(int _t) { m_sstr << EthBlue << _t << EthReset; } + void append(bigint const& _t) { m_sstr << EthNavy << _t << EthReset; } + void append(u256 const& _t) { m_sstr << EthNavy << _t << EthReset; } + void append(u160 const& _t) { m_sstr << EthNavy << _t << EthReset; } + void append(double _t) { m_sstr << EthBlue << _t << EthReset; } + template void append(FixedHash const& _t) { m_sstr << EthTeal "#" << _t.abridged() << EthReset; } + void append(h160 const& _t) { m_sstr << EthRed "@" << _t.abridged() << EthReset; } + void append(h256 const& _t) { m_sstr << EthCyan "#" << _t.abridged() << EthReset; } + void append(h512 const& _t) { m_sstr << EthTeal "##" << _t.abridged() << EthReset; } + void append(std::string const& _t) { m_sstr << EthGreen "\"" + _t + "\"" EthReset; } + void append(bytes const& _t) { m_sstr << EthYellow "%" << toHex(_t) << EthReset; } + void append(bytesConstRef _t) { m_sstr << EthYellow "%" << toHex(_t) << EthReset; } #if !defined(ETH_EMSCRIPTEN) - void append(boost::asio::ip::basic_endpoint const& _t); + void append(boost::asio::ip::basic_endpoint const& _t); #endif - template void append(std::vector const& _t) - { - m_sstr << EthWhite "[" EthReset; - int n = 0; - for (auto const& i: _t) - { - m_sstr << (n++ ? EthWhite ", " EthReset : ""); - append(i); - } - m_sstr << EthWhite "]" EthReset; - } - template void append(std::set const& _t) - { - m_sstr << EthYellow "{" EthReset; - int n = 0; - for (auto const& i: _t) - { - m_sstr << (n++ ? EthYellow ", " EthReset : ""); - append(i); - } - m_sstr << EthYellow "}" EthReset; - } - template void append(std::map const& _t) - { - m_sstr << EthLime "{" EthReset; - int n = 0; - for (auto const& i: _t) - { - m_sstr << (n++ ? EthLime ", " EthReset : ""); - append(i.first); - m_sstr << (n++ ? EthLime ": " EthReset : ""); - append(i.second); - } - m_sstr << EthLime "}" EthReset; - } - template void append(std::unordered_set const& _t) - { - m_sstr << EthYellow "{" EthReset; - int n = 0; - for (auto const& i: _t) - { - m_sstr << (n++ ? EthYellow ", " EthReset : ""); - append(i); - } - m_sstr << EthYellow "}" EthReset; - } - template void append(std::unordered_map const& _t) - { - m_sstr << EthLime "{" EthReset; - int n = 0; - for (auto const& i: _t) - { - m_sstr << (n++ ? EthLime ", " EthReset : ""); - append(i.first); - m_sstr << (n++ ? EthLime ": " EthReset : ""); - append(i.second); - } - m_sstr << EthLime "}" EthReset; - } - template void append(std::pair const& _t) - { - m_sstr << EthPurple "(" EthReset; - append(_t.first); - m_sstr << EthPurple ", " EthReset; - append(_t.second); - m_sstr << EthPurple ")" EthReset; - } - template void append(T const& _t) - { - m_sstr << toString(_t); - } + template void append(std::vector const& _t) + { + m_sstr << EthWhite "[" EthReset; + int n = 0; + for (auto const& i: _t) + { + m_sstr << (n++ ? EthWhite ", " EthReset : ""); + append(i); + } + m_sstr << EthWhite "]" EthReset; + } + template void append(std::set const& _t) + { + m_sstr << EthYellow "{" EthReset; + int n = 0; + for (auto const& i: _t) + { + m_sstr << (n++ ? EthYellow ", " EthReset : ""); + append(i); + } + m_sstr << EthYellow "}" EthReset; + } + template void append(std::map const& _t) + { + m_sstr << EthLime "{" EthReset; + int n = 0; + for (auto const& i: _t) + { + m_sstr << (n++ ? EthLime ", " EthReset : ""); + append(i.first); + m_sstr << (n++ ? EthLime ": " EthReset : ""); + append(i.second); + } + m_sstr << EthLime "}" EthReset; + } + template void append(std::unordered_set const& _t) + { + m_sstr << EthYellow "{" EthReset; + int n = 0; + for (auto const& i: _t) + { + m_sstr << (n++ ? EthYellow ", " EthReset : ""); + append(i); + } + m_sstr << EthYellow "}" EthReset; + } + template void append(std::unordered_map const& _t) + { + m_sstr << EthLime "{" EthReset; + int n = 0; + for (auto const& i: _t) + { + m_sstr << (n++ ? EthLime ", " EthReset : ""); + append(i.first); + m_sstr << (n++ ? EthLime ": " EthReset : ""); + append(i.second); + } + m_sstr << EthLime "}" EthReset; + } + template void append(std::pair const& _t) + { + m_sstr << EthPurple "(" EthReset; + append(_t.first); + m_sstr << EthPurple ", " EthReset; + append(_t.second); + m_sstr << EthPurple ")" EthReset; + } + template void append(T const& _t) + { + m_sstr << toString(_t); + } protected: - bool m_autospacing = false; - unsigned m_verbosity = 0; - std::stringstream m_sstr; ///< The accrued log entry. - LogTag m_logTag = LogTag::None; + bool m_autospacing = false; + unsigned m_verbosity = 0; + std::stringstream m_sstr; ///< The accrued log entry. + LogTag m_logTag = LogTag::None; }; /// Logging class, iostream-like, that can be shifted to. @@ -263,19 +263,19 @@ template class LogOutputStream: LogOutputStreamBase { public: - /// Construct a new object. - /// If _term is true the the prefix info is terminated with a ']' character; if not it ends only with a '|' character. - LogOutputStream(): LogOutputStreamBase(Id::name(), &typeid(Id), Id::verbosity, _AutoSpacing) {} + /// Construct a new object. + /// If _term is true the the prefix info is terminated with a ']' character; if not it ends only with a '|' character. + LogOutputStream(): LogOutputStreamBase(Id::name(), &typeid(Id), Id::verbosity, _AutoSpacing) {} - /// Destructor. Posts the accrued log entry to the g_logPost function. - ~LogOutputStream() { if (Id::verbosity <= g_logVerbosity) g_logPost(m_sstr.str(), Id::name()); } + /// Destructor. Posts the accrued log entry to the g_logPost function. + ~LogOutputStream() { if (Id::verbosity <= g_logVerbosity) g_logPost(m_sstr.str(), Id::name()); } - LogOutputStream& operator<<(std::string const& _t) { if (Id::verbosity <= g_logVerbosity) { if (_AutoSpacing && m_sstr.str().size() && m_sstr.str().back() != ' ') m_sstr << " "; comment(_t); } return *this; } + LogOutputStream& operator<<(std::string const& _t) { if (Id::verbosity <= g_logVerbosity) { if (_AutoSpacing && m_sstr.str().size() && m_sstr.str().back() != ' ') m_sstr << " "; comment(_t); } return *this; } - LogOutputStream& operator<<(LogTag _t) { m_logTag = _t; return *this; } + LogOutputStream& operator<<(LogTag _t) { m_logTag = _t; return *this; } - /// Shift arbitrary data to the log. Spaces will be added between items as required. - template LogOutputStream& operator<<(T const& _t) { if (Id::verbosity <= g_logVerbosity) { if (_AutoSpacing && m_sstr.str().size() && m_sstr.str().back() != ' ') m_sstr << " "; append(_t); } return *this; } + /// Shift arbitrary data to the log. Spaces will be added between items as required. + template LogOutputStream& operator<<(T const& _t) { if (Id::verbosity <= g_logVerbosity) { if (_AutoSpacing && m_sstr.str().size() && m_sstr.str().back() != ' ') m_sstr << " "; append(_t); } return *this; } }; /// A "hacky" way to execute the next statement on COND. diff --git a/include/metaverse/consensus/libdevcore/RLP.h b/include/metaverse/consensus/libdevcore/RLP.h index 83c03a26e..882ba9cf2 100644 --- a/include/metaverse/consensus/libdevcore/RLP.h +++ b/include/metaverse/consensus/libdevcore/RLP.h @@ -1,18 +1,18 @@ /* - This file is part of cpp-ethereum. + This file is part of cpp-ethereum. - cpp-ethereum is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. + cpp-ethereum is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. - cpp-ethereum is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. + cpp-ethereum is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. - You should have received a copy of the GNU General Public License - along with cpp-ethereum. If not, see . + You should have received a copy of the GNU General Public License + along with cpp-ethereum. If not, see . */ /** @file RLP.h * @author Gav Wood @@ -64,298 +64,298 @@ template struct Converter { static T convert(RLP const&, int) { BOOST_ class RLP { public: - /// Conversion flags - enum - { - AllowNonCanon = 1, - ThrowOnFail = 4, - FailIfTooBig = 8, - FailIfTooSmall = 16, - Strict = ThrowOnFail | FailIfTooBig, - VeryStrict = ThrowOnFail | FailIfTooBig | FailIfTooSmall, - LaissezFaire = AllowNonCanon - }; - - using Strictness = int; - - /// Construct a null node. - RLP() {} - - /// Construct a node of value given in the bytes. - explicit RLP(bytesConstRef _d, Strictness _s = VeryStrict); - - /// Construct a node of value given in the bytes. - explicit RLP(bytes const& _d, Strictness _s = VeryStrict): RLP(&_d, _s) {} - - /// Construct a node to read RLP data in the bytes given. - RLP(byte const* _b, unsigned _s, Strictness _st = VeryStrict): RLP(bytesConstRef(_b, _s), _st) {} - - /// Construct a node to read RLP data in the string. - explicit RLP(std::string const& _s, Strictness _st = VeryStrict): RLP(bytesConstRef((byte const*)_s.data(), _s.size()), _st) {} - - /// The bare data of the RLP. - bytesConstRef data() const { return m_data; } - - /// @returns true if the RLP is non-null. - explicit operator bool() const { return !isNull(); } - - /// No value. - bool isNull() const { return m_data.size() == 0; } - - /// Contains a zero-length string or zero-length list. - bool isEmpty() const { return !isNull() && (m_data[0] == c_rlpDataImmLenStart || m_data[0] == c_rlpListStart); } - - /// String value. - bool isData() const { return !isNull() && m_data[0] < c_rlpListStart; } - - /// List value. - bool isList() const { return !isNull() && m_data[0] >= c_rlpListStart; } - - /// Integer value. Must not have a leading zero. - bool isInt() const; - - /// @returns the number of items in the list, or zero if it isn't a list. - size_t itemCount() const { return isList() ? items() : 0; } - size_t itemCountStrict() const { if (!isList()) BOOST_THROW_EXCEPTION(BadCast()); return items(); } - - /// @returns the number of bytes in the data, or zero if it isn't data. - size_t size() const { return isData() ? length() : 0; } - size_t sizeStrict() const { if (!isData()) BOOST_THROW_EXCEPTION(BadCast()); return length(); } - - /// Equality operators; does best-effort conversion and checks for equality. - bool operator==(char const* _s) const { return isData() && toString() == _s; } - bool operator!=(char const* _s) const { return isData() && toString() != _s; } - bool operator==(std::string const& _s) const { return isData() && toString() == _s; } - bool operator!=(std::string const& _s) const { return isData() && toString() != _s; } - template bool operator==(FixedHash<_N> const& _h) const { return isData() && toHash<_N>() == _h; } - template bool operator!=(FixedHash<_N> const& _s) const { return isData() && toHash<_N>() != _s; } - bool operator==(unsigned const& _i) const { return isInt() && toInt() == _i; } - bool operator!=(unsigned const& _i) const { return isInt() && toInt() != _i; } - bool operator==(u256 const& _i) const { return isInt() && toInt() == _i; } - bool operator!=(u256 const& _i) const { return isInt() && toInt() != _i; } - bool operator==(bigint const& _i) const { return isInt() && toInt() == _i; } - bool operator!=(bigint const& _i) const { return isInt() && toInt() != _i; } - - /// Subscript operator. - /// @returns the list item @a _i if isList() and @a _i < listItems(), or RLP() otherwise. - /// @note if used to access items in ascending order, this is efficient. - RLP operator[](size_t _i) const; - - using element_type = RLP; - - /// @brief Iterator class for iterating through items of RLP list. - class iterator - { - friend class RLP; - - public: - using value_type = RLP; - using element_type = RLP; - - iterator& operator++(); - iterator operator++(int) { auto ret = *this; operator++(); return ret; } - RLP operator*() const { return RLP(m_currentItem); } - bool operator==(iterator const& _cmp) const { return m_currentItem == _cmp.m_currentItem; } - bool operator!=(iterator const& _cmp) const { return !operator==(_cmp); } - - private: - iterator() {} - iterator(RLP const& _parent, bool _begin); - - size_t m_remaining = 0; - bytesConstRef m_currentItem; - }; - - /// @brief Iterator into beginning of sub-item list (valid only if we are a list). - iterator begin() const { return iterator(*this, true); } - - /// @brief Iterator into end of sub-item list (valid only if we are a list). - iterator end() const { return iterator(*this, false); } - - template inline T convert(int _flags) const; - - /// Best-effort conversion operators. - explicit operator std::string() const { return toString(); } - explicit operator bytes() const { return toBytes(); } - explicit operator RLPs() const { return toList(); } - explicit operator uint8_t() const { return toInt(); } - explicit operator uint16_t() const { return toInt(); } - explicit operator uint32_t() const { return toInt(); } - explicit operator uint64_t() const { return toInt(); } - explicit operator u160() const { return toInt(); } - explicit operator u256() const { return toInt(); } - explicit operator bigint() const { return toInt(); } - template explicit operator FixedHash() const { return toHash>(); } - template explicit operator std::pair() const { return toPair(); } - template explicit operator std::vector() const { return toVector(); } - template explicit operator std::set() const { return toSet(); } - template explicit operator std::array() const { return toArray(); } - - /// Converts to bytearray. @returns the empty byte array if not a string. - bytes toBytes(int _flags = LaissezFaire) const { if (!isData()) { if (_flags & ThrowOnFail) BOOST_THROW_EXCEPTION(BadCast()); else return bytes(); } return bytes(payload().data(), payload().data() + length()); } - /// Converts to bytearray. @returns the empty byte array if not a string. - bytesConstRef toBytesConstRef(int _flags = LaissezFaire) const { if (!isData()) { if (_flags & ThrowOnFail) BOOST_THROW_EXCEPTION(BadCast()); else return bytesConstRef(); } return payload().cropped(0, length()); } - /// Converts to string. @returns the empty string if not a string. - std::string toString(int _flags = LaissezFaire) const { if (!isData()) { if (_flags & ThrowOnFail) BOOST_THROW_EXCEPTION(BadCast()); else return std::string(); } return payload().cropped(0, length()).toString(); } - /// Converts to string. @throws BadCast if not a string. - std::string toStringStrict() const { return toString(Strict); } - - template - std::vector toVector(int _flags = LaissezFaire) const - { - std::vector ret; - if (isList()) - { - ret.reserve(itemCount()); - for (auto const& i: *this) - ret.push_back(i.convert(_flags)); - } - else if (_flags & ThrowOnFail) - BOOST_THROW_EXCEPTION(BadCast()); - return ret; - } - - template - std::set toSet(int _flags = LaissezFaire) const - { - std::set ret; - if (isList()) - for (auto const& i: *this) - ret.insert(i.convert(_flags)); - else if (_flags & ThrowOnFail) - BOOST_THROW_EXCEPTION(BadCast()); - return ret; - } - - template - std::unordered_set toUnorderedSet(int _flags = LaissezFaire) const - { - std::unordered_set ret; - if (isList()) - for (auto const& i: *this) - ret.insert(i.convert(_flags)); - else if (_flags & ThrowOnFail) - BOOST_THROW_EXCEPTION(BadCast()); - return ret; - } - - template - std::pair toPair(int _flags = Strict) const - { - std::pair ret; - if (itemCountStrict() != 2) - { - if (_flags & ThrowOnFail) - BOOST_THROW_EXCEPTION(BadCast()); - else - return ret; - } - ret.first = (*this)[0].convert(_flags); - ret.second = (*this)[1].convert(_flags); - return ret; - } - - template - std::array toArray(int _flags = LaissezFaire) const - { - if (itemCountStrict() != N) - { - if (_flags & ThrowOnFail) - BOOST_THROW_EXCEPTION(BadCast()); - else - return std::array(); - } - std::array ret; - for (size_t i = 0; i < N; ++i) - ret[i] = operator[](i).convert(_flags); - return ret; - } - - /// Converts to int of type given; if isString(), decodes as big-endian bytestream. @returns 0 if not an int or string. - template _T toInt(int _flags = Strict) const - { - requireGood(); - if ((!isInt() && !(_flags & AllowNonCanon)) || isList() || isNull()) - { - if (_flags & ThrowOnFail) - BOOST_THROW_EXCEPTION(BadCast()); - else - return 0; - } - - auto p = payload(); - if (p.size() > intTraits<_T>::maxSize && (_flags & FailIfTooBig)) - { - if (_flags & ThrowOnFail) - BOOST_THROW_EXCEPTION(BadCast()); - else - return 0; - } - - return fromBigEndian<_T>(p); - } - - template _N toHash(int _flags = Strict) const - { - requireGood(); - auto p = payload(); - auto l = p.size(); - if (!isData() || (l > _N::size && (_flags & FailIfTooBig)) || (l < _N::size && (_flags & FailIfTooSmall))) - { - if (_flags & ThrowOnFail) - BOOST_THROW_EXCEPTION(BadCast()); - else - return _N(); - } - - _N ret; - size_t s = std::min(_N::size, l); - memcpy(ret.data() + _N::size - s, p.data(), s); - return ret; - } - - /// Converts to RLPs collection object. Useful if you need random access to sub items or will iterate over multiple times. - RLPs toList(int _flags = Strict) const; - - /// @returns the data payload. Valid for all types. - bytesConstRef payload() const { auto l = length(); if (l > m_data.size()) BOOST_THROW_EXCEPTION(BadRLP()); return m_data.cropped(payloadOffset(), l); } - - /// @returns the theoretical size of this item as encoded in the data. - /// @note Under normal circumstances, is equivalent to m_data.size() - use that unless you know it won't work. - size_t actualSize() const; + /// Conversion flags + enum + { + AllowNonCanon = 1, + ThrowOnFail = 4, + FailIfTooBig = 8, + FailIfTooSmall = 16, + Strict = ThrowOnFail | FailIfTooBig, + VeryStrict = ThrowOnFail | FailIfTooBig | FailIfTooSmall, + LaissezFaire = AllowNonCanon + }; + + using Strictness = int; + + /// Construct a null node. + RLP() {} + + /// Construct a node of value given in the bytes. + explicit RLP(bytesConstRef _d, Strictness _s = VeryStrict); + + /// Construct a node of value given in the bytes. + explicit RLP(bytes const& _d, Strictness _s = VeryStrict): RLP(&_d, _s) {} + + /// Construct a node to read RLP data in the bytes given. + RLP(byte const* _b, unsigned _s, Strictness _st = VeryStrict): RLP(bytesConstRef(_b, _s), _st) {} + + /// Construct a node to read RLP data in the string. + explicit RLP(std::string const& _s, Strictness _st = VeryStrict): RLP(bytesConstRef((byte const*)_s.data(), _s.size()), _st) {} + + /// The bare data of the RLP. + bytesConstRef data() const { return m_data; } + + /// @returns true if the RLP is non-null. + explicit operator bool() const { return !isNull(); } + + /// No value. + bool isNull() const { return m_data.size() == 0; } + + /// Contains a zero-length string or zero-length list. + bool isEmpty() const { return !isNull() && (m_data[0] == c_rlpDataImmLenStart || m_data[0] == c_rlpListStart); } + + /// String value. + bool isData() const { return !isNull() && m_data[0] < c_rlpListStart; } + + /// List value. + bool isList() const { return !isNull() && m_data[0] >= c_rlpListStart; } + + /// Integer value. Must not have a leading zero. + bool isInt() const; + + /// @returns the number of items in the list, or zero if it isn't a list. + size_t itemCount() const { return isList() ? items() : 0; } + size_t itemCountStrict() const { if (!isList()) BOOST_THROW_EXCEPTION(BadCast()); return items(); } + + /// @returns the number of bytes in the data, or zero if it isn't data. + size_t size() const { return isData() ? length() : 0; } + size_t sizeStrict() const { if (!isData()) BOOST_THROW_EXCEPTION(BadCast()); return length(); } + + /// Equality operators; does best-effort conversion and checks for equality. + bool operator==(char const* _s) const { return isData() && toString() == _s; } + bool operator!=(char const* _s) const { return isData() && toString() != _s; } + bool operator==(std::string const& _s) const { return isData() && toString() == _s; } + bool operator!=(std::string const& _s) const { return isData() && toString() != _s; } + template bool operator==(FixedHash<_N> const& _h) const { return isData() && toHash<_N>() == _h; } + template bool operator!=(FixedHash<_N> const& _s) const { return isData() && toHash<_N>() != _s; } + bool operator==(unsigned const& _i) const { return isInt() && toInt() == _i; } + bool operator!=(unsigned const& _i) const { return isInt() && toInt() != _i; } + bool operator==(u256 const& _i) const { return isInt() && toInt() == _i; } + bool operator!=(u256 const& _i) const { return isInt() && toInt() != _i; } + bool operator==(bigint const& _i) const { return isInt() && toInt() == _i; } + bool operator!=(bigint const& _i) const { return isInt() && toInt() != _i; } + + /// Subscript operator. + /// @returns the list item @a _i if isList() and @a _i < listItems(), or RLP() otherwise. + /// @note if used to access items in ascending order, this is efficient. + RLP operator[](size_t _i) const; + + using element_type = RLP; + + /// @brief Iterator class for iterating through items of RLP list. + class iterator + { + friend class RLP; + + public: + using value_type = RLP; + using element_type = RLP; + + iterator& operator++(); + iterator operator++(int) { auto ret = *this; operator++(); return ret; } + RLP operator*() const { return RLP(m_currentItem); } + bool operator==(iterator const& _cmp) const { return m_currentItem == _cmp.m_currentItem; } + bool operator!=(iterator const& _cmp) const { return !operator==(_cmp); } + + private: + iterator() {} + iterator(RLP const& _parent, bool _begin); + + size_t m_remaining = 0; + bytesConstRef m_currentItem; + }; + + /// @brief Iterator into beginning of sub-item list (valid only if we are a list). + iterator begin() const { return iterator(*this, true); } + + /// @brief Iterator into end of sub-item list (valid only if we are a list). + iterator end() const { return iterator(*this, false); } + + template inline T convert(int _flags) const; + + /// Best-effort conversion operators. + explicit operator std::string() const { return toString(); } + explicit operator bytes() const { return toBytes(); } + explicit operator RLPs() const { return toList(); } + explicit operator uint8_t() const { return toInt(); } + explicit operator uint16_t() const { return toInt(); } + explicit operator uint32_t() const { return toInt(); } + explicit operator uint64_t() const { return toInt(); } + explicit operator u160() const { return toInt(); } + explicit operator u256() const { return toInt(); } + explicit operator bigint() const { return toInt(); } + template explicit operator FixedHash() const { return toHash>(); } + template explicit operator std::pair() const { return toPair(); } + template explicit operator std::vector() const { return toVector(); } + template explicit operator std::set() const { return toSet(); } + template explicit operator std::array() const { return toArray(); } + + /// Converts to bytearray. @returns the empty byte array if not a string. + bytes toBytes(int _flags = LaissezFaire) const { if (!isData()) { if (_flags & ThrowOnFail) BOOST_THROW_EXCEPTION(BadCast()); else return bytes(); } return bytes(payload().data(), payload().data() + length()); } + /// Converts to bytearray. @returns the empty byte array if not a string. + bytesConstRef toBytesConstRef(int _flags = LaissezFaire) const { if (!isData()) { if (_flags & ThrowOnFail) BOOST_THROW_EXCEPTION(BadCast()); else return bytesConstRef(); } return payload().cropped(0, length()); } + /// Converts to string. @returns the empty string if not a string. + std::string toString(int _flags = LaissezFaire) const { if (!isData()) { if (_flags & ThrowOnFail) BOOST_THROW_EXCEPTION(BadCast()); else return std::string(); } return payload().cropped(0, length()).toString(); } + /// Converts to string. @throws BadCast if not a string. + std::string toStringStrict() const { return toString(Strict); } + + template + std::vector toVector(int _flags = LaissezFaire) const + { + std::vector ret; + if (isList()) + { + ret.reserve(itemCount()); + for (auto const& i: *this) + ret.push_back(i.convert(_flags)); + } + else if (_flags & ThrowOnFail) + BOOST_THROW_EXCEPTION(BadCast()); + return ret; + } + + template + std::set toSet(int _flags = LaissezFaire) const + { + std::set ret; + if (isList()) + for (auto const& i: *this) + ret.insert(i.convert(_flags)); + else if (_flags & ThrowOnFail) + BOOST_THROW_EXCEPTION(BadCast()); + return ret; + } + + template + std::unordered_set toUnorderedSet(int _flags = LaissezFaire) const + { + std::unordered_set ret; + if (isList()) + for (auto const& i: *this) + ret.insert(i.convert(_flags)); + else if (_flags & ThrowOnFail) + BOOST_THROW_EXCEPTION(BadCast()); + return ret; + } + + template + std::pair toPair(int _flags = Strict) const + { + std::pair ret; + if (itemCountStrict() != 2) + { + if (_flags & ThrowOnFail) + BOOST_THROW_EXCEPTION(BadCast()); + else + return ret; + } + ret.first = (*this)[0].convert(_flags); + ret.second = (*this)[1].convert(_flags); + return ret; + } + + template + std::array toArray(int _flags = LaissezFaire) const + { + if (itemCountStrict() != N) + { + if (_flags & ThrowOnFail) + BOOST_THROW_EXCEPTION(BadCast()); + else + return std::array(); + } + std::array ret; + for (size_t i = 0; i < N; ++i) + ret[i] = operator[](i).convert(_flags); + return ret; + } + + /// Converts to int of type given; if isString(), decodes as big-endian bytestream. @returns 0 if not an int or string. + template _T toInt(int _flags = Strict) const + { + requireGood(); + if ((!isInt() && !(_flags & AllowNonCanon)) || isList() || isNull()) + { + if (_flags & ThrowOnFail) + BOOST_THROW_EXCEPTION(BadCast()); + else + return 0; + } + + auto p = payload(); + if (p.size() > intTraits<_T>::maxSize && (_flags & FailIfTooBig)) + { + if (_flags & ThrowOnFail) + BOOST_THROW_EXCEPTION(BadCast()); + else + return 0; + } + + return fromBigEndian<_T>(p); + } + + template _N toHash(int _flags = Strict) const + { + requireGood(); + auto p = payload(); + auto l = p.size(); + if (!isData() || (l > _N::size && (_flags & FailIfTooBig)) || (l < _N::size && (_flags & FailIfTooSmall))) + { + if (_flags & ThrowOnFail) + BOOST_THROW_EXCEPTION(BadCast()); + else + return _N(); + } + + _N ret; + size_t s = std::min(_N::size, l); + memcpy(ret.data() + _N::size - s, p.data(), s); + return ret; + } + + /// Converts to RLPs collection object. Useful if you need random access to sub items or will iterate over multiple times. + RLPs toList(int _flags = Strict) const; + + /// @returns the data payload. Valid for all types. + bytesConstRef payload() const { auto l = length(); if (l > m_data.size()) BOOST_THROW_EXCEPTION(BadRLP()); return m_data.cropped(payloadOffset(), l); } + + /// @returns the theoretical size of this item as encoded in the data. + /// @note Under normal circumstances, is equivalent to m_data.size() - use that unless you know it won't work. + size_t actualSize() const; private: - /// Disable construction from rvalue - explicit RLP(bytes const&&) {} + /// Disable construction from rvalue + explicit RLP(bytes const&&) {} - /// Throws if is non-canonical data (i.e. single byte done in two bytes that could be done in one). - void requireGood() const; + /// Throws if is non-canonical data (i.e. single byte done in two bytes that could be done in one). + void requireGood() const; - /// Single-byte data payload. - bool isSingleByte() const { return !isNull() && m_data[0] < c_rlpDataImmLenStart; } + /// Single-byte data payload. + bool isSingleByte() const { return !isNull() && m_data[0] < c_rlpDataImmLenStart; } - /// @returns the amount of bytes used to encode the length of the data. Valid for all types. - unsigned lengthSize() const { if (isData() && m_data[0] > c_rlpDataIndLenZero) return m_data[0] - c_rlpDataIndLenZero; if (isList() && m_data[0] > c_rlpListIndLenZero) return m_data[0] - c_rlpListIndLenZero; return 0; } + /// @returns the amount of bytes used to encode the length of the data. Valid for all types. + unsigned lengthSize() const { if (isData() && m_data[0] > c_rlpDataIndLenZero) return m_data[0] - c_rlpDataIndLenZero; if (isList() && m_data[0] > c_rlpListIndLenZero) return m_data[0] - c_rlpListIndLenZero; return 0; } - /// @returns the size in bytes of the payload, as given by the RLP as opposed to as inferred from m_data. - size_t length() const; + /// @returns the size in bytes of the payload, as given by the RLP as opposed to as inferred from m_data. + size_t length() const; - /// @returns the number of bytes into the data that the payload starts. - size_t payloadOffset() const { return isSingleByte() ? 0 : (1 + lengthSize()); } + /// @returns the number of bytes into the data that the payload starts. + size_t payloadOffset() const { return isSingleByte() ? 0 : (1 + lengthSize()); } - /// @returns the number of data items. - size_t items() const; + /// @returns the number of data items. + size_t items() const; - /// @returns the size encoded into the RLP in @a _data and throws if _data is too short. - static size_t sizeAsEncoded(bytesConstRef _data) { return RLP(_data, ThrowOnFail | FailIfTooSmall).actualSize(); } + /// @returns the size encoded into the RLP in @a _data and throws if _data is too short. + static size_t sizeAsEncoded(bytesConstRef _data) { return RLP(_data, ThrowOnFail | FailIfTooSmall).actualSize(); } - /// Our byte data. - bytesConstRef m_data; + /// Our byte data. + bytesConstRef m_data; - /// The list-indexing cache. - mutable size_t m_lastIndex = (size_t)-1; - mutable size_t m_lastEnd = 0; - mutable bytesConstRef m_lastItem; + /// The list-indexing cache. + mutable size_t m_lastIndex = (size_t)-1; + mutable size_t m_lastEnd = 0; + mutable bytesConstRef m_lastItem; }; template <> struct Converter { static std::string convert(RLP const& _r, int _flags) { return _r.toString(_flags); } }; @@ -383,81 +383,81 @@ template inline T RLP::convert(int _flags) const { return Converter class RLPStream { public: - /// Initializes empty RLPStream. - RLPStream() {} + /// Initializes empty RLPStream. + RLPStream() {} - /// Initializes the RLPStream as a list of @a _listItems items. - explicit RLPStream(size_t _listItems) { appendList(_listItems); } + /// Initializes the RLPStream as a list of @a _listItems items. + explicit RLPStream(size_t _listItems) { appendList(_listItems); } - ~RLPStream() {} + ~RLPStream() {} - /// Append given datum to the byte stream. - RLPStream& append(unsigned _s) { return append(bigint(_s)); } - RLPStream& append(u160 _s) { return append(bigint(_s)); } - RLPStream& append(u256 _s) { return append(bigint(_s)); } - RLPStream& append(bigint _s); - RLPStream& append(bytesConstRef _s, bool _compact = false); - RLPStream& append(bytes const& _s) { return append(bytesConstRef(&_s)); } - RLPStream& append(std::string const& _s) { return append(bytesConstRef(_s)); } - RLPStream& append(char const* _s) { return append(std::string(_s)); } - template RLPStream& append(FixedHash _s, bool _compact = false, bool _allOrNothing = false) { return _allOrNothing && !_s ? append(bytesConstRef()) : append(_s.ref(), _compact); } + /// Append given datum to the byte stream. + RLPStream& append(unsigned _s) { return append(bigint(_s)); } + RLPStream& append(u160 _s) { return append(bigint(_s)); } + RLPStream& append(u256 _s) { return append(bigint(_s)); } + RLPStream& append(bigint _s); + RLPStream& append(bytesConstRef _s, bool _compact = false); + RLPStream& append(bytes const& _s) { return append(bytesConstRef(&_s)); } + RLPStream& append(std::string const& _s) { return append(bytesConstRef(_s)); } + RLPStream& append(char const* _s) { return append(std::string(_s)); } + template RLPStream& append(FixedHash _s, bool _compact = false, bool _allOrNothing = false) { return _allOrNothing && !_s ? append(bytesConstRef()) : append(_s.ref(), _compact); } - /// Appends an arbitrary RLP fragment - this *must* be a single item unless @a _itemCount is given. - RLPStream& append(RLP const& _rlp, size_t _itemCount = 1) { return appendRaw(_rlp.data(), _itemCount); } + /// Appends an arbitrary RLP fragment - this *must* be a single item unless @a _itemCount is given. + RLPStream& append(RLP const& _rlp, size_t _itemCount = 1) { return appendRaw(_rlp.data(), _itemCount); } - /// Appends a sequence of data to the stream as a list. - template RLPStream& append(std::vector<_T> const& _s) { return appendVector(_s); } - template RLPStream& appendVector(std::vector<_T> const& _s) { appendList(_s.size()); for (auto const& i: _s) append(i); return *this; } - template RLPStream& append(std::array<_T, S> const& _s) { appendList(_s.size()); for (auto const& i: _s) append(i); return *this; } - template RLPStream& append(std::set<_T> const& _s) { appendList(_s.size()); for (auto const& i: _s) append(i); return *this; } - template RLPStream& append(std::unordered_set<_T> const& _s) { appendList(_s.size()); for (auto const& i: _s) append(i); return *this; } - template RLPStream& append(std::pair const& _s) { appendList(2); append(_s.first); append(_s.second); return *this; } + /// Appends a sequence of data to the stream as a list. + template RLPStream& append(std::vector<_T> const& _s) { return appendVector(_s); } + template RLPStream& appendVector(std::vector<_T> const& _s) { appendList(_s.size()); for (auto const& i: _s) append(i); return *this; } + template RLPStream& append(std::array<_T, S> const& _s) { appendList(_s.size()); for (auto const& i: _s) append(i); return *this; } + template RLPStream& append(std::set<_T> const& _s) { appendList(_s.size()); for (auto const& i: _s) append(i); return *this; } + template RLPStream& append(std::unordered_set<_T> const& _s) { appendList(_s.size()); for (auto const& i: _s) append(i); return *this; } + template RLPStream& append(std::pair const& _s) { appendList(2); append(_s.first); append(_s.second); return *this; } - /// Appends a list. - RLPStream& appendList(size_t _items); - RLPStream& appendList(bytesConstRef _rlp); - RLPStream& appendList(bytes const& _rlp) { return appendList(&_rlp); } - RLPStream& appendList(RLPStream const& _s) { return appendList(&_s.out()); } + /// Appends a list. + RLPStream& appendList(size_t _items); + RLPStream& appendList(bytesConstRef _rlp); + RLPStream& appendList(bytes const& _rlp) { return appendList(&_rlp); } + RLPStream& appendList(RLPStream const& _s) { return appendList(&_s.out()); } - /// Appends raw (pre-serialised) RLP data. Use with caution. - RLPStream& appendRaw(bytesConstRef _rlp, size_t _itemCount = 1); - RLPStream& appendRaw(bytes const& _rlp, size_t _itemCount = 1) { return appendRaw(&_rlp, _itemCount); } + /// Appends raw (pre-serialised) RLP data. Use with caution. + RLPStream& appendRaw(bytesConstRef _rlp, size_t _itemCount = 1); + RLPStream& appendRaw(bytes const& _rlp, size_t _itemCount = 1) { return appendRaw(&_rlp, _itemCount); } - /// Shift operators for appending data items. - template RLPStream& operator<<(T _data) { return append(_data); } + /// Shift operators for appending data items. + template RLPStream& operator<<(T _data) { return append(_data); } - /// Clear the output stream so far. - void clear() { m_out.clear(); m_listStack.clear(); } + /// Clear the output stream so far. + void clear() { m_out.clear(); m_listStack.clear(); } - /// Read the byte stream. - bytes const& out() const { if(!m_listStack.empty()) BOOST_THROW_EXCEPTION(RLPException() << errinfo_comment("listStack is not empty")); return m_out; } + /// Read the byte stream. + bytes const& out() const { if(!m_listStack.empty()) BOOST_THROW_EXCEPTION(RLPException() << errinfo_comment("listStack is not empty")); return m_out; } - /// Invalidate the object and steal the output byte stream. - bytes&& invalidate() { if(!m_listStack.empty()) BOOST_THROW_EXCEPTION(RLPException() << errinfo_comment("listStack is not empty")); return std::move(m_out); } + /// Invalidate the object and steal the output byte stream. + bytes&& invalidate() { if(!m_listStack.empty()) BOOST_THROW_EXCEPTION(RLPException() << errinfo_comment("listStack is not empty")); return std::move(m_out); } - /// Swap the contents of the output stream out for some other byte array. - void swapOut(bytes& _dest) { if(!m_listStack.empty()) BOOST_THROW_EXCEPTION(RLPException() << errinfo_comment("listStack is not empty")); swap(m_out, _dest); } + /// Swap the contents of the output stream out for some other byte array. + void swapOut(bytes& _dest) { if(!m_listStack.empty()) BOOST_THROW_EXCEPTION(RLPException() << errinfo_comment("listStack is not empty")); swap(m_out, _dest); } private: - void noteAppended(size_t _itemCount = 1); + void noteAppended(size_t _itemCount = 1); - /// Push the node-type byte (using @a _base) along with the item count @a _count. - /// @arg _count is number of characters for strings, data-bytes for ints, or items for lists. - void pushCount(size_t _count, byte _offset); + /// Push the node-type byte (using @a _base) along with the item count @a _count. + /// @arg _count is number of characters for strings, data-bytes for ints, or items for lists. + void pushCount(size_t _count, byte _offset); - /// Push an integer as a raw big-endian byte-stream. - template void pushInt(_T _i, size_t _br) - { - m_out.resize(m_out.size() + _br); - byte* b = &m_out.back(); - for (; _i; _i >>= 8) - *(b--) = (byte)_i; - } + /// Push an integer as a raw big-endian byte-stream. + template void pushInt(_T _i, size_t _br) + { + m_out.resize(m_out.size() + _br); + byte* b = &m_out.back(); + for (; _i; _i >>= 8) + *(b--) = (byte)_i; + } - /// Our output byte stream. - bytes m_out; + /// Our output byte stream. + bytes m_out; - std::vector> m_listStack; + std::vector> m_listStack; }; template void rlpListAux(RLPStream& _out, _T _t) { _out << _t; } @@ -470,9 +470,9 @@ template bytes rlp(_T _t) { return (RLPStream() << _t).out(); } inline bytes rlpList() { return RLPStream(0).out(); } template bytes rlpList(_Ts ... _ts) { - RLPStream out(sizeof ...(_Ts)); - rlpListAux(out, _ts...); - return out.out(); + RLPStream out(sizeof ...(_Ts)); + rlpListAux(out, _ts...); + return out.out(); } /// The empty string in RLP format. diff --git a/include/metaverse/consensus/libdevcore/SHA3.h b/include/metaverse/consensus/libdevcore/SHA3.h index 75bcc5f79..f40e24505 100644 --- a/include/metaverse/consensus/libdevcore/SHA3.h +++ b/include/metaverse/consensus/libdevcore/SHA3.h @@ -1,18 +1,18 @@ /* - This file is part of cpp-ethereum. + This file is part of cpp-ethereum. - cpp-ethereum is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. + cpp-ethereum is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. - cpp-ethereum is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. + cpp-ethereum is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. - You should have received a copy of the GNU General Public License - along with cpp-ethereum. If not, see . + You should have received a copy of the GNU General Public License + along with cpp-ethereum. If not, see . */ /** @file SHA3.h * @author Gav Wood diff --git a/include/metaverse/consensus/libdevcore/Terminal.h b/include/metaverse/consensus/libdevcore/Terminal.h index a697fcc55..9e74be765 100644 --- a/include/metaverse/consensus/libdevcore/Terminal.h +++ b/include/metaverse/consensus/libdevcore/Terminal.h @@ -11,68 +11,68 @@ namespace con #define EthReset "" // Text Reset - // Regular Colors -#define EthBlack "" // Black -#define EthCoal "" // Black -#define EthGray "" // White -#define EthWhite "" // White -#define EthMaroon "" // Red -#define EthRed "" // Red -#define EthGreen "" // Green -#define EthLime "" // Green -#define EthOrange "" // Yellow -#define EthYellow "" // Yellow -#define EthNavy "" // Blue -#define EthBlue "" // Blue -#define EthViolet "" // Purple -#define EthPurple "" // Purple -#define EthTeal "" // Cyan -#define EthCyan "" // Cyan - -#define EthBlackBold "" // Black -#define EthCoalBold "" // Black -#define EthGrayBold "" // White -#define EthWhiteBold "" // White -#define EthMaroonBold "" // Red -#define EthRedBold "" // Red -#define EthGreenBold "" // Green -#define EthLimeBold "" // Green -#define EthOrangeBold "" // Yellow -#define EthYellowBold "" // Yellow -#define EthNavyBold "" // Blue -#define EthBlueBold "" // Blue -#define EthVioletBold "" // Purple -#define EthPurpleBold "" // Purple -#define EthTealBold "" // Cyan -#define EthCyanBold "" // Cyan - - // Background -#define EthOnBlack "" // Black -#define EthOnCoal "" // Black -#define EthOnGray "" // White -#define EthOnWhite "" // White -#define EthOnMaroon "" // Red -#define EthOnRed "" // Red -#define EthOnGreen "" // Green -#define EthOnLime "" // Green -#define EthOnOrange "" // Yellow -#define EthOnYellow "" // Yellow -#define EthOnNavy "" // Blue -#define EthOnBlue "" // Blue -#define EthOnViolet "" // Purple -#define EthOnPurple "" // Purple -#define EthOnTeal "" // Cyan -#define EthOnCyan "" // Cyan - - // Underline -#define EthBlackUnder "" // Black -#define EthGrayUnder "" // White -#define EthMaroonUnder "" // Red -#define EthGreenUnder "" // Green -#define EthOrangeUnder "" // Yellow -#define EthNavyUnder "" // Blue -#define EthVioletUnder "" // Purple -#define EthTealUnder "" // Cyan + // Regular Colors +#define EthBlack "" // Black +#define EthCoal "" // Black +#define EthGray "" // White +#define EthWhite "" // White +#define EthMaroon "" // Red +#define EthRed "" // Red +#define EthGreen "" // Green +#define EthLime "" // Green +#define EthOrange "" // Yellow +#define EthYellow "" // Yellow +#define EthNavy "" // Blue +#define EthBlue "" // Blue +#define EthViolet "" // Purple +#define EthPurple "" // Purple +#define EthTeal "" // Cyan +#define EthCyan "" // Cyan + +#define EthBlackBold "" // Black +#define EthCoalBold "" // Black +#define EthGrayBold "" // White +#define EthWhiteBold "" // White +#define EthMaroonBold "" // Red +#define EthRedBold "" // Red +#define EthGreenBold "" // Green +#define EthLimeBold "" // Green +#define EthOrangeBold "" // Yellow +#define EthYellowBold "" // Yellow +#define EthNavyBold "" // Blue +#define EthBlueBold "" // Blue +#define EthVioletBold "" // Purple +#define EthPurpleBold "" // Purple +#define EthTealBold "" // Cyan +#define EthCyanBold "" // Cyan + + // Background +#define EthOnBlack "" // Black +#define EthOnCoal "" // Black +#define EthOnGray "" // White +#define EthOnWhite "" // White +#define EthOnMaroon "" // Red +#define EthOnRed "" // Red +#define EthOnGreen "" // Green +#define EthOnLime "" // Green +#define EthOnOrange "" // Yellow +#define EthOnYellow "" // Yellow +#define EthOnNavy "" // Blue +#define EthOnBlue "" // Blue +#define EthOnViolet "" // Purple +#define EthOnPurple "" // Purple +#define EthOnTeal "" // Cyan +#define EthOnCyan "" // Cyan + + // Underline +#define EthBlackUnder "" // Black +#define EthGrayUnder "" // White +#define EthMaroonUnder "" // Red +#define EthGreenUnder "" // Green +#define EthOrangeUnder "" // Yellow +#define EthNavyUnder "" // Blue +#define EthVioletUnder "" // Purple +#define EthTealUnder "" // Cyan #else diff --git a/include/metaverse/consensus/libdevcore/picosha2.h b/include/metaverse/consensus/libdevcore/picosha2.h index 44b6bee59..972401648 100644 --- a/include/metaverse/consensus/libdevcore/picosha2.h +++ b/include/metaverse/consensus/libdevcore/picosha2.h @@ -35,324 +35,324 @@ THE SOFTWARE. namespace picosha2 { -namespace detail +namespace detail { inline uint8_t mask_8bit(uint8_t x){ - return x&0xff; + return x&0xff; } inline uint32_t mask_32bit(uint32_t x){ - return x&0xffffffff; + return x&0xffffffff; } static const uint32_t add_constant[64] = { - 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, - 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5, - 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, - 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174, - 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, - 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da, - 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, - 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967, - 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, - 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, - 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, - 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070, - 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, - 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3, - 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, - 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2 + 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, + 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5, + 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, + 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174, + 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, + 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da, + 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, + 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967, + 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, + 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, + 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, + 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070, + 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, + 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3, + 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, + 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2 }; static const uint32_t initial_message_digest[8] = { - 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, - 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19 + 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, + 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19 }; inline uint32_t ch(uint32_t x, uint32_t y, uint32_t z){ - return (x&y)^((~x)&z); + return (x&y)^((~x)&z); } inline uint32_t maj(uint32_t x, uint32_t y, uint32_t z){ - return (x&y)^(x&z)^(y&z); + return (x&y)^(x&z)^(y&z); } inline uint32_t rotr(uint32_t x, std::size_t n){ - assert(n < 32); - return mask_32bit((x>>n)|(x<<(32-n))); + assert(n < 32); + return mask_32bit((x>>n)|(x<<(32-n))); } inline uint32_t bsig0(uint32_t x){ - return rotr(x, 2)^rotr(x, 13)^rotr(x, 22); + return rotr(x, 2)^rotr(x, 13)^rotr(x, 22); } inline uint32_t bsig1(uint32_t x){ - return rotr(x, 6)^rotr(x, 11)^rotr(x, 25); + return rotr(x, 6)^rotr(x, 11)^rotr(x, 25); } inline uint32_t shr(uint32_t x, std::size_t n){ - assert(n < 32); - return x >> n; + assert(n < 32); + return x >> n; } inline uint32_t ssig0(uint32_t x){ - return rotr(x, 7)^rotr(x, 18)^shr(x, 3); + return rotr(x, 7)^rotr(x, 18)^shr(x, 3); } inline uint32_t ssig1(uint32_t x){ - return rotr(x, 17)^rotr(x, 19)^shr(x, 10); + return rotr(x, 17)^rotr(x, 19)^shr(x, 10); } template void hash256_block(RaIter1 message_digest, RaIter2 first, RaIter2 last){ - (void)last; // FIXME: check this is valid - uint32_t w[64]; - std::fill(w, w+64, 0); - for(std::size_t i = 0; i < 16; ++i){ - w[i] = (static_cast(mask_8bit(*(first+i*4)))<<24) - |(static_cast(mask_8bit(*(first+i*4+1)))<<16) - |(static_cast(mask_8bit(*(first+i*4+2)))<<8) - |(static_cast(mask_8bit(*(first+i*4+3)))); - } - for(std::size_t i = 16; i < 64; ++i){ - w[i] = mask_32bit(ssig1(w[i-2])+w[i-7]+ssig0(w[i-15])+w[i-16]); - } - - uint32_t a = *message_digest; - uint32_t b = *(message_digest+1); - uint32_t c = *(message_digest+2); - uint32_t d = *(message_digest+3); - uint32_t e = *(message_digest+4); - uint32_t f = *(message_digest+5); - uint32_t g = *(message_digest+6); - uint32_t h = *(message_digest+7); - - for(std::size_t i = 0; i < 64; ++i){ - uint32_t temp1 = h+bsig1(e)+ch(e,f,g)+add_constant[i]+w[i]; - uint32_t temp2 = bsig0(a)+maj(a,b,c); - h = g; - g = f; - f = e; - e = mask_32bit(d+temp1); - d = c; - c = b; - b = a; - a = mask_32bit(temp1+temp2); - } - *message_digest += a; - *(message_digest+1) += b; - *(message_digest+2) += c; - *(message_digest+3) += d; - *(message_digest+4) += e; - *(message_digest+5) += f; - *(message_digest+6) += g; - *(message_digest+7) += h; - for(std::size_t i = 0; i < 8; ++i){ - *(message_digest+i) = mask_32bit(*(message_digest+i)); - } + (void)last; // FIXME: check this is valid + uint32_t w[64]; + std::fill(w, w+64, 0); + for(std::size_t i = 0; i < 16; ++i){ + w[i] = (static_cast(mask_8bit(*(first+i*4)))<<24) + |(static_cast(mask_8bit(*(first+i*4+1)))<<16) + |(static_cast(mask_8bit(*(first+i*4+2)))<<8) + |(static_cast(mask_8bit(*(first+i*4+3)))); + } + for(std::size_t i = 16; i < 64; ++i){ + w[i] = mask_32bit(ssig1(w[i-2])+w[i-7]+ssig0(w[i-15])+w[i-16]); + } + + uint32_t a = *message_digest; + uint32_t b = *(message_digest+1); + uint32_t c = *(message_digest+2); + uint32_t d = *(message_digest+3); + uint32_t e = *(message_digest+4); + uint32_t f = *(message_digest+5); + uint32_t g = *(message_digest+6); + uint32_t h = *(message_digest+7); + + for(std::size_t i = 0; i < 64; ++i){ + uint32_t temp1 = h+bsig1(e)+ch(e,f,g)+add_constant[i]+w[i]; + uint32_t temp2 = bsig0(a)+maj(a,b,c); + h = g; + g = f; + f = e; + e = mask_32bit(d+temp1); + d = c; + c = b; + b = a; + a = mask_32bit(temp1+temp2); + } + *message_digest += a; + *(message_digest+1) += b; + *(message_digest+2) += c; + *(message_digest+3) += d; + *(message_digest+4) += e; + *(message_digest+5) += f; + *(message_digest+6) += g; + *(message_digest+7) += h; + for(std::size_t i = 0; i < 8; ++i){ + *(message_digest+i) = mask_32bit(*(message_digest+i)); + } } }//namespace detail template void output_hex(InIter first, InIter last, std::ostream& os){ - os.setf(std::ios::hex, std::ios::basefield); - while(first != last){ - os.width(2); - os.fill('0'); - os << static_cast(*first); - ++first; - } - os.setf(std::ios::dec, std::ios::basefield); + os.setf(std::ios::hex, std::ios::basefield); + while(first != last){ + os.width(2); + os.fill('0'); + os << static_cast(*first); + ++first; + } + os.setf(std::ios::dec, std::ios::basefield); } template void bytes_to_hex_string(InIter first, InIter last, std::string& hex_str){ - std::ostringstream oss; - output_hex(first, last, oss); - hex_str.assign(oss.str()); + std::ostringstream oss; + output_hex(first, last, oss); + hex_str.assign(oss.str()); } template void bytes_to_hex_string(const InContainer& bytes, std::string& hex_str){ - bytes_to_hex_string(bytes.begin(), bytes.end(), hex_str); + bytes_to_hex_string(bytes.begin(), bytes.end(), hex_str); } template std::string bytes_to_hex_string(InIter first, InIter last){ - std::string hex_str; - bytes_to_hex_string(first, last, hex_str); - return hex_str; + std::string hex_str; + bytes_to_hex_string(first, last, hex_str); + return hex_str; } template std::string bytes_to_hex_string(const InContainer& bytes){ - std::string hex_str; - bytes_to_hex_string(bytes, hex_str); - return hex_str; + std::string hex_str; + bytes_to_hex_string(bytes, hex_str); + return hex_str; } class hash256_one_by_one { public: - hash256_one_by_one(){ - init(); - } - - void init(){ - buffer_.clear(); - std::fill(data_length_digits_, data_length_digits_+4, 0); - std::copy(detail::initial_message_digest, detail::initial_message_digest+8, h_); - } - - template - void process(RaIter first, RaIter last){ - add_to_data_length(std::distance(first, last)); - std::copy(first, last, std::back_inserter(buffer_)); - std::size_t i = 0; - for(;i+64 <= buffer_.size(); i+=64){ - detail::hash256_block(h_, buffer_.begin()+i, buffer_.begin()+i+64); - } - buffer_.erase(buffer_.begin(), buffer_.begin()+i); - } - - void finish(){ - uint8_t temp[64]; - std::fill(temp, temp+64, 0); - std::size_t remains = buffer_.size(); - std::copy(buffer_.begin(), buffer_.end(), temp); - temp[remains] = 0x80; - - if(remains > 55){ - std::fill(temp+remains+1, temp+64, 0); - detail::hash256_block(h_, temp, temp+64); - std::fill(temp, temp+64-4, 0); - } - else { - std::fill(temp+remains+1, temp+64-4, 0); - } - - write_data_bit_length(&(temp[56])); - detail::hash256_block(h_, temp, temp+64); - } - - template - void get_hash_bytes(OutIter first, OutIter last)const{ - for(const uint32_t* iter = h_; iter != h_+8; ++iter){ - for(std::size_t i = 0; i < 4 && first != last; ++i){ - *(first++) = detail::mask_8bit(static_cast((*iter >> (24-8*i)))); - } - } - } + hash256_one_by_one(){ + init(); + } + + void init(){ + buffer_.clear(); + std::fill(data_length_digits_, data_length_digits_+4, 0); + std::copy(detail::initial_message_digest, detail::initial_message_digest+8, h_); + } + + template + void process(RaIter first, RaIter last){ + add_to_data_length(std::distance(first, last)); + std::copy(first, last, std::back_inserter(buffer_)); + std::size_t i = 0; + for(;i+64 <= buffer_.size(); i+=64){ + detail::hash256_block(h_, buffer_.begin()+i, buffer_.begin()+i+64); + } + buffer_.erase(buffer_.begin(), buffer_.begin()+i); + } + + void finish(){ + uint8_t temp[64]; + std::fill(temp, temp+64, 0); + std::size_t remains = buffer_.size(); + std::copy(buffer_.begin(), buffer_.end(), temp); + temp[remains] = 0x80; + + if(remains > 55){ + std::fill(temp+remains+1, temp+64, 0); + detail::hash256_block(h_, temp, temp+64); + std::fill(temp, temp+64-4, 0); + } + else { + std::fill(temp+remains+1, temp+64-4, 0); + } + + write_data_bit_length(&(temp[56])); + detail::hash256_block(h_, temp, temp+64); + } + + template + void get_hash_bytes(OutIter first, OutIter last)const{ + for(const uint32_t* iter = h_; iter != h_+8; ++iter){ + for(std::size_t i = 0; i < 4 && first != last; ++i){ + *(first++) = detail::mask_8bit(static_cast((*iter >> (24-8*i)))); + } + } + } private: - void add_to_data_length(uint32_t n) { - uint32_t carry = 0; - data_length_digits_[0] += n; - for(std::size_t i = 0; i < 4; ++i) { - data_length_digits_[i] += carry; - if(data_length_digits_[i] >= 65536u) { - data_length_digits_[i] -= 65536u; - carry = 1; - } - else { - break; - } - } - } - void write_data_bit_length(uint8_t* begin) { - uint32_t data_bit_length_digits[4]; - std::copy( - data_length_digits_, data_length_digits_+4, - data_bit_length_digits - ); - - // convert byte length to bit length (multiply 8 or shift 3 times left) - uint32_t carry = 0; - for(std::size_t i = 0; i < 4; ++i) { - uint32_t before_val = data_bit_length_digits[i]; - data_bit_length_digits[i] <<= 3; - data_bit_length_digits[i] |= carry; - data_bit_length_digits[i] &= 65535u; - carry = (before_val >> (16-3)) & 65535u; - } - - // write data_bit_length - for(int i = 3; i >= 0; --i) { - (*begin++) = static_cast(data_bit_length_digits[i] >> 8); - (*begin++) = static_cast(data_bit_length_digits[i]); - } - } - std::vector buffer_; - uint32_t data_length_digits_[4]; //as 64bit integer (16bit x 4 integer) - uint32_t h_[8]; + void add_to_data_length(uint32_t n) { + uint32_t carry = 0; + data_length_digits_[0] += n; + for(std::size_t i = 0; i < 4; ++i) { + data_length_digits_[i] += carry; + if(data_length_digits_[i] >= 65536u) { + data_length_digits_[i] -= 65536u; + carry = 1; + } + else { + break; + } + } + } + void write_data_bit_length(uint8_t* begin) { + uint32_t data_bit_length_digits[4]; + std::copy( + data_length_digits_, data_length_digits_+4, + data_bit_length_digits + ); + + // convert byte length to bit length (multiply 8 or shift 3 times left) + uint32_t carry = 0; + for(std::size_t i = 0; i < 4; ++i) { + uint32_t before_val = data_bit_length_digits[i]; + data_bit_length_digits[i] <<= 3; + data_bit_length_digits[i] |= carry; + data_bit_length_digits[i] &= 65535u; + carry = (before_val >> (16-3)) & 65535u; + } + + // write data_bit_length + for(int i = 3; i >= 0; --i) { + (*begin++) = static_cast(data_bit_length_digits[i] >> 8); + (*begin++) = static_cast(data_bit_length_digits[i]); + } + } + std::vector buffer_; + uint32_t data_length_digits_[4]; //as 64bit integer (16bit x 4 integer) + uint32_t h_[8]; }; inline void get_hash_hex_string(const hash256_one_by_one& hasher, std::string& hex_str){ - uint8_t hash[32]; - hasher.get_hash_bytes(hash, hash+32); - return bytes_to_hex_string(hash, hash+32, hex_str); + uint8_t hash[32]; + hasher.get_hash_bytes(hash, hash+32); + return bytes_to_hex_string(hash, hash+32, hex_str); } inline std::string get_hash_hex_string(const hash256_one_by_one& hasher){ - std::string hex_str; - get_hash_hex_string(hasher, hex_str); - return hex_str; + std::string hex_str; + get_hash_hex_string(hasher, hex_str); + return hex_str; } template void hash256(RaIter first, RaIter last, OutIter first2, OutIter last2){ - hash256_one_by_one hasher; - //hasher.init(); - hasher.process(first, last); - hasher.finish(); - hasher.get_hash_bytes(first2, last2); + hash256_one_by_one hasher; + //hasher.init(); + hasher.process(first, last); + hasher.finish(); + hasher.get_hash_bytes(first2, last2); } template void hash256(RaIter first, RaIter last, OutContainer& dst){ - hash256(first, last, dst.begin(), dst.end()); + hash256(first, last, dst.begin(), dst.end()); } template void hash256(const RaContainer& src, OutIter first, OutIter last){ - hash256(src.begin(), src.end(), first, last); + hash256(src.begin(), src.end(), first, last); } template void hash256(const RaContainer& src, OutContainer& dst){ - hash256(src.begin(), src.end(), dst.begin(), dst.end()); + hash256(src.begin(), src.end(), dst.begin(), dst.end()); } template void hash256_hex_string(RaIter first, RaIter last, std::string& hex_str){ - uint8_t hashed[32]; - hash256(first, last, hashed, hashed+32); - std::ostringstream oss; - output_hex(hashed, hashed+32, oss); - hex_str.assign(oss.str()); + uint8_t hashed[32]; + hash256(first, last, hashed, hashed+32); + std::ostringstream oss; + output_hex(hashed, hashed+32, oss); + hex_str.assign(oss.str()); } template std::string hash256_hex_string(RaIter first, RaIter last){ - std::string hex_str; - hash256_hex_string(first, last, hex_str); - return hex_str; + std::string hex_str; + hash256_hex_string(first, last, hex_str); + return hex_str; } inline void hash256_hex_string(const std::string& src, std::string& hex_str){ - hash256_hex_string(src.begin(), src.end(), hex_str); + hash256_hex_string(src.begin(), src.end(), hex_str); } template void hash256_hex_string(const RaContainer& src, std::string& hex_str){ - hash256_hex_string(src.begin(), src.end(), hex_str); + hash256_hex_string(src.begin(), src.end(), hex_str); } template std::string hash256_hex_string(const RaContainer& src){ - return hash256_hex_string(src.begin(), src.end()); + return hash256_hex_string(src.begin(), src.end()); } }//namespace picosha2 diff --git a/include/metaverse/consensus/libdevcore/vector_ref.h b/include/metaverse/consensus/libdevcore/vector_ref.h index 0c338fc15..7672aeab0 100644 --- a/include/metaverse/consensus/libdevcore/vector_ref.h +++ b/include/metaverse/consensus/libdevcore/vector_ref.h @@ -20,96 +20,96 @@ template class vector_ref { public: - using value_type = _T; - using element_type = _T; - using mutable_value_type = typename std::conditional::value, typename std::remove_const<_T>::type, _T>::type; - - static_assert(std::is_pod::value, "vector_ref can only be used with PODs due to its low-level treatment of data."); - - vector_ref(): m_data(nullptr), m_count(0) {} - /// Creates a new vector_ref to point to @a _count elements starting at @a _data. - vector_ref(_T* _data, size_t _count): m_data(_data), m_count(_count) {} - /// Creates a new vector_ref pointing to the data part of a string (given as pointer). - vector_ref(typename std::conditional::value, std::string const*, std::string*>::type _data): m_data(reinterpret_cast<_T*>(_data->data())), m_count(_data->size() / sizeof(_T)) {} - /// Creates a new vector_ref pointing to the data part of a vector (given as pointer). - vector_ref(typename std::conditional::value, std::vector::type> const*, std::vector<_T>*>::type _data): m_data(_data->data()), m_count(_data->size()) {} - /// Creates a new vector_ref pointing to the data part of a string (given as reference). - vector_ref(typename std::conditional::value, std::string const&, std::string&>::type _data): m_data(reinterpret_cast<_T*>(_data.data())), m_count(_data.size() / sizeof(_T)) {} + using value_type = _T; + using element_type = _T; + using mutable_value_type = typename std::conditional::value, typename std::remove_const<_T>::type, _T>::type; + + static_assert(std::is_pod::value, "vector_ref can only be used with PODs due to its low-level treatment of data."); + + vector_ref(): m_data(nullptr), m_count(0) {} + /// Creates a new vector_ref to point to @a _count elements starting at @a _data. + vector_ref(_T* _data, size_t _count): m_data(_data), m_count(_count) {} + /// Creates a new vector_ref pointing to the data part of a string (given as pointer). + vector_ref(typename std::conditional::value, std::string const*, std::string*>::type _data): m_data(reinterpret_cast<_T*>(_data->data())), m_count(_data->size() / sizeof(_T)) {} + /// Creates a new vector_ref pointing to the data part of a vector (given as pointer). + vector_ref(typename std::conditional::value, std::vector::type> const*, std::vector<_T>*>::type _data): m_data(_data->data()), m_count(_data->size()) {} + /// Creates a new vector_ref pointing to the data part of a string (given as reference). + vector_ref(typename std::conditional::value, std::string const&, std::string&>::type _data): m_data(reinterpret_cast<_T*>(_data.data())), m_count(_data.size() / sizeof(_T)) {} #if DEV_LDB - vector_ref(ldb::Slice const& _s): m_data(reinterpret_cast<_T*>(_s.data())), m_count(_s.size() / sizeof(_T)) {} + vector_ref(ldb::Slice const& _s): m_data(reinterpret_cast<_T*>(_s.data())), m_count(_s.size() / sizeof(_T)) {} #endif - explicit operator bool() const { return m_data && m_count; } - - bool contentsEqual(std::vector const& _c) const { if (!m_data || m_count == 0) return _c.empty(); else return _c.size() == m_count && !memcmp(_c.data(), m_data, m_count * sizeof(_T)); } - std::vector toVector() const { return std::vector(m_data, m_data + m_count); } - std::vector toBytes() const { return std::vector(reinterpret_cast(m_data), reinterpret_cast(m_data) + m_count * sizeof(_T)); } - std::string toString() const { return std::string((char const*)m_data, ((char const*)m_data) + m_count * sizeof(_T)); } - - template explicit operator vector_ref<_T2>() const { assert(m_count * sizeof(_T) / sizeof(_T2) * sizeof(_T2) / sizeof(_T) == m_count); return vector_ref<_T2>(reinterpret_cast<_T2*>(m_data), m_count * sizeof(_T) / sizeof(_T2)); } - operator vector_ref<_T const>() const { return vector_ref<_T const>(m_data, m_count); } - - _T* data() const { return m_data; } - /// @returns the number of elements referenced (not necessarily number of bytes). - size_t count() const { return m_count; } - /// @returns the number of elements referenced (not necessarily number of bytes). - size_t size() const { return m_count; } - bool empty() const { return !m_count; } - /// @returns a new vector_ref pointing at the next chunk of @a size() elements. - vector_ref<_T> next() const { if (!m_data) return *this; else return vector_ref<_T>(m_data + m_count, m_count); } - /// @returns a new vector_ref which is a shifted and shortened view of the original data. - /// If this goes out of bounds in any way, returns an empty vector_ref. - /// If @a _count is ~size_t(0), extends the view to the end of the data. - vector_ref<_T> cropped(size_t _begin, size_t _count) const { if (m_data && _begin <= m_count && _count <= m_count && _begin + _count <= m_count) return vector_ref<_T>(m_data + _begin, _count == ~size_t(0) ? m_count - _begin : _count); else return vector_ref<_T>(); } - /// @returns a new vector_ref which is a shifted view of the original data (not going beyond it). - vector_ref<_T> cropped(size_t _begin) const { if (m_data && _begin <= m_count) return vector_ref<_T>(m_data + _begin, m_count - _begin); else return vector_ref<_T>(); } - void retarget(_T* _d, size_t _s) { m_data = _d; m_count = _s; } - void retarget(std::vector<_T> const& _t) { m_data = _t.data(); m_count = _t.size(); } - template bool overlapsWith(vector_ref _t) const { void const* f1 = data(); void const* t1 = data() + size(); void const* f2 = _t.data(); void const* t2 = _t.data() + _t.size(); return f1 < t2 && t1 > f2; } - /// Copies the contents of this vector_ref to the contents of @a _t, up to the max size of @a _t. - void copyTo(vector_ref::type> _t) const { if (overlapsWith(_t)) memmove(_t.data(), m_data, std::min(_t.size(), m_count) * sizeof(_T)); else memcpy(_t.data(), m_data, std::min(_t.size(), m_count) * sizeof(_T)); } - /// Copies the contents of this vector_ref to the contents of @a _t, and zeros further trailing elements in @a _t. - void populate(vector_ref::type> _t) const { copyTo(_t); memset(_t.data() + m_count, 0, std::max(_t.size(), m_count) - m_count); } - /// Securely overwrite the memory. - /// @note adapted from OpenSSL's implementation. - void cleanse() - { - static unsigned char s_cleanseCounter = 0; - uint8_t* p = (uint8_t*)begin(); - size_t const len = (uint8_t*)end() - p; - size_t loop = len; - size_t count = s_cleanseCounter; - while (loop--) - { - *(p++) = (uint8_t)count; - count += (17 + ((size_t)p & 0xf)); - } - p = (uint8_t*)memchr((uint8_t*)begin(), (uint8_t)count, len); - if (p) - count += (63 + (size_t)p); - s_cleanseCounter = (uint8_t)count; - memset((uint8_t*)begin(), 0, len); - } - - _T* begin() { return m_data; } - _T* end() { return m_data + m_count; } - _T const* begin() const { return m_data; } - _T const* end() const { return m_data + m_count; } - - _T& operator[](size_t _i) { assert(m_data); assert(_i < m_count); return m_data[_i]; } - _T const& operator[](size_t _i) const { assert(m_data); assert(_i < m_count); return m_data[_i]; } - - bool operator==(vector_ref<_T> const& _cmp) const { return m_data == _cmp.m_data && m_count == _cmp.m_count; } - bool operator!=(vector_ref<_T> const& _cmp) const { return !operator==(_cmp); } + explicit operator bool() const { return m_data && m_count; } + + bool contentsEqual(std::vector const& _c) const { if (!m_data || m_count == 0) return _c.empty(); else return _c.size() == m_count && !memcmp(_c.data(), m_data, m_count * sizeof(_T)); } + std::vector toVector() const { return std::vector(m_data, m_data + m_count); } + std::vector toBytes() const { return std::vector(reinterpret_cast(m_data), reinterpret_cast(m_data) + m_count * sizeof(_T)); } + std::string toString() const { return std::string((char const*)m_data, ((char const*)m_data) + m_count * sizeof(_T)); } + + template explicit operator vector_ref<_T2>() const { assert(m_count * sizeof(_T) / sizeof(_T2) * sizeof(_T2) / sizeof(_T) == m_count); return vector_ref<_T2>(reinterpret_cast<_T2*>(m_data), m_count * sizeof(_T) / sizeof(_T2)); } + operator vector_ref<_T const>() const { return vector_ref<_T const>(m_data, m_count); } + + _T* data() const { return m_data; } + /// @returns the number of elements referenced (not necessarily number of bytes). + size_t count() const { return m_count; } + /// @returns the number of elements referenced (not necessarily number of bytes). + size_t size() const { return m_count; } + bool empty() const { return !m_count; } + /// @returns a new vector_ref pointing at the next chunk of @a size() elements. + vector_ref<_T> next() const { if (!m_data) return *this; else return vector_ref<_T>(m_data + m_count, m_count); } + /// @returns a new vector_ref which is a shifted and shortened view of the original data. + /// If this goes out of bounds in any way, returns an empty vector_ref. + /// If @a _count is ~size_t(0), extends the view to the end of the data. + vector_ref<_T> cropped(size_t _begin, size_t _count) const { if (m_data && _begin <= m_count && _count <= m_count && _begin + _count <= m_count) return vector_ref<_T>(m_data + _begin, _count == ~size_t(0) ? m_count - _begin : _count); else return vector_ref<_T>(); } + /// @returns a new vector_ref which is a shifted view of the original data (not going beyond it). + vector_ref<_T> cropped(size_t _begin) const { if (m_data && _begin <= m_count) return vector_ref<_T>(m_data + _begin, m_count - _begin); else return vector_ref<_T>(); } + void retarget(_T* _d, size_t _s) { m_data = _d; m_count = _s; } + void retarget(std::vector<_T> const& _t) { m_data = _t.data(); m_count = _t.size(); } + template bool overlapsWith(vector_ref _t) const { void const* f1 = data(); void const* t1 = data() + size(); void const* f2 = _t.data(); void const* t2 = _t.data() + _t.size(); return f1 < t2 && t1 > f2; } + /// Copies the contents of this vector_ref to the contents of @a _t, up to the max size of @a _t. + void copyTo(vector_ref::type> _t) const { if (overlapsWith(_t)) memmove(_t.data(), m_data, std::min(_t.size(), m_count) * sizeof(_T)); else memcpy(_t.data(), m_data, std::min(_t.size(), m_count) * sizeof(_T)); } + /// Copies the contents of this vector_ref to the contents of @a _t, and zeros further trailing elements in @a _t. + void populate(vector_ref::type> _t) const { copyTo(_t); memset(_t.data() + m_count, 0, std::max(_t.size(), m_count) - m_count); } + /// Securely overwrite the memory. + /// @note adapted from OpenSSL's implementation. + void cleanse() + { + static unsigned char s_cleanseCounter = 0; + uint8_t* p = (uint8_t*)begin(); + size_t const len = (uint8_t*)end() - p; + size_t loop = len; + size_t count = s_cleanseCounter; + while (loop--) + { + *(p++) = (uint8_t)count; + count += (17 + ((size_t)p & 0xf)); + } + p = (uint8_t*)memchr((uint8_t*)begin(), (uint8_t)count, len); + if (p) + count += (63 + (size_t)p); + s_cleanseCounter = (uint8_t)count; + memset((uint8_t*)begin(), 0, len); + } + + _T* begin() { return m_data; } + _T* end() { return m_data + m_count; } + _T const* begin() const { return m_data; } + _T const* end() const { return m_data + m_count; } + + _T& operator[](size_t _i) { assert(m_data); assert(_i < m_count); return m_data[_i]; } + _T const& operator[](size_t _i) const { assert(m_data); assert(_i < m_count); return m_data[_i]; } + + bool operator==(vector_ref<_T> const& _cmp) const { return m_data == _cmp.m_data && m_count == _cmp.m_count; } + bool operator!=(vector_ref<_T> const& _cmp) const { return !operator==(_cmp); } #if DEV_LDB - operator ldb::Slice() const { return ldb::Slice((char const*)m_data, m_count * sizeof(_T)); } + operator ldb::Slice() const { return ldb::Slice((char const*)m_data, m_count * sizeof(_T)); } #endif - void reset() { m_data = nullptr; m_count = 0; } + void reset() { m_data = nullptr; m_count = 0; } private: - _T* m_data; - size_t m_count; + _T* m_data; + size_t m_count; }; template vector_ref<_T const> ref(_T const& _t) { return vector_ref<_T const>(&_t, 1); } diff --git a/include/metaverse/consensus/libethash/data_sizes.h b/include/metaverse/consensus/libethash/data_sizes.h index 83cc30bcb..297216c7c 100644 --- a/include/metaverse/consensus/libethash/data_sizes.h +++ b/include/metaverse/consensus/libethash/data_sizes.h @@ -49,416 +49,416 @@ extern "C" { static const uint64_t dag_sizes[2048] = { - 1073739904U, 1082130304U, 1090514816U, 1098906752U, 1107293056U, - 1115684224U, 1124070016U, 1132461952U, 1140849536U, 1149232768U, - 1157627776U, 1166013824U, 1174404736U, 1182786944U, 1191180416U, - 1199568512U, 1207958912U, 1216345216U, 1224732032U, 1233124736U, - 1241513344U, 1249902464U, 1258290304U, 1266673792U, 1275067264U, - 1283453312U, 1291844992U, 1300234112U, 1308619904U, 1317010048U, - 1325397376U, 1333787776U, 1342176128U, 1350561664U, 1358954368U, - 1367339392U, 1375731584U, 1384118144U, 1392507008U, 1400897408U, - 1409284736U, 1417673344U, 1426062464U, 1434451072U, 1442839168U, - 1451229056U, 1459615616U, 1468006016U, 1476394112U, 1484782976U, - 1493171584U, 1501559168U, 1509948032U, 1518337664U, 1526726528U, - 1535114624U, 1543503488U, 1551892096U, 1560278656U, 1568669056U, - 1577056384U, 1585446272U, 1593831296U, 1602219392U, 1610610304U, - 1619000192U, 1627386752U, 1635773824U, 1644164224U, 1652555648U, - 1660943488U, 1669332608U, 1677721216U, 1686109312U, 1694497664U, - 1702886272U, 1711274624U, 1719661184U, 1728047744U, 1736434816U, - 1744829056U, 1753218944U, 1761606272U, 1769995904U, 1778382464U, - 1786772864U, 1795157888U, 1803550592U, 1811937664U, 1820327552U, - 1828711552U, 1837102976U, 1845488768U, 1853879936U, 1862269312U, - 1870656896U, 1879048064U, 1887431552U, 1895825024U, 1904212096U, - 1912601216U, 1920988544U, 1929379456U, 1937765504U, 1946156672U, - 1954543232U, 1962932096U, 1971321728U, 1979707264U, 1988093056U, - 1996487552U, 2004874624U, 2013262208U, 2021653888U, 2030039936U, - 2038430848U, 2046819968U, 2055208576U, 2063596672U, 2071981952U, - 2080373632U, 2088762752U, 2097149056U, 2105539712U, 2113928576U, - 2122315136U, 2130700672U, 2139092608U, 2147483264U, 2155872128U, - 2164257664U, 2172642176U, 2181035392U, 2189426048U, 2197814912U, - 2206203008U, 2214587264U, 2222979712U, 2231367808U, 2239758208U, - 2248145024U, 2256527744U, 2264922752U, 2273312128U, 2281701248U, - 2290086272U, 2298476672U, 2306867072U, 2315251072U, 2323639168U, - 2332032128U, 2340420224U, 2348808064U, 2357196416U, 2365580416U, - 2373966976U, 2382363008U, 2390748544U, 2399139968U, 2407530368U, - 2415918976U, 2424307328U, 2432695424U, 2441084288U, 2449472384U, - 2457861248U, 2466247808U, 2474637184U, 2483026816U, 2491414144U, - 2499803776U, 2508191872U, 2516582272U, 2524970368U, 2533359232U, - 2541743488U, 2550134144U, 2558525056U, 2566913408U, 2575301504U, - 2583686528U, 2592073856U, 2600467328U, 2608856192U, 2617240448U, - 2625631616U, 2634022016U, 2642407552U, 2650796416U, 2659188352U, - 2667574912U, 2675965312U, 2684352896U, 2692738688U, 2701130624U, - 2709518464U, 2717907328U, 2726293376U, 2734685056U, 2743073152U, - 2751462016U, 2759851648U, 2768232832U, 2776625536U, 2785017728U, - 2793401984U, 2801794432U, 2810182016U, 2818571648U, 2826959488U, - 2835349376U, 2843734144U, 2852121472U, 2860514432U, 2868900992U, - 2877286784U, 2885676928U, 2894069632U, 2902451584U, 2910843008U, - 2919234688U, 2927622784U, 2936011648U, 2944400768U, 2952789376U, - 2961177728U, 2969565568U, 2977951616U, 2986338944U, 2994731392U, - 3003120256U, 3011508352U, 3019895936U, 3028287104U, 3036675968U, - 3045063808U, 3053452928U, 3061837696U, 3070228352U, 3078615424U, - 3087003776U, 3095394944U, 3103782272U, 3112173184U, 3120562048U, - 3128944768U, 3137339264U, 3145725056U, 3154109312U, 3162505088U, - 3170893184U, 3179280256U, 3187669376U, 3196056704U, 3204445568U, - 3212836736U, 3221224064U, 3229612928U, 3238002304U, 3246391168U, - 3254778496U, 3263165824U, 3271556224U, 3279944576U, 3288332416U, - 3296719232U, 3305110912U, 3313500032U, 3321887104U, 3330273152U, - 3338658944U, 3347053184U, 3355440512U, 3363827072U, 3372220288U, - 3380608384U, 3388997504U, 3397384576U, 3405774208U, 3414163072U, - 3422551936U, 3430937984U, 3439328384U, 3447714176U, 3456104576U, - 3464493952U, 3472883584U, 3481268864U, 3489655168U, 3498048896U, - 3506434432U, 3514826368U, 3523213952U, 3531603584U, 3539987072U, - 3548380288U, 3556763264U, 3565157248U, 3573545344U, 3581934464U, - 3590324096U, 3598712704U, 3607098752U, 3615488384U, 3623877248U, - 3632265856U, 3640646528U, 3649043584U, 3657430144U, 3665821568U, - 3674207872U, 3682597504U, 3690984832U, 3699367808U, 3707764352U, - 3716152448U, 3724541056U, 3732925568U, 3741318016U, 3749706368U, - 3758091136U, 3766481536U, 3774872704U, 3783260032U, 3791650432U, - 3800036224U, 3808427648U, 3816815488U, 3825204608U, 3833592704U, - 3841981568U, 3850370432U, 3858755968U, 3867147904U, 3875536256U, - 3883920512U, 3892313728U, 3900702592U, 3909087872U, 3917478784U, - 3925868416U, 3934256512U, 3942645376U, 3951032192U, 3959422336U, - 3967809152U, 3976200064U, 3984588416U, 3992974976U, 4001363584U, - 4009751168U, 4018141312U, 4026530432U, 4034911616U, 4043308928U, - 4051695488U, 4060084352U, 4068472448U, 4076862848U, 4085249408U, - 4093640576U, 4102028416U, 4110413696U, 4118805632U, 4127194496U, - 4135583104U, 4143971968U, 4152360832U, 4160746112U, 4169135744U, - 4177525888U, 4185912704U, 4194303616U, 4202691968U, 4211076736U, - 4219463552U, 4227855488U, 4236246656U, 4244633728U, 4253022848U, - 4261412224U, 4269799808U, 4278184832U, 4286578048U, 4294962304U, - 4303349632U, 4311743104U, 4320130432U, 4328521088U, 4336909184U, - 4345295488U, 4353687424U, 4362073472U, 4370458496U, 4378852736U, - 4387238528U, 4395630208U, 4404019072U, 4412407424U, 4420790656U, - 4429182848U, 4437571456U, 4445962112U, 4454344064U, 4462738048U, - 4471119232U, 4479516544U, 4487904128U, 4496289664U, 4504682368U, - 4513068416U, 4521459584U, 4529846144U, 4538232704U, 4546619776U, - 4555010176U, 4563402112U, 4571790208U, 4580174464U, 4588567936U, - 4596957056U, 4605344896U, 4613734016U, 4622119808U, 4630511488U, - 4638898816U, 4647287936U, 4655675264U, 4664065664U, 4672451968U, - 4680842624U, 4689231488U, 4697620352U, 4706007424U, 4714397056U, - 4722786176U, 4731173248U, 4739562368U, 4747951744U, 4756340608U, - 4764727936U, 4773114496U, 4781504384U, 4789894784U, 4798283648U, - 4806667648U, 4815059584U, 4823449472U, 4831835776U, 4840226176U, - 4848612224U, 4857003392U, 4865391488U, 4873780096U, 4882169728U, - 4890557312U, 4898946944U, 4907333248U, 4915722368U, 4924110976U, - 4932499328U, 4940889728U, 4949276032U, 4957666432U, 4966054784U, - 4974438016U, 4982831488U, 4991221376U, 4999607168U, 5007998848U, - 5016386432U, 5024763776U, 5033164672U, 5041544576U, 5049941888U, - 5058329728U, 5066717056U, 5075107456U, 5083494272U, 5091883904U, - 5100273536U, 5108662144U, 5117048192U, 5125436032U, 5133827456U, - 5142215296U, 5150605184U, 5158993024U, 5167382144U, 5175769472U, - 5184157568U, 5192543872U, 5200936064U, 5209324928U, 5217711232U, - 5226102656U, 5234490496U, 5242877312U, 5251263872U, 5259654016U, - 5268040832U, 5276434304U, 5284819328U, 5293209728U, 5301598592U, - 5309986688U, 5318374784U, 5326764416U, 5335151488U, 5343542144U, - 5351929472U, 5360319872U, 5368706944U, 5377096576U, 5385484928U, - 5393871232U, 5402263424U, 5410650496U, 5419040384U, 5427426944U, - 5435816576U, 5444205952U, 5452594816U, 5460981376U, 5469367936U, - 5477760896U, 5486148736U, 5494536832U, 5502925952U, 5511315328U, - 5519703424U, 5528089984U, 5536481152U, 5544869504U, 5553256064U, - 5561645696U, 5570032768U, 5578423936U, 5586811264U, 5595193216U, - 5603585408U, 5611972736U, 5620366208U, 5628750464U, 5637143936U, - 5645528192U, 5653921408U, 5662310272U, 5670694784U, 5679082624U, - 5687474048U, 5695864448U, 5704251008U, 5712641408U, 5721030272U, - 5729416832U, 5737806208U, 5746194304U, 5754583936U, 5762969984U, - 5771358592U, 5779748224U, 5788137856U, 5796527488U, 5804911232U, - 5813300608U, 5821692544U, 5830082176U, 5838468992U, 5846855552U, - 5855247488U, 5863636096U, 5872024448U, 5880411008U, 5888799872U, - 5897186432U, 5905576832U, 5913966976U, 5922352768U, 5930744704U, - 5939132288U, 5947522432U, 5955911296U, 5964299392U, 5972688256U, - 5981074304U, 5989465472U, 5997851008U, 6006241408U, 6014627968U, - 6023015552U, 6031408256U, 6039796096U, 6048185216U, 6056574848U, - 6064963456U, 6073351808U, 6081736064U, 6090128768U, 6098517632U, - 6106906496U, 6115289216U, 6123680896U, 6132070016U, 6140459648U, - 6148849024U, 6157237376U, 6165624704U, 6174009728U, 6182403712U, - 6190792064U, 6199176064U, 6207569792U, 6215952256U, 6224345216U, - 6232732544U, 6241124224U, 6249510272U, 6257899136U, 6266287744U, - 6274676864U, 6283065728U, 6291454336U, 6299843456U, 6308232064U, - 6316620928U, 6325006208U, 6333395584U, 6341784704U, 6350174848U, - 6358562176U, 6366951296U, 6375337856U, 6383729536U, 6392119168U, - 6400504192U, 6408895616U, 6417283456U, 6425673344U, 6434059136U, - 6442444672U, 6450837376U, 6459223424U, 6467613056U, 6476004224U, - 6484393088U, 6492781952U, 6501170048U, 6509555072U, 6517947008U, - 6526336384U, 6534725504U, 6543112832U, 6551500672U, 6559888768U, - 6568278656U, 6576662912U, 6585055616U, 6593443456U, 6601834112U, - 6610219648U, 6618610304U, 6626999168U, 6635385472U, 6643777408U, - 6652164224U, 6660552832U, 6668941952U, 6677330048U, 6685719424U, - 6694107776U, 6702493568U, 6710882176U, 6719274112U, 6727662976U, - 6736052096U, 6744437632U, 6752825984U, 6761213824U, 6769604224U, - 6777993856U, 6786383488U, 6794770816U, 6803158144U, 6811549312U, - 6819937664U, 6828326528U, 6836706176U, 6845101696U, 6853491328U, - 6861880448U, 6870269312U, 6878655104U, 6887046272U, 6895433344U, - 6903822208U, 6912212864U, 6920596864U, 6928988288U, 6937377152U, - 6945764992U, 6954149248U, 6962544256U, 6970928768U, 6979317376U, - 6987709312U, 6996093824U, 7004487296U, 7012875392U, 7021258624U, - 7029652352U, 7038038912U, 7046427776U, 7054818944U, 7063207808U, - 7071595136U, 7079980928U, 7088372608U, 7096759424U, 7105149824U, - 7113536896U, 7121928064U, 7130315392U, 7138699648U, 7147092352U, - 7155479168U, 7163865728U, 7172249984U, 7180648064U, 7189036672U, - 7197424768U, 7205810816U, 7214196608U, 7222589824U, 7230975104U, - 7239367552U, 7247755904U, 7256145536U, 7264533376U, 7272921472U, - 7281308032U, 7289694848U, 7298088832U, 7306471808U, 7314864512U, - 7323253888U, 7331643008U, 7340029568U, 7348419712U, 7356808832U, - 7365196672U, 7373585792U, 7381973888U, 7390362752U, 7398750592U, - 7407138944U, 7415528576U, 7423915648U, 7432302208U, 7440690304U, - 7449080192U, 7457472128U, 7465860992U, 7474249088U, 7482635648U, - 7491023744U, 7499412608U, 7507803008U, 7516192384U, 7524579968U, - 7532967296U, 7541358464U, 7549745792U, 7558134656U, 7566524032U, - 7574912896U, 7583300992U, 7591690112U, 7600075136U, 7608466816U, - 7616854912U, 7625244544U, 7633629824U, 7642020992U, 7650410368U, - 7658794112U, 7667187328U, 7675574912U, 7683961984U, 7692349568U, - 7700739712U, 7709130368U, 7717519232U, 7725905536U, 7734295424U, - 7742683264U, 7751069056U, 7759457408U, 7767849088U, 7776238208U, - 7784626816U, 7793014912U, 7801405312U, 7809792128U, 7818179968U, - 7826571136U, 7834957184U, 7843347328U, 7851732352U, 7860124544U, - 7868512384U, 7876902016U, 7885287808U, 7893679744U, 7902067072U, - 7910455936U, 7918844288U, 7927230848U, 7935622784U, 7944009344U, - 7952400256U, 7960786048U, 7969176704U, 7977565312U, 7985953408U, - 7994339968U, 8002730368U, 8011119488U, 8019508096U, 8027896192U, - 8036285056U, 8044674688U, 8053062272U, 8061448832U, 8069838464U, - 8078227328U, 8086616704U, 8095006592U, 8103393664U, 8111783552U, - 8120171392U, 8128560256U, 8136949376U, 8145336704U, 8153726848U, - 8162114944U, 8170503296U, 8178891904U, 8187280768U, 8195669632U, - 8204058496U, 8212444544U, 8220834176U, 8229222272U, 8237612672U, - 8246000768U, 8254389376U, 8262775168U, 8271167104U, 8279553664U, - 8287944064U, 8296333184U, 8304715136U, 8313108352U, 8321497984U, - 8329885568U, 8338274432U, 8346663296U, 8355052928U, 8363441536U, - 8371828352U, 8380217984U, 8388606592U, 8396996224U, 8405384576U, - 8413772672U, 8422161536U, 8430549376U, 8438939008U, 8447326592U, - 8455715456U, 8464104832U, 8472492928U, 8480882048U, 8489270656U, - 8497659776U, 8506045312U, 8514434944U, 8522823808U, 8531208832U, - 8539602304U, 8547990656U, 8556378752U, 8564768384U, 8573154176U, - 8581542784U, 8589933952U, 8598322816U, 8606705024U, 8615099264U, - 8623487872U, 8631876992U, 8640264064U, 8648653952U, 8657040256U, - 8665430656U, 8673820544U, 8682209152U, 8690592128U, 8698977152U, - 8707374464U, 8715763328U, 8724151424U, 8732540032U, 8740928384U, - 8749315712U, 8757704576U, 8766089344U, 8774480768U, 8782871936U, - 8791260032U, 8799645824U, 8808034432U, 8816426368U, 8824812928U, - 8833199488U, 8841591424U, 8849976448U, 8858366336U, 8866757248U, - 8875147136U, 8883532928U, 8891923328U, 8900306816U, 8908700288U, - 8917088384U, 8925478784U, 8933867392U, 8942250368U, 8950644608U, - 8959032704U, 8967420544U, 8975809664U, 8984197504U, 8992584064U, - 9000976256U, 9009362048U, 9017752448U, 9026141312U, 9034530688U, - 9042917504U, 9051307904U, 9059694208U, 9068084864U, 9076471424U, - 9084861824U, 9093250688U, 9101638528U, 9110027648U, 9118416512U, - 9126803584U, 9135188096U, 9143581312U, 9151969664U, 9160356224U, - 9168747136U, 9177134464U, 9185525632U, 9193910144U, 9202302848U, - 9210690688U, 9219079552U, 9227465344U, 9235854464U, 9244244864U, - 9252633472U, 9261021824U, 9269411456U, 9277799296U, 9286188928U, - 9294574208U, 9302965888U, 9311351936U, 9319740032U, 9328131968U, - 9336516736U, 9344907392U, 9353296768U, 9361685888U, 9370074752U, - 9378463616U, 9386849408U, 9395239808U, 9403629184U, 9412016512U, - 9420405376U, 9428795008U, 9437181568U, 9445570688U, 9453960832U, - 9462346624U, 9470738048U, 9479121536U, 9487515008U, 9495903616U, - 9504289664U, 9512678528U, 9521067904U, 9529456256U, 9537843584U, - 9546233728U, 9554621312U, 9563011456U, 9571398784U, 9579788672U, - 9588178304U, 9596567168U, 9604954496U, 9613343104U, 9621732992U, - 9630121856U, 9638508416U, 9646898816U, 9655283584U, 9663675776U, - 9672061312U, 9680449664U, 9688840064U, 9697230464U, 9705617536U, - 9714003584U, 9722393984U, 9730772608U, 9739172224U, 9747561088U, - 9755945344U, 9764338816U, 9772726144U, 9781116544U, 9789503872U, - 9797892992U, 9806282624U, 9814670464U, 9823056512U, 9831439232U, - 9839833984U, 9848224384U, 9856613504U, 9865000576U, 9873391232U, - 9881772416U, 9890162816U, 9898556288U, 9906940544U, 9915333248U, - 9923721088U, 9932108672U, 9940496512U, 9948888448U, 9957276544U, - 9965666176U, 9974048384U, 9982441088U, 9990830464U, 9999219584U, - 10007602816U, 10015996544U, 10024385152U, 10032774016U, 10041163648U, - 10049548928U, 10057940096U, 10066329472U, 10074717824U, 10083105152U, - 10091495296U, 10099878784U, 10108272256U, 10116660608U, 10125049216U, - 10133437312U, 10141825664U, 10150213504U, 10158601088U, 10166991232U, - 10175378816U, 10183766144U, 10192157312U, 10200545408U, 10208935552U, - 10217322112U, 10225712768U, 10234099328U, 10242489472U, 10250876032U, - 10259264896U, 10267656064U, 10276042624U, 10284429184U, 10292820352U, - 10301209472U, 10309598848U, 10317987712U, 10326375296U, 10334763392U, - 10343153536U, 10351541632U, 10359930752U, 10368318592U, 10376707456U, - 10385096576U, 10393484672U, 10401867136U, 10410262144U, 10418647424U, - 10427039104U, 10435425664U, 10443810176U, 10452203648U, 10460589952U, - 10468982144U, 10477369472U, 10485759104U, 10494147712U, 10502533504U, - 10510923392U, 10519313536U, 10527702656U, 10536091264U, 10544478592U, - 10552867712U, 10561255808U, 10569642368U, 10578032768U, 10586423168U, - 10594805632U, 10603200128U, 10611588992U, 10619976064U, 10628361344U, - 10636754048U, 10645143424U, 10653531776U, 10661920384U, 10670307968U, - 10678696832U, 10687086464U, 10695475072U, 10703863168U, 10712246144U, - 10720639616U, 10729026688U, 10737414784U, 10745806208U, 10754190976U, - 10762581376U, 10770971264U, 10779356288U, 10787747456U, 10796135552U, - 10804525184U, 10812915584U, 10821301888U, 10829692288U, 10838078336U, - 10846469248U, 10854858368U, 10863247232U, 10871631488U, 10880023424U, - 10888412032U, 10896799616U, 10905188992U, 10913574016U, 10921964672U, - 10930352768U, 10938742912U, 10947132544U, 10955518592U, 10963909504U, - 10972298368U, 10980687488U, 10989074816U, 10997462912U, 11005851776U, - 11014241152U, 11022627712U, 11031017344U, 11039403904U, 11047793024U, - 11056184704U, 11064570752U, 11072960896U, 11081343872U, 11089737856U, - 11098128256U, 11106514816U, 11114904448U, 11123293568U, 11131680128U, - 11140065152U, 11148458368U, 11156845696U, 11165236864U, 11173624192U, - 11182013824U, 11190402688U, 11198790784U, 11207179136U, 11215568768U, - 11223957376U, 11232345728U, 11240734592U, 11249122688U, 11257511296U, - 11265899648U, 11274285952U, 11282675584U, 11291065472U, 11299452544U, - 11307842432U, 11316231296U, 11324616832U, 11333009024U, 11341395584U, - 11349782656U, 11358172288U, 11366560384U, 11374950016U, 11383339648U, - 11391721856U, 11400117376U, 11408504192U, 11416893568U, 11425283456U, - 11433671552U, 11442061184U, 11450444672U, 11458837888U, 11467226752U, - 11475611776U, 11484003968U, 11492392064U, 11500780672U, 11509169024U, - 11517550976U, 11525944448U, 11534335616U, 11542724224U, 11551111808U, - 11559500672U, 11567890304U, 11576277376U, 11584667008U, 11593056128U, - 11601443456U, 11609830016U, 11618221952U, 11626607488U, 11634995072U, - 11643387776U, 11651775104U, 11660161664U, 11668552576U, 11676940928U, - 11685330304U, 11693718656U, 11702106496U, 11710496128U, 11718882688U, - 11727273088U, 11735660416U, 11744050048U, 11752437376U, 11760824704U, - 11769216128U, 11777604736U, 11785991296U, 11794381952U, 11802770048U, - 11811157888U, 11819548544U, 11827932544U, 11836324736U, 11844713344U, - 11853100928U, 11861486464U, 11869879936U, 11878268032U, 11886656896U, - 11895044992U, 11903433088U, 11911822976U, 11920210816U, 11928600448U, - 11936987264U, 11945375872U, 11953761152U, 11962151296U, 11970543488U, - 11978928512U, 11987320448U, 11995708288U, 12004095104U, 12012486272U, - 12020875136U, 12029255552U, 12037652096U, 12046039168U, 12054429568U, - 12062813824U, 12071206528U, 12079594624U, 12087983744U, 12096371072U, - 12104759936U, 12113147264U, 12121534592U, 12129924992U, 12138314624U, - 12146703232U, 12155091584U, 12163481216U, 12171864704U, 12180255872U, - 12188643968U, 12197034112U, 12205424512U, 12213811328U, 12222199424U, - 12230590336U, 12238977664U, 12247365248U, 12255755392U, 12264143488U, - 12272531584U, 12280920448U, 12289309568U, 12297694592U, 12306086528U, - 12314475392U, 12322865024U, 12331253632U, 12339640448U, 12348029312U, - 12356418944U, 12364805248U, 12373196672U, 12381580928U, 12389969024U, - 12398357632U, 12406750592U, 12415138432U, 12423527552U, 12431916416U, - 12440304512U, 12448692352U, 12457081216U, 12465467776U, 12473859968U, - 12482245504U, 12490636672U, 12499025536U, 12507411584U, 12515801728U, - 12524190592U, 12532577152U, 12540966272U, 12549354368U, 12557743232U, - 12566129536U, 12574523264U, 12582911872U, 12591299456U, 12599688064U, - 12608074624U, 12616463488U, 12624845696U, 12633239936U, 12641631616U, - 12650019968U, 12658407296U, 12666795136U, 12675183232U, 12683574656U, - 12691960192U, 12700350592U, 12708740224U, 12717128576U, 12725515904U, - 12733906816U, 12742295168U, 12750680192U, 12759071872U, 12767460736U, - 12775848832U, 12784236928U, 12792626816U, 12801014656U, 12809404288U, - 12817789312U, 12826181504U, 12834568832U, 12842954624U, 12851345792U, - 12859732352U, 12868122496U, 12876512128U, 12884901248U, 12893289088U, - 12901672832U, 12910067584U, 12918455168U, 12926842496U, 12935232896U, - 12943620736U, 12952009856U, 12960396928U, 12968786816U, 12977176192U, - 12985563776U, 12993951104U, 13002341504U, 13010730368U, 13019115392U, - 13027506304U, 13035895168U, 13044272512U, 13052673152U, 13061062528U, - 13069446272U, 13077838976U, 13086227072U, 13094613632U, 13103000192U, - 13111393664U, 13119782528U, 13128157568U, 13136559232U, 13144945024U, - 13153329536U, 13161724288U, 13170111872U, 13178502784U, 13186884736U, - 13195279744U, 13203667072U, 13212057472U, 13220445824U, 13228832128U, - 13237221248U, 13245610624U, 13254000512U, 13262388352U, 13270777472U, - 13279166336U, 13287553408U, 13295943296U, 13304331904U, 13312719488U, - 13321108096U, 13329494656U, 13337885824U, 13346274944U, 13354663808U, - 13363051136U, 13371439232U, 13379825024U, 13388210816U, 13396605056U, - 13404995456U, 13413380224U, 13421771392U, 13430159744U, 13438546048U, - 13446937216U, 13455326848U, 13463708288U, 13472103808U, 13480492672U, - 13488875648U, 13497269888U, 13505657728U, 13514045312U, 13522435712U, - 13530824576U, 13539210112U, 13547599232U, 13555989376U, 13564379008U, - 13572766336U, 13581154432U, 13589544832U, 13597932928U, 13606320512U, - 13614710656U, 13623097472U, 13631477632U, 13639874944U, 13648264064U, - 13656652928U, 13665041792U, 13673430656U, 13681818496U, 13690207616U, - 13698595712U, 13706982272U, 13715373184U, 13723762048U, 13732150144U, - 13740536704U, 13748926592U, 13757316224U, 13765700992U, 13774090112U, - 13782477952U, 13790869376U, 13799259008U, 13807647872U, 13816036736U, - 13824425344U, 13832814208U, 13841202304U, 13849591424U, 13857978752U, - 13866368896U, 13874754688U, 13883145344U, 13891533184U, 13899919232U, - 13908311168U, 13916692096U, 13925085056U, 13933473152U, 13941866368U, - 13950253696U, 13958643584U, 13967032192U, 13975417216U, 13983807616U, - 13992197504U, 14000582272U, 14008973696U, 14017363072U, 14025752192U, - 14034137984U, 14042528384U, 14050918016U, 14059301504U, 14067691648U, - 14076083584U, 14084470144U, 14092852352U, 14101249664U, 14109635968U, - 14118024832U, 14126407552U, 14134804352U, 14143188608U, 14151577984U, - 14159968384U, 14168357248U, 14176741504U, 14185127296U, 14193521024U, - 14201911424U, 14210301824U, 14218685056U, 14227067264U, 14235467392U, - 14243855488U, 14252243072U, 14260630144U, 14269021568U, 14277409408U, - 14285799296U, 14294187904U, 14302571392U, 14310961792U, 14319353728U, - 14327738752U, 14336130944U, 14344518784U, 14352906368U, 14361296512U, - 14369685376U, 14378071424U, 14386462592U, 14394848128U, 14403230848U, - 14411627392U, 14420013952U, 14428402304U, 14436793472U, 14445181568U, - 14453569664U, 14461959808U, 14470347904U, 14478737024U, 14487122816U, - 14495511424U, 14503901824U, 14512291712U, 14520677504U, 14529064832U, - 14537456768U, 14545845632U, 14554234496U, 14562618496U, 14571011456U, - 14579398784U, 14587789184U, 14596172672U, 14604564608U, 14612953984U, - 14621341312U, 14629724288U, 14638120832U, 14646503296U, 14654897536U, - 14663284864U, 14671675264U, 14680061056U, 14688447616U, 14696835968U, - 14705228416U, 14713616768U, 14722003328U, 14730392192U, 14738784128U, - 14747172736U, 14755561088U, 14763947648U, 14772336512U, 14780725376U, - 14789110144U, 14797499776U, 14805892736U, 14814276992U, 14822670208U, - 14831056256U, 14839444352U, 14847836032U, 14856222848U, 14864612992U, - 14872997504U, 14881388672U, 14889775744U, 14898165376U, 14906553472U, - 14914944896U, 14923329664U, 14931721856U, 14940109696U, 14948497024U, - 14956887424U, 14965276544U, 14973663616U, 14982053248U, 14990439808U, - 14998830976U, 15007216768U, 15015605888U, 15023995264U, 15032385152U, - 15040768384U, 15049154944U, 15057549184U, 15065939072U, 15074328448U, - 15082715008U, 15091104128U, 15099493504U, 15107879296U, 15116269184U, - 15124659584U, 15133042304U, 15141431936U, 15149824384U, 15158214272U, - 15166602368U, 15174991232U, 15183378304U, 15191760512U, 15200154496U, - 15208542592U, 15216931712U, 15225323392U, 15233708416U, 15242098048U, - 15250489216U, 15258875264U, 15267265408U, 15275654528U, 15284043136U, - 15292431488U, 15300819584U, 15309208192U, 15317596544U, 15325986176U, - 15334374784U, 15342763648U, 15351151744U, 15359540608U, 15367929728U, - 15376318336U, 15384706432U, 15393092992U, 15401481856U, 15409869952U, - 15418258816U, 15426649984U, 15435037568U, 15443425664U, 15451815296U, - 15460203392U, 15468589184U, 15476979328U, 15485369216U, 15493755776U, - 15502146944U, 15510534272U, 15518924416U, 15527311232U, 15535699072U, - 15544089472U, 15552478336U, 15560866688U, 15569254528U, 15577642624U, - 15586031488U, 15594419072U, 15602809472U, 15611199104U, 15619586432U, - 15627975296U, 15636364928U, 15644753792U, 15653141888U, 15661529216U, - 15669918848U, 15678305152U, 15686696576U, 15695083136U, 15703474048U, - 15711861632U, 15720251264U, 15728636288U, 15737027456U, 15745417088U, - 15753804928U, 15762194048U, 15770582656U, 15778971008U, 15787358336U, - 15795747712U, 15804132224U, 15812523392U, 15820909696U, 15829300096U, - 15837691264U, 15846071936U, 15854466944U, 15862855808U, 15871244672U, - 15879634816U, 15888020608U, 15896409728U, 15904799104U, 15913185152U, - 15921577088U, 15929966464U, 15938354816U, 15946743424U, 15955129472U, - 15963519872U, 15971907968U, 15980296064U, 15988684928U, 15997073024U, - 16005460864U, 16013851264U, 16022241152U, 16030629248U, 16039012736U, - 16047406976U, 16055794816U, 16064181376U, 16072571264U, 16080957824U, - 16089346688U, 16097737856U, 16106125184U, 16114514816U, 16122904192U, - 16131292544U, 16139678848U, 16148066944U, 16156453504U, 16164839552U, - 16173236096U, 16181623424U, 16190012032U, 16198401152U, 16206790528U, - 16215177344U, 16223567744U, 16231956352U, 16240344704U, 16248731008U, - 16257117824U, 16265504384U, 16273898624U, 16282281856U, 16290668672U, - 16299064192U, 16307449216U, 16315842176U, 16324230016U, 16332613504U, - 16341006464U, 16349394304U, 16357783168U, 16366172288U, 16374561664U, - 16382951296U, 16391337856U, 16399726208U, 16408116352U, 16416505472U, - 16424892032U, 16433282176U, 16441668224U, 16450058624U, 16458448768U, - 16466836864U, 16475224448U, 16483613056U, 16492001408U, 16500391808U, - 16508779648U, 16517166976U, 16525555328U, 16533944192U, 16542330752U, - 16550719616U, 16559110528U, 16567497088U, 16575888512U, 16584274816U, - 16592665472U, 16601051008U, 16609442944U, 16617832064U, 16626218624U, - 16634607488U, 16642996096U, 16651385728U, 16659773824U, 16668163712U, - 16676552576U, 16684938112U, 16693328768U, 16701718144U, 16710095488U, - 16718492288U, 16726883968U, 16735272832U, 16743661184U, 16752049792U, - 16760436608U, 16768827008U, 16777214336U, 16785599104U, 16793992832U, - 16802381696U, 16810768768U, 16819151744U, 16827542656U, 16835934848U, - 16844323712U, 16852711552U, 16861101952U, 16869489536U, 16877876864U, - 16886265728U, 16894653056U, 16903044736U, 16911431296U, 16919821696U, - 16928207488U, 16936592768U, 16944987776U, 16953375616U, 16961763968U, - 16970152832U, 16978540928U, 16986929536U, 16995319168U, 17003704448U, - 17012096896U, 17020481152U, 17028870784U, 17037262208U, 17045649536U, - 17054039936U, 17062426496U, 17070814336U, 17079205504U, 17087592064U, - 17095978112U, 17104369024U, 17112759424U, 17121147776U, 17129536384U, - 17137926016U, 17146314368U, 17154700928U, 17163089792U, 17171480192U, - 17179864192U, 17188256896U, 17196644992U, 17205033856U, 17213423488U, - 17221811072U, 17230198912U, 17238588032U, 17246976896U, 17255360384U, - 17263754624U, 17272143232U, 17280530048U, 17288918912U, 17297309312U, - 17305696384U, 17314085504U, 17322475136U, 17330863744U, 17339252096U, - 17347640192U, 17356026496U, 17364413824U, 17372796544U, 17381190016U, - 17389583488U, 17397972608U, 17406360704U, 17414748544U, 17423135872U, - 17431527296U, 17439915904U, 17448303232U, 17456691584U, 17465081728U, - 17473468288U, 17481857408U, 17490247552U, 17498635904U, 17507022464U, - 17515409024U, 17523801728U, 17532189824U, 17540577664U, 17548966016U, - 17557353344U, 17565741184U, 17574131584U, 17582519168U, 17590907008U, - 17599296128U, 17607687808U, 17616076672U, 17624455808U, 17632852352U, - 17641238656U, 17649630848U, 17658018944U, 17666403968U, 17674794112U, - 17683178368U, 17691573376U, 17699962496U, 17708350592U, 17716739968U, - 17725126528U, 17733517184U, 17741898112U, 17750293888U, 17758673024U, - 17767070336U, 17775458432U, 17783848832U, 17792236928U, 17800625536U, - 17809012352U, 17817402752U, 17825785984U, 17834178944U, 17842563968U, - 17850955648U, 17859344512U, 17867732864U, 17876119424U, 17884511872U, - 17892900224U, 17901287296U, 17909677696U, 17918058112U, 17926451072U, - 17934843776U, 17943230848U, 17951609216U, 17960008576U, 17968397696U, - 17976784256U, 17985175424U, 17993564032U, 18001952128U, 18010339712U, - 18018728576U, 18027116672U, 18035503232U, 18043894144U, 18052283264U, - 18060672128U, 18069056384U, 18077449856U, 18085837184U, 18094225792U, - 18102613376U, 18111004544U, 18119388544U, 18127781248U, 18136170368U, - 18144558976U, 18152947328U, 18161336192U, 18169724288U, 18178108544U, - 18186498944U, 18194886784U, 18203275648U, 18211666048U, 18220048768U, - 18228444544U, 18236833408U, 18245220736U + 1073739904U, 1082130304U, 1090514816U, 1098906752U, 1107293056U, + 1115684224U, 1124070016U, 1132461952U, 1140849536U, 1149232768U, + 1157627776U, 1166013824U, 1174404736U, 1182786944U, 1191180416U, + 1199568512U, 1207958912U, 1216345216U, 1224732032U, 1233124736U, + 1241513344U, 1249902464U, 1258290304U, 1266673792U, 1275067264U, + 1283453312U, 1291844992U, 1300234112U, 1308619904U, 1317010048U, + 1325397376U, 1333787776U, 1342176128U, 1350561664U, 1358954368U, + 1367339392U, 1375731584U, 1384118144U, 1392507008U, 1400897408U, + 1409284736U, 1417673344U, 1426062464U, 1434451072U, 1442839168U, + 1451229056U, 1459615616U, 1468006016U, 1476394112U, 1484782976U, + 1493171584U, 1501559168U, 1509948032U, 1518337664U, 1526726528U, + 1535114624U, 1543503488U, 1551892096U, 1560278656U, 1568669056U, + 1577056384U, 1585446272U, 1593831296U, 1602219392U, 1610610304U, + 1619000192U, 1627386752U, 1635773824U, 1644164224U, 1652555648U, + 1660943488U, 1669332608U, 1677721216U, 1686109312U, 1694497664U, + 1702886272U, 1711274624U, 1719661184U, 1728047744U, 1736434816U, + 1744829056U, 1753218944U, 1761606272U, 1769995904U, 1778382464U, + 1786772864U, 1795157888U, 1803550592U, 1811937664U, 1820327552U, + 1828711552U, 1837102976U, 1845488768U, 1853879936U, 1862269312U, + 1870656896U, 1879048064U, 1887431552U, 1895825024U, 1904212096U, + 1912601216U, 1920988544U, 1929379456U, 1937765504U, 1946156672U, + 1954543232U, 1962932096U, 1971321728U, 1979707264U, 1988093056U, + 1996487552U, 2004874624U, 2013262208U, 2021653888U, 2030039936U, + 2038430848U, 2046819968U, 2055208576U, 2063596672U, 2071981952U, + 2080373632U, 2088762752U, 2097149056U, 2105539712U, 2113928576U, + 2122315136U, 2130700672U, 2139092608U, 2147483264U, 2155872128U, + 2164257664U, 2172642176U, 2181035392U, 2189426048U, 2197814912U, + 2206203008U, 2214587264U, 2222979712U, 2231367808U, 2239758208U, + 2248145024U, 2256527744U, 2264922752U, 2273312128U, 2281701248U, + 2290086272U, 2298476672U, 2306867072U, 2315251072U, 2323639168U, + 2332032128U, 2340420224U, 2348808064U, 2357196416U, 2365580416U, + 2373966976U, 2382363008U, 2390748544U, 2399139968U, 2407530368U, + 2415918976U, 2424307328U, 2432695424U, 2441084288U, 2449472384U, + 2457861248U, 2466247808U, 2474637184U, 2483026816U, 2491414144U, + 2499803776U, 2508191872U, 2516582272U, 2524970368U, 2533359232U, + 2541743488U, 2550134144U, 2558525056U, 2566913408U, 2575301504U, + 2583686528U, 2592073856U, 2600467328U, 2608856192U, 2617240448U, + 2625631616U, 2634022016U, 2642407552U, 2650796416U, 2659188352U, + 2667574912U, 2675965312U, 2684352896U, 2692738688U, 2701130624U, + 2709518464U, 2717907328U, 2726293376U, 2734685056U, 2743073152U, + 2751462016U, 2759851648U, 2768232832U, 2776625536U, 2785017728U, + 2793401984U, 2801794432U, 2810182016U, 2818571648U, 2826959488U, + 2835349376U, 2843734144U, 2852121472U, 2860514432U, 2868900992U, + 2877286784U, 2885676928U, 2894069632U, 2902451584U, 2910843008U, + 2919234688U, 2927622784U, 2936011648U, 2944400768U, 2952789376U, + 2961177728U, 2969565568U, 2977951616U, 2986338944U, 2994731392U, + 3003120256U, 3011508352U, 3019895936U, 3028287104U, 3036675968U, + 3045063808U, 3053452928U, 3061837696U, 3070228352U, 3078615424U, + 3087003776U, 3095394944U, 3103782272U, 3112173184U, 3120562048U, + 3128944768U, 3137339264U, 3145725056U, 3154109312U, 3162505088U, + 3170893184U, 3179280256U, 3187669376U, 3196056704U, 3204445568U, + 3212836736U, 3221224064U, 3229612928U, 3238002304U, 3246391168U, + 3254778496U, 3263165824U, 3271556224U, 3279944576U, 3288332416U, + 3296719232U, 3305110912U, 3313500032U, 3321887104U, 3330273152U, + 3338658944U, 3347053184U, 3355440512U, 3363827072U, 3372220288U, + 3380608384U, 3388997504U, 3397384576U, 3405774208U, 3414163072U, + 3422551936U, 3430937984U, 3439328384U, 3447714176U, 3456104576U, + 3464493952U, 3472883584U, 3481268864U, 3489655168U, 3498048896U, + 3506434432U, 3514826368U, 3523213952U, 3531603584U, 3539987072U, + 3548380288U, 3556763264U, 3565157248U, 3573545344U, 3581934464U, + 3590324096U, 3598712704U, 3607098752U, 3615488384U, 3623877248U, + 3632265856U, 3640646528U, 3649043584U, 3657430144U, 3665821568U, + 3674207872U, 3682597504U, 3690984832U, 3699367808U, 3707764352U, + 3716152448U, 3724541056U, 3732925568U, 3741318016U, 3749706368U, + 3758091136U, 3766481536U, 3774872704U, 3783260032U, 3791650432U, + 3800036224U, 3808427648U, 3816815488U, 3825204608U, 3833592704U, + 3841981568U, 3850370432U, 3858755968U, 3867147904U, 3875536256U, + 3883920512U, 3892313728U, 3900702592U, 3909087872U, 3917478784U, + 3925868416U, 3934256512U, 3942645376U, 3951032192U, 3959422336U, + 3967809152U, 3976200064U, 3984588416U, 3992974976U, 4001363584U, + 4009751168U, 4018141312U, 4026530432U, 4034911616U, 4043308928U, + 4051695488U, 4060084352U, 4068472448U, 4076862848U, 4085249408U, + 4093640576U, 4102028416U, 4110413696U, 4118805632U, 4127194496U, + 4135583104U, 4143971968U, 4152360832U, 4160746112U, 4169135744U, + 4177525888U, 4185912704U, 4194303616U, 4202691968U, 4211076736U, + 4219463552U, 4227855488U, 4236246656U, 4244633728U, 4253022848U, + 4261412224U, 4269799808U, 4278184832U, 4286578048U, 4294962304U, + 4303349632U, 4311743104U, 4320130432U, 4328521088U, 4336909184U, + 4345295488U, 4353687424U, 4362073472U, 4370458496U, 4378852736U, + 4387238528U, 4395630208U, 4404019072U, 4412407424U, 4420790656U, + 4429182848U, 4437571456U, 4445962112U, 4454344064U, 4462738048U, + 4471119232U, 4479516544U, 4487904128U, 4496289664U, 4504682368U, + 4513068416U, 4521459584U, 4529846144U, 4538232704U, 4546619776U, + 4555010176U, 4563402112U, 4571790208U, 4580174464U, 4588567936U, + 4596957056U, 4605344896U, 4613734016U, 4622119808U, 4630511488U, + 4638898816U, 4647287936U, 4655675264U, 4664065664U, 4672451968U, + 4680842624U, 4689231488U, 4697620352U, 4706007424U, 4714397056U, + 4722786176U, 4731173248U, 4739562368U, 4747951744U, 4756340608U, + 4764727936U, 4773114496U, 4781504384U, 4789894784U, 4798283648U, + 4806667648U, 4815059584U, 4823449472U, 4831835776U, 4840226176U, + 4848612224U, 4857003392U, 4865391488U, 4873780096U, 4882169728U, + 4890557312U, 4898946944U, 4907333248U, 4915722368U, 4924110976U, + 4932499328U, 4940889728U, 4949276032U, 4957666432U, 4966054784U, + 4974438016U, 4982831488U, 4991221376U, 4999607168U, 5007998848U, + 5016386432U, 5024763776U, 5033164672U, 5041544576U, 5049941888U, + 5058329728U, 5066717056U, 5075107456U, 5083494272U, 5091883904U, + 5100273536U, 5108662144U, 5117048192U, 5125436032U, 5133827456U, + 5142215296U, 5150605184U, 5158993024U, 5167382144U, 5175769472U, + 5184157568U, 5192543872U, 5200936064U, 5209324928U, 5217711232U, + 5226102656U, 5234490496U, 5242877312U, 5251263872U, 5259654016U, + 5268040832U, 5276434304U, 5284819328U, 5293209728U, 5301598592U, + 5309986688U, 5318374784U, 5326764416U, 5335151488U, 5343542144U, + 5351929472U, 5360319872U, 5368706944U, 5377096576U, 5385484928U, + 5393871232U, 5402263424U, 5410650496U, 5419040384U, 5427426944U, + 5435816576U, 5444205952U, 5452594816U, 5460981376U, 5469367936U, + 5477760896U, 5486148736U, 5494536832U, 5502925952U, 5511315328U, + 5519703424U, 5528089984U, 5536481152U, 5544869504U, 5553256064U, + 5561645696U, 5570032768U, 5578423936U, 5586811264U, 5595193216U, + 5603585408U, 5611972736U, 5620366208U, 5628750464U, 5637143936U, + 5645528192U, 5653921408U, 5662310272U, 5670694784U, 5679082624U, + 5687474048U, 5695864448U, 5704251008U, 5712641408U, 5721030272U, + 5729416832U, 5737806208U, 5746194304U, 5754583936U, 5762969984U, + 5771358592U, 5779748224U, 5788137856U, 5796527488U, 5804911232U, + 5813300608U, 5821692544U, 5830082176U, 5838468992U, 5846855552U, + 5855247488U, 5863636096U, 5872024448U, 5880411008U, 5888799872U, + 5897186432U, 5905576832U, 5913966976U, 5922352768U, 5930744704U, + 5939132288U, 5947522432U, 5955911296U, 5964299392U, 5972688256U, + 5981074304U, 5989465472U, 5997851008U, 6006241408U, 6014627968U, + 6023015552U, 6031408256U, 6039796096U, 6048185216U, 6056574848U, + 6064963456U, 6073351808U, 6081736064U, 6090128768U, 6098517632U, + 6106906496U, 6115289216U, 6123680896U, 6132070016U, 6140459648U, + 6148849024U, 6157237376U, 6165624704U, 6174009728U, 6182403712U, + 6190792064U, 6199176064U, 6207569792U, 6215952256U, 6224345216U, + 6232732544U, 6241124224U, 6249510272U, 6257899136U, 6266287744U, + 6274676864U, 6283065728U, 6291454336U, 6299843456U, 6308232064U, + 6316620928U, 6325006208U, 6333395584U, 6341784704U, 6350174848U, + 6358562176U, 6366951296U, 6375337856U, 6383729536U, 6392119168U, + 6400504192U, 6408895616U, 6417283456U, 6425673344U, 6434059136U, + 6442444672U, 6450837376U, 6459223424U, 6467613056U, 6476004224U, + 6484393088U, 6492781952U, 6501170048U, 6509555072U, 6517947008U, + 6526336384U, 6534725504U, 6543112832U, 6551500672U, 6559888768U, + 6568278656U, 6576662912U, 6585055616U, 6593443456U, 6601834112U, + 6610219648U, 6618610304U, 6626999168U, 6635385472U, 6643777408U, + 6652164224U, 6660552832U, 6668941952U, 6677330048U, 6685719424U, + 6694107776U, 6702493568U, 6710882176U, 6719274112U, 6727662976U, + 6736052096U, 6744437632U, 6752825984U, 6761213824U, 6769604224U, + 6777993856U, 6786383488U, 6794770816U, 6803158144U, 6811549312U, + 6819937664U, 6828326528U, 6836706176U, 6845101696U, 6853491328U, + 6861880448U, 6870269312U, 6878655104U, 6887046272U, 6895433344U, + 6903822208U, 6912212864U, 6920596864U, 6928988288U, 6937377152U, + 6945764992U, 6954149248U, 6962544256U, 6970928768U, 6979317376U, + 6987709312U, 6996093824U, 7004487296U, 7012875392U, 7021258624U, + 7029652352U, 7038038912U, 7046427776U, 7054818944U, 7063207808U, + 7071595136U, 7079980928U, 7088372608U, 7096759424U, 7105149824U, + 7113536896U, 7121928064U, 7130315392U, 7138699648U, 7147092352U, + 7155479168U, 7163865728U, 7172249984U, 7180648064U, 7189036672U, + 7197424768U, 7205810816U, 7214196608U, 7222589824U, 7230975104U, + 7239367552U, 7247755904U, 7256145536U, 7264533376U, 7272921472U, + 7281308032U, 7289694848U, 7298088832U, 7306471808U, 7314864512U, + 7323253888U, 7331643008U, 7340029568U, 7348419712U, 7356808832U, + 7365196672U, 7373585792U, 7381973888U, 7390362752U, 7398750592U, + 7407138944U, 7415528576U, 7423915648U, 7432302208U, 7440690304U, + 7449080192U, 7457472128U, 7465860992U, 7474249088U, 7482635648U, + 7491023744U, 7499412608U, 7507803008U, 7516192384U, 7524579968U, + 7532967296U, 7541358464U, 7549745792U, 7558134656U, 7566524032U, + 7574912896U, 7583300992U, 7591690112U, 7600075136U, 7608466816U, + 7616854912U, 7625244544U, 7633629824U, 7642020992U, 7650410368U, + 7658794112U, 7667187328U, 7675574912U, 7683961984U, 7692349568U, + 7700739712U, 7709130368U, 7717519232U, 7725905536U, 7734295424U, + 7742683264U, 7751069056U, 7759457408U, 7767849088U, 7776238208U, + 7784626816U, 7793014912U, 7801405312U, 7809792128U, 7818179968U, + 7826571136U, 7834957184U, 7843347328U, 7851732352U, 7860124544U, + 7868512384U, 7876902016U, 7885287808U, 7893679744U, 7902067072U, + 7910455936U, 7918844288U, 7927230848U, 7935622784U, 7944009344U, + 7952400256U, 7960786048U, 7969176704U, 7977565312U, 7985953408U, + 7994339968U, 8002730368U, 8011119488U, 8019508096U, 8027896192U, + 8036285056U, 8044674688U, 8053062272U, 8061448832U, 8069838464U, + 8078227328U, 8086616704U, 8095006592U, 8103393664U, 8111783552U, + 8120171392U, 8128560256U, 8136949376U, 8145336704U, 8153726848U, + 8162114944U, 8170503296U, 8178891904U, 8187280768U, 8195669632U, + 8204058496U, 8212444544U, 8220834176U, 8229222272U, 8237612672U, + 8246000768U, 8254389376U, 8262775168U, 8271167104U, 8279553664U, + 8287944064U, 8296333184U, 8304715136U, 8313108352U, 8321497984U, + 8329885568U, 8338274432U, 8346663296U, 8355052928U, 8363441536U, + 8371828352U, 8380217984U, 8388606592U, 8396996224U, 8405384576U, + 8413772672U, 8422161536U, 8430549376U, 8438939008U, 8447326592U, + 8455715456U, 8464104832U, 8472492928U, 8480882048U, 8489270656U, + 8497659776U, 8506045312U, 8514434944U, 8522823808U, 8531208832U, + 8539602304U, 8547990656U, 8556378752U, 8564768384U, 8573154176U, + 8581542784U, 8589933952U, 8598322816U, 8606705024U, 8615099264U, + 8623487872U, 8631876992U, 8640264064U, 8648653952U, 8657040256U, + 8665430656U, 8673820544U, 8682209152U, 8690592128U, 8698977152U, + 8707374464U, 8715763328U, 8724151424U, 8732540032U, 8740928384U, + 8749315712U, 8757704576U, 8766089344U, 8774480768U, 8782871936U, + 8791260032U, 8799645824U, 8808034432U, 8816426368U, 8824812928U, + 8833199488U, 8841591424U, 8849976448U, 8858366336U, 8866757248U, + 8875147136U, 8883532928U, 8891923328U, 8900306816U, 8908700288U, + 8917088384U, 8925478784U, 8933867392U, 8942250368U, 8950644608U, + 8959032704U, 8967420544U, 8975809664U, 8984197504U, 8992584064U, + 9000976256U, 9009362048U, 9017752448U, 9026141312U, 9034530688U, + 9042917504U, 9051307904U, 9059694208U, 9068084864U, 9076471424U, + 9084861824U, 9093250688U, 9101638528U, 9110027648U, 9118416512U, + 9126803584U, 9135188096U, 9143581312U, 9151969664U, 9160356224U, + 9168747136U, 9177134464U, 9185525632U, 9193910144U, 9202302848U, + 9210690688U, 9219079552U, 9227465344U, 9235854464U, 9244244864U, + 9252633472U, 9261021824U, 9269411456U, 9277799296U, 9286188928U, + 9294574208U, 9302965888U, 9311351936U, 9319740032U, 9328131968U, + 9336516736U, 9344907392U, 9353296768U, 9361685888U, 9370074752U, + 9378463616U, 9386849408U, 9395239808U, 9403629184U, 9412016512U, + 9420405376U, 9428795008U, 9437181568U, 9445570688U, 9453960832U, + 9462346624U, 9470738048U, 9479121536U, 9487515008U, 9495903616U, + 9504289664U, 9512678528U, 9521067904U, 9529456256U, 9537843584U, + 9546233728U, 9554621312U, 9563011456U, 9571398784U, 9579788672U, + 9588178304U, 9596567168U, 9604954496U, 9613343104U, 9621732992U, + 9630121856U, 9638508416U, 9646898816U, 9655283584U, 9663675776U, + 9672061312U, 9680449664U, 9688840064U, 9697230464U, 9705617536U, + 9714003584U, 9722393984U, 9730772608U, 9739172224U, 9747561088U, + 9755945344U, 9764338816U, 9772726144U, 9781116544U, 9789503872U, + 9797892992U, 9806282624U, 9814670464U, 9823056512U, 9831439232U, + 9839833984U, 9848224384U, 9856613504U, 9865000576U, 9873391232U, + 9881772416U, 9890162816U, 9898556288U, 9906940544U, 9915333248U, + 9923721088U, 9932108672U, 9940496512U, 9948888448U, 9957276544U, + 9965666176U, 9974048384U, 9982441088U, 9990830464U, 9999219584U, + 10007602816U, 10015996544U, 10024385152U, 10032774016U, 10041163648U, + 10049548928U, 10057940096U, 10066329472U, 10074717824U, 10083105152U, + 10091495296U, 10099878784U, 10108272256U, 10116660608U, 10125049216U, + 10133437312U, 10141825664U, 10150213504U, 10158601088U, 10166991232U, + 10175378816U, 10183766144U, 10192157312U, 10200545408U, 10208935552U, + 10217322112U, 10225712768U, 10234099328U, 10242489472U, 10250876032U, + 10259264896U, 10267656064U, 10276042624U, 10284429184U, 10292820352U, + 10301209472U, 10309598848U, 10317987712U, 10326375296U, 10334763392U, + 10343153536U, 10351541632U, 10359930752U, 10368318592U, 10376707456U, + 10385096576U, 10393484672U, 10401867136U, 10410262144U, 10418647424U, + 10427039104U, 10435425664U, 10443810176U, 10452203648U, 10460589952U, + 10468982144U, 10477369472U, 10485759104U, 10494147712U, 10502533504U, + 10510923392U, 10519313536U, 10527702656U, 10536091264U, 10544478592U, + 10552867712U, 10561255808U, 10569642368U, 10578032768U, 10586423168U, + 10594805632U, 10603200128U, 10611588992U, 10619976064U, 10628361344U, + 10636754048U, 10645143424U, 10653531776U, 10661920384U, 10670307968U, + 10678696832U, 10687086464U, 10695475072U, 10703863168U, 10712246144U, + 10720639616U, 10729026688U, 10737414784U, 10745806208U, 10754190976U, + 10762581376U, 10770971264U, 10779356288U, 10787747456U, 10796135552U, + 10804525184U, 10812915584U, 10821301888U, 10829692288U, 10838078336U, + 10846469248U, 10854858368U, 10863247232U, 10871631488U, 10880023424U, + 10888412032U, 10896799616U, 10905188992U, 10913574016U, 10921964672U, + 10930352768U, 10938742912U, 10947132544U, 10955518592U, 10963909504U, + 10972298368U, 10980687488U, 10989074816U, 10997462912U, 11005851776U, + 11014241152U, 11022627712U, 11031017344U, 11039403904U, 11047793024U, + 11056184704U, 11064570752U, 11072960896U, 11081343872U, 11089737856U, + 11098128256U, 11106514816U, 11114904448U, 11123293568U, 11131680128U, + 11140065152U, 11148458368U, 11156845696U, 11165236864U, 11173624192U, + 11182013824U, 11190402688U, 11198790784U, 11207179136U, 11215568768U, + 11223957376U, 11232345728U, 11240734592U, 11249122688U, 11257511296U, + 11265899648U, 11274285952U, 11282675584U, 11291065472U, 11299452544U, + 11307842432U, 11316231296U, 11324616832U, 11333009024U, 11341395584U, + 11349782656U, 11358172288U, 11366560384U, 11374950016U, 11383339648U, + 11391721856U, 11400117376U, 11408504192U, 11416893568U, 11425283456U, + 11433671552U, 11442061184U, 11450444672U, 11458837888U, 11467226752U, + 11475611776U, 11484003968U, 11492392064U, 11500780672U, 11509169024U, + 11517550976U, 11525944448U, 11534335616U, 11542724224U, 11551111808U, + 11559500672U, 11567890304U, 11576277376U, 11584667008U, 11593056128U, + 11601443456U, 11609830016U, 11618221952U, 11626607488U, 11634995072U, + 11643387776U, 11651775104U, 11660161664U, 11668552576U, 11676940928U, + 11685330304U, 11693718656U, 11702106496U, 11710496128U, 11718882688U, + 11727273088U, 11735660416U, 11744050048U, 11752437376U, 11760824704U, + 11769216128U, 11777604736U, 11785991296U, 11794381952U, 11802770048U, + 11811157888U, 11819548544U, 11827932544U, 11836324736U, 11844713344U, + 11853100928U, 11861486464U, 11869879936U, 11878268032U, 11886656896U, + 11895044992U, 11903433088U, 11911822976U, 11920210816U, 11928600448U, + 11936987264U, 11945375872U, 11953761152U, 11962151296U, 11970543488U, + 11978928512U, 11987320448U, 11995708288U, 12004095104U, 12012486272U, + 12020875136U, 12029255552U, 12037652096U, 12046039168U, 12054429568U, + 12062813824U, 12071206528U, 12079594624U, 12087983744U, 12096371072U, + 12104759936U, 12113147264U, 12121534592U, 12129924992U, 12138314624U, + 12146703232U, 12155091584U, 12163481216U, 12171864704U, 12180255872U, + 12188643968U, 12197034112U, 12205424512U, 12213811328U, 12222199424U, + 12230590336U, 12238977664U, 12247365248U, 12255755392U, 12264143488U, + 12272531584U, 12280920448U, 12289309568U, 12297694592U, 12306086528U, + 12314475392U, 12322865024U, 12331253632U, 12339640448U, 12348029312U, + 12356418944U, 12364805248U, 12373196672U, 12381580928U, 12389969024U, + 12398357632U, 12406750592U, 12415138432U, 12423527552U, 12431916416U, + 12440304512U, 12448692352U, 12457081216U, 12465467776U, 12473859968U, + 12482245504U, 12490636672U, 12499025536U, 12507411584U, 12515801728U, + 12524190592U, 12532577152U, 12540966272U, 12549354368U, 12557743232U, + 12566129536U, 12574523264U, 12582911872U, 12591299456U, 12599688064U, + 12608074624U, 12616463488U, 12624845696U, 12633239936U, 12641631616U, + 12650019968U, 12658407296U, 12666795136U, 12675183232U, 12683574656U, + 12691960192U, 12700350592U, 12708740224U, 12717128576U, 12725515904U, + 12733906816U, 12742295168U, 12750680192U, 12759071872U, 12767460736U, + 12775848832U, 12784236928U, 12792626816U, 12801014656U, 12809404288U, + 12817789312U, 12826181504U, 12834568832U, 12842954624U, 12851345792U, + 12859732352U, 12868122496U, 12876512128U, 12884901248U, 12893289088U, + 12901672832U, 12910067584U, 12918455168U, 12926842496U, 12935232896U, + 12943620736U, 12952009856U, 12960396928U, 12968786816U, 12977176192U, + 12985563776U, 12993951104U, 13002341504U, 13010730368U, 13019115392U, + 13027506304U, 13035895168U, 13044272512U, 13052673152U, 13061062528U, + 13069446272U, 13077838976U, 13086227072U, 13094613632U, 13103000192U, + 13111393664U, 13119782528U, 13128157568U, 13136559232U, 13144945024U, + 13153329536U, 13161724288U, 13170111872U, 13178502784U, 13186884736U, + 13195279744U, 13203667072U, 13212057472U, 13220445824U, 13228832128U, + 13237221248U, 13245610624U, 13254000512U, 13262388352U, 13270777472U, + 13279166336U, 13287553408U, 13295943296U, 13304331904U, 13312719488U, + 13321108096U, 13329494656U, 13337885824U, 13346274944U, 13354663808U, + 13363051136U, 13371439232U, 13379825024U, 13388210816U, 13396605056U, + 13404995456U, 13413380224U, 13421771392U, 13430159744U, 13438546048U, + 13446937216U, 13455326848U, 13463708288U, 13472103808U, 13480492672U, + 13488875648U, 13497269888U, 13505657728U, 13514045312U, 13522435712U, + 13530824576U, 13539210112U, 13547599232U, 13555989376U, 13564379008U, + 13572766336U, 13581154432U, 13589544832U, 13597932928U, 13606320512U, + 13614710656U, 13623097472U, 13631477632U, 13639874944U, 13648264064U, + 13656652928U, 13665041792U, 13673430656U, 13681818496U, 13690207616U, + 13698595712U, 13706982272U, 13715373184U, 13723762048U, 13732150144U, + 13740536704U, 13748926592U, 13757316224U, 13765700992U, 13774090112U, + 13782477952U, 13790869376U, 13799259008U, 13807647872U, 13816036736U, + 13824425344U, 13832814208U, 13841202304U, 13849591424U, 13857978752U, + 13866368896U, 13874754688U, 13883145344U, 13891533184U, 13899919232U, + 13908311168U, 13916692096U, 13925085056U, 13933473152U, 13941866368U, + 13950253696U, 13958643584U, 13967032192U, 13975417216U, 13983807616U, + 13992197504U, 14000582272U, 14008973696U, 14017363072U, 14025752192U, + 14034137984U, 14042528384U, 14050918016U, 14059301504U, 14067691648U, + 14076083584U, 14084470144U, 14092852352U, 14101249664U, 14109635968U, + 14118024832U, 14126407552U, 14134804352U, 14143188608U, 14151577984U, + 14159968384U, 14168357248U, 14176741504U, 14185127296U, 14193521024U, + 14201911424U, 14210301824U, 14218685056U, 14227067264U, 14235467392U, + 14243855488U, 14252243072U, 14260630144U, 14269021568U, 14277409408U, + 14285799296U, 14294187904U, 14302571392U, 14310961792U, 14319353728U, + 14327738752U, 14336130944U, 14344518784U, 14352906368U, 14361296512U, + 14369685376U, 14378071424U, 14386462592U, 14394848128U, 14403230848U, + 14411627392U, 14420013952U, 14428402304U, 14436793472U, 14445181568U, + 14453569664U, 14461959808U, 14470347904U, 14478737024U, 14487122816U, + 14495511424U, 14503901824U, 14512291712U, 14520677504U, 14529064832U, + 14537456768U, 14545845632U, 14554234496U, 14562618496U, 14571011456U, + 14579398784U, 14587789184U, 14596172672U, 14604564608U, 14612953984U, + 14621341312U, 14629724288U, 14638120832U, 14646503296U, 14654897536U, + 14663284864U, 14671675264U, 14680061056U, 14688447616U, 14696835968U, + 14705228416U, 14713616768U, 14722003328U, 14730392192U, 14738784128U, + 14747172736U, 14755561088U, 14763947648U, 14772336512U, 14780725376U, + 14789110144U, 14797499776U, 14805892736U, 14814276992U, 14822670208U, + 14831056256U, 14839444352U, 14847836032U, 14856222848U, 14864612992U, + 14872997504U, 14881388672U, 14889775744U, 14898165376U, 14906553472U, + 14914944896U, 14923329664U, 14931721856U, 14940109696U, 14948497024U, + 14956887424U, 14965276544U, 14973663616U, 14982053248U, 14990439808U, + 14998830976U, 15007216768U, 15015605888U, 15023995264U, 15032385152U, + 15040768384U, 15049154944U, 15057549184U, 15065939072U, 15074328448U, + 15082715008U, 15091104128U, 15099493504U, 15107879296U, 15116269184U, + 15124659584U, 15133042304U, 15141431936U, 15149824384U, 15158214272U, + 15166602368U, 15174991232U, 15183378304U, 15191760512U, 15200154496U, + 15208542592U, 15216931712U, 15225323392U, 15233708416U, 15242098048U, + 15250489216U, 15258875264U, 15267265408U, 15275654528U, 15284043136U, + 15292431488U, 15300819584U, 15309208192U, 15317596544U, 15325986176U, + 15334374784U, 15342763648U, 15351151744U, 15359540608U, 15367929728U, + 15376318336U, 15384706432U, 15393092992U, 15401481856U, 15409869952U, + 15418258816U, 15426649984U, 15435037568U, 15443425664U, 15451815296U, + 15460203392U, 15468589184U, 15476979328U, 15485369216U, 15493755776U, + 15502146944U, 15510534272U, 15518924416U, 15527311232U, 15535699072U, + 15544089472U, 15552478336U, 15560866688U, 15569254528U, 15577642624U, + 15586031488U, 15594419072U, 15602809472U, 15611199104U, 15619586432U, + 15627975296U, 15636364928U, 15644753792U, 15653141888U, 15661529216U, + 15669918848U, 15678305152U, 15686696576U, 15695083136U, 15703474048U, + 15711861632U, 15720251264U, 15728636288U, 15737027456U, 15745417088U, + 15753804928U, 15762194048U, 15770582656U, 15778971008U, 15787358336U, + 15795747712U, 15804132224U, 15812523392U, 15820909696U, 15829300096U, + 15837691264U, 15846071936U, 15854466944U, 15862855808U, 15871244672U, + 15879634816U, 15888020608U, 15896409728U, 15904799104U, 15913185152U, + 15921577088U, 15929966464U, 15938354816U, 15946743424U, 15955129472U, + 15963519872U, 15971907968U, 15980296064U, 15988684928U, 15997073024U, + 16005460864U, 16013851264U, 16022241152U, 16030629248U, 16039012736U, + 16047406976U, 16055794816U, 16064181376U, 16072571264U, 16080957824U, + 16089346688U, 16097737856U, 16106125184U, 16114514816U, 16122904192U, + 16131292544U, 16139678848U, 16148066944U, 16156453504U, 16164839552U, + 16173236096U, 16181623424U, 16190012032U, 16198401152U, 16206790528U, + 16215177344U, 16223567744U, 16231956352U, 16240344704U, 16248731008U, + 16257117824U, 16265504384U, 16273898624U, 16282281856U, 16290668672U, + 16299064192U, 16307449216U, 16315842176U, 16324230016U, 16332613504U, + 16341006464U, 16349394304U, 16357783168U, 16366172288U, 16374561664U, + 16382951296U, 16391337856U, 16399726208U, 16408116352U, 16416505472U, + 16424892032U, 16433282176U, 16441668224U, 16450058624U, 16458448768U, + 16466836864U, 16475224448U, 16483613056U, 16492001408U, 16500391808U, + 16508779648U, 16517166976U, 16525555328U, 16533944192U, 16542330752U, + 16550719616U, 16559110528U, 16567497088U, 16575888512U, 16584274816U, + 16592665472U, 16601051008U, 16609442944U, 16617832064U, 16626218624U, + 16634607488U, 16642996096U, 16651385728U, 16659773824U, 16668163712U, + 16676552576U, 16684938112U, 16693328768U, 16701718144U, 16710095488U, + 16718492288U, 16726883968U, 16735272832U, 16743661184U, 16752049792U, + 16760436608U, 16768827008U, 16777214336U, 16785599104U, 16793992832U, + 16802381696U, 16810768768U, 16819151744U, 16827542656U, 16835934848U, + 16844323712U, 16852711552U, 16861101952U, 16869489536U, 16877876864U, + 16886265728U, 16894653056U, 16903044736U, 16911431296U, 16919821696U, + 16928207488U, 16936592768U, 16944987776U, 16953375616U, 16961763968U, + 16970152832U, 16978540928U, 16986929536U, 16995319168U, 17003704448U, + 17012096896U, 17020481152U, 17028870784U, 17037262208U, 17045649536U, + 17054039936U, 17062426496U, 17070814336U, 17079205504U, 17087592064U, + 17095978112U, 17104369024U, 17112759424U, 17121147776U, 17129536384U, + 17137926016U, 17146314368U, 17154700928U, 17163089792U, 17171480192U, + 17179864192U, 17188256896U, 17196644992U, 17205033856U, 17213423488U, + 17221811072U, 17230198912U, 17238588032U, 17246976896U, 17255360384U, + 17263754624U, 17272143232U, 17280530048U, 17288918912U, 17297309312U, + 17305696384U, 17314085504U, 17322475136U, 17330863744U, 17339252096U, + 17347640192U, 17356026496U, 17364413824U, 17372796544U, 17381190016U, + 17389583488U, 17397972608U, 17406360704U, 17414748544U, 17423135872U, + 17431527296U, 17439915904U, 17448303232U, 17456691584U, 17465081728U, + 17473468288U, 17481857408U, 17490247552U, 17498635904U, 17507022464U, + 17515409024U, 17523801728U, 17532189824U, 17540577664U, 17548966016U, + 17557353344U, 17565741184U, 17574131584U, 17582519168U, 17590907008U, + 17599296128U, 17607687808U, 17616076672U, 17624455808U, 17632852352U, + 17641238656U, 17649630848U, 17658018944U, 17666403968U, 17674794112U, + 17683178368U, 17691573376U, 17699962496U, 17708350592U, 17716739968U, + 17725126528U, 17733517184U, 17741898112U, 17750293888U, 17758673024U, + 17767070336U, 17775458432U, 17783848832U, 17792236928U, 17800625536U, + 17809012352U, 17817402752U, 17825785984U, 17834178944U, 17842563968U, + 17850955648U, 17859344512U, 17867732864U, 17876119424U, 17884511872U, + 17892900224U, 17901287296U, 17909677696U, 17918058112U, 17926451072U, + 17934843776U, 17943230848U, 17951609216U, 17960008576U, 17968397696U, + 17976784256U, 17985175424U, 17993564032U, 18001952128U, 18010339712U, + 18018728576U, 18027116672U, 18035503232U, 18043894144U, 18052283264U, + 18060672128U, 18069056384U, 18077449856U, 18085837184U, 18094225792U, + 18102613376U, 18111004544U, 18119388544U, 18127781248U, 18136170368U, + 18144558976U, 18152947328U, 18161336192U, 18169724288U, 18178108544U, + 18186498944U, 18194886784U, 18203275648U, 18211666048U, 18220048768U, + 18228444544U, 18236833408U, 18245220736U }; @@ -478,333 +478,333 @@ static const uint64_t dag_sizes[2048] = { // Sow[i*HashBytes]; j++]]]][[2]][[1]] const uint64_t cache_sizes[2048] = { - 16776896U, 16907456U, 17039296U, 17170112U, 17301056U, 17432512U, 17563072U, - 17693888U, 17824192U, 17955904U, 18087488U, 18218176U, 18349504U, 18481088U, - 18611392U, 18742336U, 18874304U, 19004224U, 19135936U, 19267264U, 19398208U, - 19529408U, 19660096U, 19791424U, 19922752U, 20053952U, 20184896U, 20315968U, - 20446912U, 20576576U, 20709184U, 20840384U, 20971072U, 21102272U, 21233216U, - 21364544U, 21494848U, 21626816U, 21757376U, 21887552U, 22019392U, 22151104U, - 22281536U, 22412224U, 22543936U, 22675264U, 22806464U, 22935872U, 23068096U, - 23198272U, 23330752U, 23459008U, 23592512U, 23723968U, 23854912U, 23986112U, - 24116672U, 24247616U, 24378688U, 24509504U, 24640832U, 24772544U, 24903488U, - 25034432U, 25165376U, 25296704U, 25427392U, 25558592U, 25690048U, 25820096U, - 25951936U, 26081728U, 26214208U, 26345024U, 26476096U, 26606656U, 26737472U, - 26869184U, 26998208U, 27131584U, 27262528U, 27393728U, 27523904U, 27655744U, - 27786688U, 27917888U, 28049344U, 28179904U, 28311488U, 28441792U, 28573504U, - 28700864U, 28835648U, 28966208U, 29096768U, 29228608U, 29359808U, 29490752U, - 29621824U, 29752256U, 29882816U, 30014912U, 30144448U, 30273728U, 30406976U, - 30538432U, 30670784U, 30799936U, 30932672U, 31063744U, 31195072U, 31325248U, - 31456192U, 31588288U, 31719232U, 31850432U, 31981504U, 32110784U, 32243392U, - 32372672U, 32505664U, 32636608U, 32767808U, 32897344U, 33029824U, 33160768U, - 33289664U, 33423296U, 33554368U, 33683648U, 33816512U, 33947456U, 34076992U, - 34208704U, 34340032U, 34471744U, 34600256U, 34734016U, 34864576U, 34993984U, - 35127104U, 35258176U, 35386688U, 35518528U, 35650624U, 35782336U, 35910976U, - 36044608U, 36175808U, 36305728U, 36436672U, 36568384U, 36699968U, 36830656U, - 36961984U, 37093312U, 37223488U, 37355072U, 37486528U, 37617472U, 37747904U, - 37879232U, 38009792U, 38141888U, 38272448U, 38403392U, 38535104U, 38660672U, - 38795584U, 38925632U, 39059264U, 39190336U, 39320768U, 39452096U, 39581632U, - 39713984U, 39844928U, 39974848U, 40107968U, 40238144U, 40367168U, 40500032U, - 40631744U, 40762816U, 40894144U, 41023552U, 41155904U, 41286208U, 41418304U, - 41547712U, 41680448U, 41811904U, 41942848U, 42073792U, 42204992U, 42334912U, - 42467008U, 42597824U, 42729152U, 42860096U, 42991552U, 43122368U, 43253696U, - 43382848U, 43515712U, 43646912U, 43777088U, 43907648U, 44039104U, 44170432U, - 44302144U, 44433344U, 44564288U, 44694976U, 44825152U, 44956864U, 45088448U, - 45219008U, 45350464U, 45481024U, 45612608U, 45744064U, 45874496U, 46006208U, - 46136768U, 46267712U, 46399424U, 46529344U, 46660672U, 46791488U, 46923328U, - 47053504U, 47185856U, 47316928U, 47447872U, 47579072U, 47710144U, 47839936U, - 47971648U, 48103232U, 48234176U, 48365248U, 48496192U, 48627136U, 48757312U, - 48889664U, 49020736U, 49149248U, 49283008U, 49413824U, 49545152U, 49675712U, - 49807168U, 49938368U, 50069056U, 50200256U, 50331584U, 50462656U, 50593472U, - 50724032U, 50853952U, 50986048U, 51117632U, 51248576U, 51379904U, 51510848U, - 51641792U, 51773248U, 51903296U, 52035136U, 52164032U, 52297664U, 52427968U, - 52557376U, 52690112U, 52821952U, 52952896U, 53081536U, 53213504U, 53344576U, - 53475776U, 53608384U, 53738816U, 53870528U, 54000832U, 54131776U, 54263744U, - 54394688U, 54525248U, 54655936U, 54787904U, 54918592U, 55049152U, 55181248U, - 55312064U, 55442752U, 55574336U, 55705024U, 55836224U, 55967168U, 56097856U, - 56228672U, 56358592U, 56490176U, 56621888U, 56753728U, 56884928U, 57015488U, - 57146816U, 57278272U, 57409216U, 57540416U, 57671104U, 57802432U, 57933632U, - 58064576U, 58195264U, 58326976U, 58457408U, 58588864U, 58720192U, 58849984U, - 58981696U, 59113024U, 59243456U, 59375552U, 59506624U, 59637568U, 59768512U, - 59897792U, 60030016U, 60161984U, 60293056U, 60423872U, 60554432U, 60683968U, - 60817216U, 60948032U, 61079488U, 61209664U, 61341376U, 61471936U, 61602752U, - 61733696U, 61865792U, 61996736U, 62127808U, 62259136U, 62389568U, 62520512U, - 62651584U, 62781632U, 62910784U, 63045056U, 63176128U, 63307072U, 63438656U, - 63569216U, 63700928U, 63831616U, 63960896U, 64093888U, 64225088U, 64355392U, - 64486976U, 64617664U, 64748608U, 64879424U, 65009216U, 65142464U, 65273792U, - 65402816U, 65535424U, 65666752U, 65797696U, 65927744U, 66060224U, 66191296U, - 66321344U, 66453056U, 66584384U, 66715328U, 66846656U, 66977728U, 67108672U, - 67239104U, 67370432U, 67501888U, 67631296U, 67763776U, 67895104U, 68026304U, - 68157248U, 68287936U, 68419264U, 68548288U, 68681408U, 68811968U, 68942912U, - 69074624U, 69205568U, 69337024U, 69467584U, 69599168U, 69729472U, 69861184U, - 69989824U, 70122944U, 70253888U, 70385344U, 70515904U, 70647232U, 70778816U, - 70907968U, 71040832U, 71171648U, 71303104U, 71432512U, 71564992U, 71695168U, - 71826368U, 71958464U, 72089536U, 72219712U, 72350144U, 72482624U, 72613568U, - 72744512U, 72875584U, 73006144U, 73138112U, 73268672U, 73400128U, 73530944U, - 73662272U, 73793344U, 73924544U, 74055104U, 74185792U, 74316992U, 74448832U, - 74579392U, 74710976U, 74841664U, 74972864U, 75102784U, 75233344U, 75364544U, - 75497024U, 75627584U, 75759296U, 75890624U, 76021696U, 76152256U, 76283072U, - 76414144U, 76545856U, 76676672U, 76806976U, 76937792U, 77070016U, 77200832U, - 77331392U, 77462464U, 77593664U, 77725376U, 77856448U, 77987776U, 78118336U, - 78249664U, 78380992U, 78511424U, 78642496U, 78773056U, 78905152U, 79033664U, - 79166656U, 79297472U, 79429568U, 79560512U, 79690816U, 79822784U, 79953472U, - 80084672U, 80214208U, 80346944U, 80477632U, 80608576U, 80740288U, 80870848U, - 81002048U, 81133504U, 81264448U, 81395648U, 81525952U, 81657536U, 81786304U, - 81919808U, 82050112U, 82181312U, 82311616U, 82443968U, 82573376U, 82705984U, - 82835776U, 82967744U, 83096768U, 83230528U, 83359552U, 83491264U, 83622464U, - 83753536U, 83886016U, 84015296U, 84147776U, 84277184U, 84409792U, 84540608U, - 84672064U, 84803008U, 84934336U, 85065152U, 85193792U, 85326784U, 85458496U, - 85589312U, 85721024U, 85851968U, 85982656U, 86112448U, 86244416U, 86370112U, - 86506688U, 86637632U, 86769344U, 86900672U, 87031744U, 87162304U, 87293632U, - 87424576U, 87555392U, 87687104U, 87816896U, 87947968U, 88079168U, 88211264U, - 88341824U, 88473152U, 88603712U, 88735424U, 88862912U, 88996672U, 89128384U, - 89259712U, 89390272U, 89521984U, 89652544U, 89783872U, 89914816U, 90045376U, - 90177088U, 90307904U, 90438848U, 90569152U, 90700096U, 90832832U, 90963776U, - 91093696U, 91223744U, 91356992U, 91486784U, 91618496U, 91749824U, 91880384U, - 92012224U, 92143552U, 92273344U, 92405696U, 92536768U, 92666432U, 92798912U, - 92926016U, 93060544U, 93192128U, 93322816U, 93453632U, 93583936U, 93715136U, - 93845056U, 93977792U, 94109504U, 94240448U, 94371776U, 94501184U, 94632896U, - 94764224U, 94895552U, 95023424U, 95158208U, 95287744U, 95420224U, 95550016U, - 95681216U, 95811904U, 95943872U, 96075328U, 96203584U, 96337856U, 96468544U, - 96599744U, 96731072U, 96860992U, 96992576U, 97124288U, 97254848U, 97385536U, - 97517248U, 97647808U, 97779392U, 97910464U, 98041408U, 98172608U, 98303168U, - 98434496U, 98565568U, 98696768U, 98827328U, 98958784U, 99089728U, 99220928U, - 99352384U, 99482816U, 99614272U, 99745472U, 99876416U, 100007104U, - 100138048U, 100267072U, 100401088U, 100529984U, 100662592U, 100791872U, - 100925248U, 101056064U, 101187392U, 101317952U, 101449408U, 101580608U, - 101711296U, 101841728U, 101973824U, 102104896U, 102235712U, 102366016U, - 102498112U, 102628672U, 102760384U, 102890432U, 103021888U, 103153472U, - 103284032U, 103415744U, 103545152U, 103677248U, 103808576U, 103939648U, - 104070976U, 104201792U, 104332736U, 104462528U, 104594752U, 104725952U, - 104854592U, 104988608U, 105118912U, 105247808U, 105381184U, 105511232U, - 105643072U, 105774784U, 105903296U, 106037056U, 106167872U, 106298944U, - 106429504U, 106561472U, 106691392U, 106822592U, 106954304U, 107085376U, - 107216576U, 107346368U, 107478464U, 107609792U, 107739712U, 107872192U, - 108003136U, 108131392U, 108265408U, 108396224U, 108527168U, 108657344U, - 108789568U, 108920384U, 109049792U, 109182272U, 109312576U, 109444928U, - 109572928U, 109706944U, 109837888U, 109969088U, 110099648U, 110230976U, - 110362432U, 110492992U, 110624704U, 110755264U, 110886208U, 111017408U, - 111148864U, 111279296U, 111410752U, 111541952U, 111673024U, 111803456U, - 111933632U, 112066496U, 112196416U, 112328512U, 112457792U, 112590784U, - 112715968U, 112852672U, 112983616U, 113114944U, 113244224U, 113376448U, - 113505472U, 113639104U, 113770304U, 113901376U, 114031552U, 114163264U, - 114294592U, 114425536U, 114556864U, 114687424U, 114818624U, 114948544U, - 115080512U, 115212224U, 115343296U, 115473472U, 115605184U, 115736128U, - 115867072U, 115997248U, 116128576U, 116260288U, 116391488U, 116522944U, - 116652992U, 116784704U, 116915648U, 117046208U, 117178304U, 117308608U, - 117440192U, 117569728U, 117701824U, 117833024U, 117964096U, 118094656U, - 118225984U, 118357312U, 118489024U, 118617536U, 118749632U, 118882112U, - 119012416U, 119144384U, 119275328U, 119406016U, 119537344U, 119668672U, - 119798464U, 119928896U, 120061376U, 120192832U, 120321728U, 120454336U, - 120584512U, 120716608U, 120848192U, 120979136U, 121109056U, 121241408U, - 121372352U, 121502912U, 121634752U, 121764416U, 121895744U, 122027072U, - 122157632U, 122289088U, 122421184U, 122550592U, 122682944U, 122813888U, - 122945344U, 123075776U, 123207488U, 123338048U, 123468736U, 123600704U, - 123731264U, 123861952U, 123993664U, 124124608U, 124256192U, 124386368U, - 124518208U, 124649024U, 124778048U, 124911296U, 125041088U, 125173696U, - 125303744U, 125432896U, 125566912U, 125696576U, 125829056U, 125958592U, - 126090304U, 126221248U, 126352832U, 126483776U, 126615232U, 126746432U, - 126876608U, 127008704U, 127139392U, 127270336U, 127401152U, 127532224U, - 127663552U, 127794752U, 127925696U, 128055232U, 128188096U, 128319424U, - 128449856U, 128581312U, 128712256U, 128843584U, 128973632U, 129103808U, - 129236288U, 129365696U, 129498944U, 129629888U, 129760832U, 129892288U, - 130023104U, 130154048U, 130283968U, 130416448U, 130547008U, 130678336U, - 130807616U, 130939456U, 131071552U, 131202112U, 131331776U, 131464384U, - 131594048U, 131727296U, 131858368U, 131987392U, 132120256U, 132250816U, - 132382528U, 132513728U, 132644672U, 132774976U, 132905792U, 133038016U, - 133168832U, 133299392U, 133429312U, 133562048U, 133692992U, 133823296U, - 133954624U, 134086336U, 134217152U, 134348608U, 134479808U, 134607296U, - 134741056U, 134872384U, 135002944U, 135134144U, 135265472U, 135396544U, - 135527872U, 135659072U, 135787712U, 135921472U, 136052416U, 136182848U, - 136313792U, 136444864U, 136576448U, 136707904U, 136837952U, 136970048U, - 137099584U, 137232064U, 137363392U, 137494208U, 137625536U, 137755712U, - 137887424U, 138018368U, 138149824U, 138280256U, 138411584U, 138539584U, - 138672832U, 138804928U, 138936128U, 139066688U, 139196864U, 139328704U, - 139460032U, 139590208U, 139721024U, 139852864U, 139984576U, 140115776U, - 140245696U, 140376512U, 140508352U, 140640064U, 140769856U, 140902336U, - 141032768U, 141162688U, 141294016U, 141426496U, 141556544U, 141687488U, - 141819584U, 141949888U, 142080448U, 142212544U, 142342336U, 142474432U, - 142606144U, 142736192U, 142868288U, 142997824U, 143129408U, 143258944U, - 143392448U, 143523136U, 143653696U, 143785024U, 143916992U, 144045632U, - 144177856U, 144309184U, 144440768U, 144570688U, 144701888U, 144832448U, - 144965056U, 145096384U, 145227584U, 145358656U, 145489856U, 145620928U, - 145751488U, 145883072U, 146011456U, 146144704U, 146275264U, 146407232U, - 146538176U, 146668736U, 146800448U, 146931392U, 147062336U, 147193664U, - 147324224U, 147455936U, 147586624U, 147717056U, 147848768U, 147979456U, - 148110784U, 148242368U, 148373312U, 148503232U, 148635584U, 148766144U, - 148897088U, 149028416U, 149159488U, 149290688U, 149420224U, 149551552U, - 149683136U, 149814976U, 149943616U, 150076352U, 150208064U, 150338624U, - 150470464U, 150600256U, 150732224U, 150862784U, 150993088U, 151125952U, - 151254976U, 151388096U, 151519168U, 151649728U, 151778752U, 151911104U, - 152042944U, 152174144U, 152304704U, 152435648U, 152567488U, 152698816U, - 152828992U, 152960576U, 153091648U, 153222976U, 153353792U, 153484096U, - 153616192U, 153747008U, 153878336U, 154008256U, 154139968U, 154270912U, - 154402624U, 154533824U, 154663616U, 154795712U, 154926272U, 155057984U, - 155188928U, 155319872U, 155450816U, 155580608U, 155712064U, 155843392U, - 155971136U, 156106688U, 156237376U, 156367424U, 156499264U, 156630976U, - 156761536U, 156892352U, 157024064U, 157155008U, 157284416U, 157415872U, - 157545536U, 157677248U, 157810496U, 157938112U, 158071744U, 158203328U, - 158334656U, 158464832U, 158596288U, 158727616U, 158858048U, 158988992U, - 159121216U, 159252416U, 159381568U, 159513152U, 159645632U, 159776192U, - 159906496U, 160038464U, 160169536U, 160300352U, 160430656U, 160563008U, - 160693952U, 160822208U, 160956352U, 161086784U, 161217344U, 161349184U, - 161480512U, 161611456U, 161742272U, 161873216U, 162002752U, 162135872U, - 162266432U, 162397888U, 162529216U, 162660032U, 162790976U, 162922048U, - 163052096U, 163184576U, 163314752U, 163446592U, 163577408U, 163707968U, - 163839296U, 163969984U, 164100928U, 164233024U, 164364224U, 164494912U, - 164625856U, 164756672U, 164887616U, 165019072U, 165150016U, 165280064U, - 165412672U, 165543104U, 165674944U, 165805888U, 165936832U, 166067648U, - 166198336U, 166330048U, 166461248U, 166591552U, 166722496U, 166854208U, - 166985408U, 167116736U, 167246656U, 167378368U, 167508416U, 167641024U, - 167771584U, 167903168U, 168034112U, 168164032U, 168295744U, 168427456U, - 168557632U, 168688448U, 168819136U, 168951616U, 169082176U, 169213504U, - 169344832U, 169475648U, 169605952U, 169738048U, 169866304U, 169999552U, - 170131264U, 170262464U, 170393536U, 170524352U, 170655424U, 170782016U, - 170917696U, 171048896U, 171179072U, 171310784U, 171439936U, 171573184U, - 171702976U, 171835072U, 171966272U, 172097216U, 172228288U, 172359232U, - 172489664U, 172621376U, 172747712U, 172883264U, 173014208U, 173144512U, - 173275072U, 173407424U, 173539136U, 173669696U, 173800768U, 173931712U, - 174063424U, 174193472U, 174325696U, 174455744U, 174586816U, 174718912U, - 174849728U, 174977728U, 175109696U, 175242688U, 175374272U, 175504832U, - 175636288U, 175765696U, 175898432U, 176028992U, 176159936U, 176291264U, - 176422592U, 176552512U, 176684864U, 176815424U, 176946496U, 177076544U, - 177209152U, 177340096U, 177470528U, 177600704U, 177731648U, 177864256U, - 177994816U, 178126528U, 178257472U, 178387648U, 178518464U, 178650176U, - 178781888U, 178912064U, 179044288U, 179174848U, 179305024U, 179436736U, - 179568448U, 179698496U, 179830208U, 179960512U, 180092608U, 180223808U, - 180354752U, 180485696U, 180617152U, 180748096U, 180877504U, 181009984U, - 181139264U, 181272512U, 181402688U, 181532608U, 181663168U, 181795136U, - 181926592U, 182057536U, 182190016U, 182320192U, 182451904U, 182582336U, - 182713792U, 182843072U, 182976064U, 183107264U, 183237056U, 183368384U, - 183494848U, 183631424U, 183762752U, 183893824U, 184024768U, 184154816U, - 184286656U, 184417984U, 184548928U, 184680128U, 184810816U, 184941248U, - 185072704U, 185203904U, 185335616U, 185465408U, 185596352U, 185727296U, - 185859904U, 185989696U, 186121664U, 186252992U, 186383552U, 186514112U, - 186645952U, 186777152U, 186907328U, 187037504U, 187170112U, 187301824U, - 187429184U, 187562048U, 187693504U, 187825472U, 187957184U, 188087104U, - 188218304U, 188349376U, 188481344U, 188609728U, 188743616U, 188874304U, - 189005248U, 189136448U, 189265088U, 189396544U, 189528128U, 189660992U, - 189791936U, 189923264U, 190054208U, 190182848U, 190315072U, 190447424U, - 190577984U, 190709312U, 190840768U, 190971328U, 191102656U, 191233472U, - 191364032U, 191495872U, 191626816U, 191758016U, 191888192U, 192020288U, - 192148928U, 192282176U, 192413504U, 192542528U, 192674752U, 192805952U, - 192937792U, 193068608U, 193198912U, 193330496U, 193462208U, 193592384U, - 193723456U, 193854272U, 193985984U, 194116672U, 194247232U, 194379712U, - 194508352U, 194641856U, 194772544U, 194900672U, 195035072U, 195166016U, - 195296704U, 195428032U, 195558592U, 195690304U, 195818176U, 195952576U, - 196083392U, 196214336U, 196345792U, 196476736U, 196607552U, 196739008U, - 196869952U, 197000768U, 197130688U, 197262784U, 197394368U, 197523904U, - 197656384U, 197787584U, 197916608U, 198049472U, 198180544U, 198310208U, - 198442432U, 198573632U, 198705088U, 198834368U, 198967232U, 199097792U, - 199228352U, 199360192U, 199491392U, 199621696U, 199751744U, 199883968U, - 200014016U, 200146624U, 200276672U, 200408128U, 200540096U, 200671168U, - 200801984U, 200933312U, 201062464U, 201194944U, 201326144U, 201457472U, - 201588544U, 201719744U, 201850816U, 201981632U, 202111552U, 202244032U, - 202374464U, 202505152U, 202636352U, 202767808U, 202898368U, 203030336U, - 203159872U, 203292608U, 203423296U, 203553472U, 203685824U, 203816896U, - 203947712U, 204078272U, 204208192U, 204341056U, 204472256U, 204603328U, - 204733888U, 204864448U, 204996544U, 205125568U, 205258304U, 205388864U, - 205517632U, 205650112U, 205782208U, 205913536U, 206044736U, 206176192U, - 206307008U, 206434496U, 206569024U, 206700224U, 206831168U, 206961856U, - 207093056U, 207223616U, 207355328U, 207486784U, 207616832U, 207749056U, - 207879104U, 208010048U, 208141888U, 208273216U, 208404032U, 208534336U, - 208666048U, 208796864U, 208927424U, 209059264U, 209189824U, 209321792U, - 209451584U, 209582656U, 209715136U, 209845568U, 209976896U, 210106432U, - 210239296U, 210370112U, 210501568U, 210630976U, 210763712U, 210894272U, - 211024832U, 211156672U, 211287616U, 211418176U, 211549376U, 211679296U, - 211812032U, 211942592U, 212074432U, 212204864U, 212334016U, 212467648U, - 212597824U, 212727616U, 212860352U, 212991424U, 213120832U, 213253952U, - 213385024U, 213515584U, 213645632U, 213777728U, 213909184U, 214040128U, - 214170688U, 214302656U, 214433728U, 214564544U, 214695232U, 214826048U, - 214956992U, 215089088U, 215219776U, 215350592U, 215482304U, 215613248U, - 215743552U, 215874752U, 216005312U, 216137024U, 216267328U, 216399296U, - 216530752U, 216661696U, 216790592U, 216923968U, 217054528U, 217183168U, - 217316672U, 217448128U, 217579072U, 217709504U, 217838912U, 217972672U, - 218102848U, 218233024U, 218364736U, 218496832U, 218627776U, 218759104U, - 218888896U, 219021248U, 219151936U, 219281728U, 219413056U, 219545024U, - 219675968U, 219807296U, 219938624U, 220069312U, 220200128U, 220331456U, - 220461632U, 220592704U, 220725184U, 220855744U, 220987072U, 221117888U, - 221249216U, 221378368U, 221510336U, 221642048U, 221772736U, 221904832U, - 222031808U, 222166976U, 222297536U, 222428992U, 222559936U, 222690368U, - 222820672U, 222953152U, 223083968U, 223213376U, 223345984U, 223476928U, - 223608512U, 223738688U, 223869376U, 224001472U, 224132672U, 224262848U, - 224394944U, 224524864U, 224657344U, 224788288U, 224919488U, 225050432U, - 225181504U, 225312704U, 225443776U, 225574592U, 225704768U, 225834176U, - 225966784U, 226097216U, 226229824U, 226360384U, 226491712U, 226623424U, - 226754368U, 226885312U, 227015104U, 227147456U, 227278528U, 227409472U, - 227539904U, 227669696U, 227802944U, 227932352U, 228065216U, 228196288U, - 228326464U, 228457792U, 228588736U, 228720064U, 228850112U, 228981056U, - 229113152U, 229243328U, 229375936U, 229505344U, 229636928U, 229769152U, - 229894976U, 230030272U, 230162368U, 230292416U, 230424512U, 230553152U, - 230684864U, 230816704U, 230948416U, 231079616U, 231210944U, 231342016U, - 231472448U, 231603776U, 231733952U, 231866176U, 231996736U, 232127296U, - 232259392U, 232388672U, 232521664U, 232652608U, 232782272U, 232914496U, - 233043904U, 233175616U, 233306816U, 233438528U, 233569984U, 233699776U, - 233830592U, 233962688U, 234092224U, 234221888U, 234353984U, 234485312U, - 234618304U, 234749888U, 234880832U, 235011776U, 235142464U, 235274048U, - 235403456U, 235535936U, 235667392U, 235797568U, 235928768U, 236057152U, - 236190272U, 236322752U, 236453312U, 236583616U, 236715712U, 236846528U, - 236976448U, 237108544U, 237239104U, 237371072U, 237501632U, 237630784U, - 237764416U, 237895232U, 238026688U, 238157632U, 238286912U, 238419392U, - 238548032U, 238681024U, 238812608U, 238941632U, 239075008U, 239206336U, - 239335232U, 239466944U, 239599168U, 239730496U, 239861312U, 239992384U, - 240122816U, 240254656U, 240385856U, 240516928U, 240647872U, 240779072U, - 240909632U, 241040704U, 241171904U, 241302848U, 241433408U, 241565248U, - 241696192U, 241825984U, 241958848U, 242088256U, 242220224U, 242352064U, - 242481856U, 242611648U, 242744896U, 242876224U, 243005632U, 243138496U, - 243268672U, 243400384U, 243531712U, 243662656U, 243793856U, 243924544U, - 244054592U, 244187072U, 244316608U, 244448704U, 244580032U, 244710976U, - 244841536U, 244972864U, 245104448U, 245233984U, 245365312U, 245497792U, - 245628736U, 245759936U, 245889856U, 246021056U, 246152512U, 246284224U, - 246415168U, 246545344U, 246675904U, 246808384U, 246939584U, 247070144U, - 247199552U, 247331648U, 247463872U, 247593536U, 247726016U, 247857088U, - 247987648U, 248116928U, 248249536U, 248380736U, 248512064U, 248643008U, - 248773312U, 248901056U, 249036608U, 249167552U, 249298624U, 249429184U, - 249560512U, 249692096U, 249822784U, 249954112U, 250085312U, 250215488U, - 250345792U, 250478528U, 250608704U, 250739264U, 250870976U, 251002816U, - 251133632U, 251263552U, 251395136U, 251523904U, 251657792U, 251789248U, - 251919424U, 252051392U, 252182464U, 252313408U, 252444224U, 252575552U, - 252706624U, 252836032U, 252968512U, 253099712U, 253227584U, 253361728U, - 253493056U, 253623488U, 253754432U, 253885504U, 254017216U, 254148032U, - 254279488U, 254410432U, 254541376U, 254672576U, 254803264U, 254933824U, - 255065792U, 255196736U, 255326528U, 255458752U, 255589952U, 255721408U, - 255851072U, 255983296U, 256114624U, 256244416U, 256374208U, 256507712U, - 256636096U, 256768832U, 256900544U, 257031616U, 257162176U, 257294272U, - 257424448U, 257555776U, 257686976U, 257818432U, 257949632U, 258079552U, - 258211136U, 258342464U, 258473408U, 258603712U, 258734656U, 258867008U, - 258996544U, 259127744U, 259260224U, 259391296U, 259522112U, 259651904U, - 259784384U, 259915328U, 260045888U, 260175424U, 260308544U, 260438336U, - 260570944U, 260700992U, 260832448U, 260963776U, 261092672U, 261226304U, - 261356864U, 261487936U, 261619648U, 261750592U, 261879872U, 262011968U, - 262143424U, 262274752U, 262404416U, 262537024U, 262667968U, 262799296U, - 262928704U, 263061184U, 263191744U, 263322944U, 263454656U, 263585216U, - 263716672U, 263847872U, 263978944U, 264108608U, 264241088U, 264371648U, - 264501184U, 264632768U, 264764096U, 264895936U, 265024576U, 265158464U, - 265287488U, 265418432U, 265550528U, 265681216U, 265813312U, 265943488U, - 266075968U, 266206144U, 266337728U, 266468032U, 266600384U, 266731072U, - 266862272U, 266993344U, 267124288U, 267255616U, 267386432U, 267516992U, - 267648704U, 267777728U, 267910592U, 268040512U, 268172096U, 268302784U, - 268435264U, 268566208U, 268696256U, 268828096U, 268959296U, 269090368U, - 269221312U, 269352256U, 269482688U, 269614784U, 269745856U, 269876416U, - 270007616U, 270139328U, 270270272U, 270401216U, 270531904U, 270663616U, - 270791744U, 270924736U, 271056832U, 271186112U, 271317184U, 271449536U, - 271580992U, 271711936U, 271843136U, 271973056U, 272105408U, 272236352U, - 272367296U, 272498368U, 272629568U, 272759488U, 272891456U, 273022784U, - 273153856U, 273284672U, 273415616U, 273547072U, 273677632U, 273808448U, - 273937088U, 274071488U, 274200896U, 274332992U, 274463296U, 274595392U, - 274726208U, 274857536U, 274988992U, 275118656U, 275250496U, 275382208U, - 275513024U, 275643968U, 275775296U, 275906368U, 276037184U, 276167872U, - 276297664U, 276429376U, 276560576U, 276692672U, 276822976U, 276955072U, - 277085632U, 277216832U, 277347008U, 277478848U, 277609664U, 277740992U, - 277868608U, 278002624U, 278134336U, 278265536U, 278395328U, 278526784U, - 278657728U, 278789824U, 278921152U, 279052096U, 279182912U, 279313088U, - 279443776U, 279576256U, 279706048U, 279838528U, 279969728U, 280099648U, - 280230976U, 280361408U, 280493632U, 280622528U, 280755392U, 280887104U, - 281018176U, 281147968U, 281278912U, 281411392U, 281542592U, 281673152U, - 281803712U, 281935552U, 282066496U, 282197312U, 282329024U, 282458816U, - 282590272U, 282720832U, 282853184U, 282983744U, 283115072U, 283246144U, - 283377344U, 283508416U, 283639744U, 283770304U, 283901504U, 284032576U, - 284163136U, 284294848U, 284426176U, 284556992U, 284687296U, 284819264U, - 284950208U, 285081536U + 16776896U, 16907456U, 17039296U, 17170112U, 17301056U, 17432512U, 17563072U, + 17693888U, 17824192U, 17955904U, 18087488U, 18218176U, 18349504U, 18481088U, + 18611392U, 18742336U, 18874304U, 19004224U, 19135936U, 19267264U, 19398208U, + 19529408U, 19660096U, 19791424U, 19922752U, 20053952U, 20184896U, 20315968U, + 20446912U, 20576576U, 20709184U, 20840384U, 20971072U, 21102272U, 21233216U, + 21364544U, 21494848U, 21626816U, 21757376U, 21887552U, 22019392U, 22151104U, + 22281536U, 22412224U, 22543936U, 22675264U, 22806464U, 22935872U, 23068096U, + 23198272U, 23330752U, 23459008U, 23592512U, 23723968U, 23854912U, 23986112U, + 24116672U, 24247616U, 24378688U, 24509504U, 24640832U, 24772544U, 24903488U, + 25034432U, 25165376U, 25296704U, 25427392U, 25558592U, 25690048U, 25820096U, + 25951936U, 26081728U, 26214208U, 26345024U, 26476096U, 26606656U, 26737472U, + 26869184U, 26998208U, 27131584U, 27262528U, 27393728U, 27523904U, 27655744U, + 27786688U, 27917888U, 28049344U, 28179904U, 28311488U, 28441792U, 28573504U, + 28700864U, 28835648U, 28966208U, 29096768U, 29228608U, 29359808U, 29490752U, + 29621824U, 29752256U, 29882816U, 30014912U, 30144448U, 30273728U, 30406976U, + 30538432U, 30670784U, 30799936U, 30932672U, 31063744U, 31195072U, 31325248U, + 31456192U, 31588288U, 31719232U, 31850432U, 31981504U, 32110784U, 32243392U, + 32372672U, 32505664U, 32636608U, 32767808U, 32897344U, 33029824U, 33160768U, + 33289664U, 33423296U, 33554368U, 33683648U, 33816512U, 33947456U, 34076992U, + 34208704U, 34340032U, 34471744U, 34600256U, 34734016U, 34864576U, 34993984U, + 35127104U, 35258176U, 35386688U, 35518528U, 35650624U, 35782336U, 35910976U, + 36044608U, 36175808U, 36305728U, 36436672U, 36568384U, 36699968U, 36830656U, + 36961984U, 37093312U, 37223488U, 37355072U, 37486528U, 37617472U, 37747904U, + 37879232U, 38009792U, 38141888U, 38272448U, 38403392U, 38535104U, 38660672U, + 38795584U, 38925632U, 39059264U, 39190336U, 39320768U, 39452096U, 39581632U, + 39713984U, 39844928U, 39974848U, 40107968U, 40238144U, 40367168U, 40500032U, + 40631744U, 40762816U, 40894144U, 41023552U, 41155904U, 41286208U, 41418304U, + 41547712U, 41680448U, 41811904U, 41942848U, 42073792U, 42204992U, 42334912U, + 42467008U, 42597824U, 42729152U, 42860096U, 42991552U, 43122368U, 43253696U, + 43382848U, 43515712U, 43646912U, 43777088U, 43907648U, 44039104U, 44170432U, + 44302144U, 44433344U, 44564288U, 44694976U, 44825152U, 44956864U, 45088448U, + 45219008U, 45350464U, 45481024U, 45612608U, 45744064U, 45874496U, 46006208U, + 46136768U, 46267712U, 46399424U, 46529344U, 46660672U, 46791488U, 46923328U, + 47053504U, 47185856U, 47316928U, 47447872U, 47579072U, 47710144U, 47839936U, + 47971648U, 48103232U, 48234176U, 48365248U, 48496192U, 48627136U, 48757312U, + 48889664U, 49020736U, 49149248U, 49283008U, 49413824U, 49545152U, 49675712U, + 49807168U, 49938368U, 50069056U, 50200256U, 50331584U, 50462656U, 50593472U, + 50724032U, 50853952U, 50986048U, 51117632U, 51248576U, 51379904U, 51510848U, + 51641792U, 51773248U, 51903296U, 52035136U, 52164032U, 52297664U, 52427968U, + 52557376U, 52690112U, 52821952U, 52952896U, 53081536U, 53213504U, 53344576U, + 53475776U, 53608384U, 53738816U, 53870528U, 54000832U, 54131776U, 54263744U, + 54394688U, 54525248U, 54655936U, 54787904U, 54918592U, 55049152U, 55181248U, + 55312064U, 55442752U, 55574336U, 55705024U, 55836224U, 55967168U, 56097856U, + 56228672U, 56358592U, 56490176U, 56621888U, 56753728U, 56884928U, 57015488U, + 57146816U, 57278272U, 57409216U, 57540416U, 57671104U, 57802432U, 57933632U, + 58064576U, 58195264U, 58326976U, 58457408U, 58588864U, 58720192U, 58849984U, + 58981696U, 59113024U, 59243456U, 59375552U, 59506624U, 59637568U, 59768512U, + 59897792U, 60030016U, 60161984U, 60293056U, 60423872U, 60554432U, 60683968U, + 60817216U, 60948032U, 61079488U, 61209664U, 61341376U, 61471936U, 61602752U, + 61733696U, 61865792U, 61996736U, 62127808U, 62259136U, 62389568U, 62520512U, + 62651584U, 62781632U, 62910784U, 63045056U, 63176128U, 63307072U, 63438656U, + 63569216U, 63700928U, 63831616U, 63960896U, 64093888U, 64225088U, 64355392U, + 64486976U, 64617664U, 64748608U, 64879424U, 65009216U, 65142464U, 65273792U, + 65402816U, 65535424U, 65666752U, 65797696U, 65927744U, 66060224U, 66191296U, + 66321344U, 66453056U, 66584384U, 66715328U, 66846656U, 66977728U, 67108672U, + 67239104U, 67370432U, 67501888U, 67631296U, 67763776U, 67895104U, 68026304U, + 68157248U, 68287936U, 68419264U, 68548288U, 68681408U, 68811968U, 68942912U, + 69074624U, 69205568U, 69337024U, 69467584U, 69599168U, 69729472U, 69861184U, + 69989824U, 70122944U, 70253888U, 70385344U, 70515904U, 70647232U, 70778816U, + 70907968U, 71040832U, 71171648U, 71303104U, 71432512U, 71564992U, 71695168U, + 71826368U, 71958464U, 72089536U, 72219712U, 72350144U, 72482624U, 72613568U, + 72744512U, 72875584U, 73006144U, 73138112U, 73268672U, 73400128U, 73530944U, + 73662272U, 73793344U, 73924544U, 74055104U, 74185792U, 74316992U, 74448832U, + 74579392U, 74710976U, 74841664U, 74972864U, 75102784U, 75233344U, 75364544U, + 75497024U, 75627584U, 75759296U, 75890624U, 76021696U, 76152256U, 76283072U, + 76414144U, 76545856U, 76676672U, 76806976U, 76937792U, 77070016U, 77200832U, + 77331392U, 77462464U, 77593664U, 77725376U, 77856448U, 77987776U, 78118336U, + 78249664U, 78380992U, 78511424U, 78642496U, 78773056U, 78905152U, 79033664U, + 79166656U, 79297472U, 79429568U, 79560512U, 79690816U, 79822784U, 79953472U, + 80084672U, 80214208U, 80346944U, 80477632U, 80608576U, 80740288U, 80870848U, + 81002048U, 81133504U, 81264448U, 81395648U, 81525952U, 81657536U, 81786304U, + 81919808U, 82050112U, 82181312U, 82311616U, 82443968U, 82573376U, 82705984U, + 82835776U, 82967744U, 83096768U, 83230528U, 83359552U, 83491264U, 83622464U, + 83753536U, 83886016U, 84015296U, 84147776U, 84277184U, 84409792U, 84540608U, + 84672064U, 84803008U, 84934336U, 85065152U, 85193792U, 85326784U, 85458496U, + 85589312U, 85721024U, 85851968U, 85982656U, 86112448U, 86244416U, 86370112U, + 86506688U, 86637632U, 86769344U, 86900672U, 87031744U, 87162304U, 87293632U, + 87424576U, 87555392U, 87687104U, 87816896U, 87947968U, 88079168U, 88211264U, + 88341824U, 88473152U, 88603712U, 88735424U, 88862912U, 88996672U, 89128384U, + 89259712U, 89390272U, 89521984U, 89652544U, 89783872U, 89914816U, 90045376U, + 90177088U, 90307904U, 90438848U, 90569152U, 90700096U, 90832832U, 90963776U, + 91093696U, 91223744U, 91356992U, 91486784U, 91618496U, 91749824U, 91880384U, + 92012224U, 92143552U, 92273344U, 92405696U, 92536768U, 92666432U, 92798912U, + 92926016U, 93060544U, 93192128U, 93322816U, 93453632U, 93583936U, 93715136U, + 93845056U, 93977792U, 94109504U, 94240448U, 94371776U, 94501184U, 94632896U, + 94764224U, 94895552U, 95023424U, 95158208U, 95287744U, 95420224U, 95550016U, + 95681216U, 95811904U, 95943872U, 96075328U, 96203584U, 96337856U, 96468544U, + 96599744U, 96731072U, 96860992U, 96992576U, 97124288U, 97254848U, 97385536U, + 97517248U, 97647808U, 97779392U, 97910464U, 98041408U, 98172608U, 98303168U, + 98434496U, 98565568U, 98696768U, 98827328U, 98958784U, 99089728U, 99220928U, + 99352384U, 99482816U, 99614272U, 99745472U, 99876416U, 100007104U, + 100138048U, 100267072U, 100401088U, 100529984U, 100662592U, 100791872U, + 100925248U, 101056064U, 101187392U, 101317952U, 101449408U, 101580608U, + 101711296U, 101841728U, 101973824U, 102104896U, 102235712U, 102366016U, + 102498112U, 102628672U, 102760384U, 102890432U, 103021888U, 103153472U, + 103284032U, 103415744U, 103545152U, 103677248U, 103808576U, 103939648U, + 104070976U, 104201792U, 104332736U, 104462528U, 104594752U, 104725952U, + 104854592U, 104988608U, 105118912U, 105247808U, 105381184U, 105511232U, + 105643072U, 105774784U, 105903296U, 106037056U, 106167872U, 106298944U, + 106429504U, 106561472U, 106691392U, 106822592U, 106954304U, 107085376U, + 107216576U, 107346368U, 107478464U, 107609792U, 107739712U, 107872192U, + 108003136U, 108131392U, 108265408U, 108396224U, 108527168U, 108657344U, + 108789568U, 108920384U, 109049792U, 109182272U, 109312576U, 109444928U, + 109572928U, 109706944U, 109837888U, 109969088U, 110099648U, 110230976U, + 110362432U, 110492992U, 110624704U, 110755264U, 110886208U, 111017408U, + 111148864U, 111279296U, 111410752U, 111541952U, 111673024U, 111803456U, + 111933632U, 112066496U, 112196416U, 112328512U, 112457792U, 112590784U, + 112715968U, 112852672U, 112983616U, 113114944U, 113244224U, 113376448U, + 113505472U, 113639104U, 113770304U, 113901376U, 114031552U, 114163264U, + 114294592U, 114425536U, 114556864U, 114687424U, 114818624U, 114948544U, + 115080512U, 115212224U, 115343296U, 115473472U, 115605184U, 115736128U, + 115867072U, 115997248U, 116128576U, 116260288U, 116391488U, 116522944U, + 116652992U, 116784704U, 116915648U, 117046208U, 117178304U, 117308608U, + 117440192U, 117569728U, 117701824U, 117833024U, 117964096U, 118094656U, + 118225984U, 118357312U, 118489024U, 118617536U, 118749632U, 118882112U, + 119012416U, 119144384U, 119275328U, 119406016U, 119537344U, 119668672U, + 119798464U, 119928896U, 120061376U, 120192832U, 120321728U, 120454336U, + 120584512U, 120716608U, 120848192U, 120979136U, 121109056U, 121241408U, + 121372352U, 121502912U, 121634752U, 121764416U, 121895744U, 122027072U, + 122157632U, 122289088U, 122421184U, 122550592U, 122682944U, 122813888U, + 122945344U, 123075776U, 123207488U, 123338048U, 123468736U, 123600704U, + 123731264U, 123861952U, 123993664U, 124124608U, 124256192U, 124386368U, + 124518208U, 124649024U, 124778048U, 124911296U, 125041088U, 125173696U, + 125303744U, 125432896U, 125566912U, 125696576U, 125829056U, 125958592U, + 126090304U, 126221248U, 126352832U, 126483776U, 126615232U, 126746432U, + 126876608U, 127008704U, 127139392U, 127270336U, 127401152U, 127532224U, + 127663552U, 127794752U, 127925696U, 128055232U, 128188096U, 128319424U, + 128449856U, 128581312U, 128712256U, 128843584U, 128973632U, 129103808U, + 129236288U, 129365696U, 129498944U, 129629888U, 129760832U, 129892288U, + 130023104U, 130154048U, 130283968U, 130416448U, 130547008U, 130678336U, + 130807616U, 130939456U, 131071552U, 131202112U, 131331776U, 131464384U, + 131594048U, 131727296U, 131858368U, 131987392U, 132120256U, 132250816U, + 132382528U, 132513728U, 132644672U, 132774976U, 132905792U, 133038016U, + 133168832U, 133299392U, 133429312U, 133562048U, 133692992U, 133823296U, + 133954624U, 134086336U, 134217152U, 134348608U, 134479808U, 134607296U, + 134741056U, 134872384U, 135002944U, 135134144U, 135265472U, 135396544U, + 135527872U, 135659072U, 135787712U, 135921472U, 136052416U, 136182848U, + 136313792U, 136444864U, 136576448U, 136707904U, 136837952U, 136970048U, + 137099584U, 137232064U, 137363392U, 137494208U, 137625536U, 137755712U, + 137887424U, 138018368U, 138149824U, 138280256U, 138411584U, 138539584U, + 138672832U, 138804928U, 138936128U, 139066688U, 139196864U, 139328704U, + 139460032U, 139590208U, 139721024U, 139852864U, 139984576U, 140115776U, + 140245696U, 140376512U, 140508352U, 140640064U, 140769856U, 140902336U, + 141032768U, 141162688U, 141294016U, 141426496U, 141556544U, 141687488U, + 141819584U, 141949888U, 142080448U, 142212544U, 142342336U, 142474432U, + 142606144U, 142736192U, 142868288U, 142997824U, 143129408U, 143258944U, + 143392448U, 143523136U, 143653696U, 143785024U, 143916992U, 144045632U, + 144177856U, 144309184U, 144440768U, 144570688U, 144701888U, 144832448U, + 144965056U, 145096384U, 145227584U, 145358656U, 145489856U, 145620928U, + 145751488U, 145883072U, 146011456U, 146144704U, 146275264U, 146407232U, + 146538176U, 146668736U, 146800448U, 146931392U, 147062336U, 147193664U, + 147324224U, 147455936U, 147586624U, 147717056U, 147848768U, 147979456U, + 148110784U, 148242368U, 148373312U, 148503232U, 148635584U, 148766144U, + 148897088U, 149028416U, 149159488U, 149290688U, 149420224U, 149551552U, + 149683136U, 149814976U, 149943616U, 150076352U, 150208064U, 150338624U, + 150470464U, 150600256U, 150732224U, 150862784U, 150993088U, 151125952U, + 151254976U, 151388096U, 151519168U, 151649728U, 151778752U, 151911104U, + 152042944U, 152174144U, 152304704U, 152435648U, 152567488U, 152698816U, + 152828992U, 152960576U, 153091648U, 153222976U, 153353792U, 153484096U, + 153616192U, 153747008U, 153878336U, 154008256U, 154139968U, 154270912U, + 154402624U, 154533824U, 154663616U, 154795712U, 154926272U, 155057984U, + 155188928U, 155319872U, 155450816U, 155580608U, 155712064U, 155843392U, + 155971136U, 156106688U, 156237376U, 156367424U, 156499264U, 156630976U, + 156761536U, 156892352U, 157024064U, 157155008U, 157284416U, 157415872U, + 157545536U, 157677248U, 157810496U, 157938112U, 158071744U, 158203328U, + 158334656U, 158464832U, 158596288U, 158727616U, 158858048U, 158988992U, + 159121216U, 159252416U, 159381568U, 159513152U, 159645632U, 159776192U, + 159906496U, 160038464U, 160169536U, 160300352U, 160430656U, 160563008U, + 160693952U, 160822208U, 160956352U, 161086784U, 161217344U, 161349184U, + 161480512U, 161611456U, 161742272U, 161873216U, 162002752U, 162135872U, + 162266432U, 162397888U, 162529216U, 162660032U, 162790976U, 162922048U, + 163052096U, 163184576U, 163314752U, 163446592U, 163577408U, 163707968U, + 163839296U, 163969984U, 164100928U, 164233024U, 164364224U, 164494912U, + 164625856U, 164756672U, 164887616U, 165019072U, 165150016U, 165280064U, + 165412672U, 165543104U, 165674944U, 165805888U, 165936832U, 166067648U, + 166198336U, 166330048U, 166461248U, 166591552U, 166722496U, 166854208U, + 166985408U, 167116736U, 167246656U, 167378368U, 167508416U, 167641024U, + 167771584U, 167903168U, 168034112U, 168164032U, 168295744U, 168427456U, + 168557632U, 168688448U, 168819136U, 168951616U, 169082176U, 169213504U, + 169344832U, 169475648U, 169605952U, 169738048U, 169866304U, 169999552U, + 170131264U, 170262464U, 170393536U, 170524352U, 170655424U, 170782016U, + 170917696U, 171048896U, 171179072U, 171310784U, 171439936U, 171573184U, + 171702976U, 171835072U, 171966272U, 172097216U, 172228288U, 172359232U, + 172489664U, 172621376U, 172747712U, 172883264U, 173014208U, 173144512U, + 173275072U, 173407424U, 173539136U, 173669696U, 173800768U, 173931712U, + 174063424U, 174193472U, 174325696U, 174455744U, 174586816U, 174718912U, + 174849728U, 174977728U, 175109696U, 175242688U, 175374272U, 175504832U, + 175636288U, 175765696U, 175898432U, 176028992U, 176159936U, 176291264U, + 176422592U, 176552512U, 176684864U, 176815424U, 176946496U, 177076544U, + 177209152U, 177340096U, 177470528U, 177600704U, 177731648U, 177864256U, + 177994816U, 178126528U, 178257472U, 178387648U, 178518464U, 178650176U, + 178781888U, 178912064U, 179044288U, 179174848U, 179305024U, 179436736U, + 179568448U, 179698496U, 179830208U, 179960512U, 180092608U, 180223808U, + 180354752U, 180485696U, 180617152U, 180748096U, 180877504U, 181009984U, + 181139264U, 181272512U, 181402688U, 181532608U, 181663168U, 181795136U, + 181926592U, 182057536U, 182190016U, 182320192U, 182451904U, 182582336U, + 182713792U, 182843072U, 182976064U, 183107264U, 183237056U, 183368384U, + 183494848U, 183631424U, 183762752U, 183893824U, 184024768U, 184154816U, + 184286656U, 184417984U, 184548928U, 184680128U, 184810816U, 184941248U, + 185072704U, 185203904U, 185335616U, 185465408U, 185596352U, 185727296U, + 185859904U, 185989696U, 186121664U, 186252992U, 186383552U, 186514112U, + 186645952U, 186777152U, 186907328U, 187037504U, 187170112U, 187301824U, + 187429184U, 187562048U, 187693504U, 187825472U, 187957184U, 188087104U, + 188218304U, 188349376U, 188481344U, 188609728U, 188743616U, 188874304U, + 189005248U, 189136448U, 189265088U, 189396544U, 189528128U, 189660992U, + 189791936U, 189923264U, 190054208U, 190182848U, 190315072U, 190447424U, + 190577984U, 190709312U, 190840768U, 190971328U, 191102656U, 191233472U, + 191364032U, 191495872U, 191626816U, 191758016U, 191888192U, 192020288U, + 192148928U, 192282176U, 192413504U, 192542528U, 192674752U, 192805952U, + 192937792U, 193068608U, 193198912U, 193330496U, 193462208U, 193592384U, + 193723456U, 193854272U, 193985984U, 194116672U, 194247232U, 194379712U, + 194508352U, 194641856U, 194772544U, 194900672U, 195035072U, 195166016U, + 195296704U, 195428032U, 195558592U, 195690304U, 195818176U, 195952576U, + 196083392U, 196214336U, 196345792U, 196476736U, 196607552U, 196739008U, + 196869952U, 197000768U, 197130688U, 197262784U, 197394368U, 197523904U, + 197656384U, 197787584U, 197916608U, 198049472U, 198180544U, 198310208U, + 198442432U, 198573632U, 198705088U, 198834368U, 198967232U, 199097792U, + 199228352U, 199360192U, 199491392U, 199621696U, 199751744U, 199883968U, + 200014016U, 200146624U, 200276672U, 200408128U, 200540096U, 200671168U, + 200801984U, 200933312U, 201062464U, 201194944U, 201326144U, 201457472U, + 201588544U, 201719744U, 201850816U, 201981632U, 202111552U, 202244032U, + 202374464U, 202505152U, 202636352U, 202767808U, 202898368U, 203030336U, + 203159872U, 203292608U, 203423296U, 203553472U, 203685824U, 203816896U, + 203947712U, 204078272U, 204208192U, 204341056U, 204472256U, 204603328U, + 204733888U, 204864448U, 204996544U, 205125568U, 205258304U, 205388864U, + 205517632U, 205650112U, 205782208U, 205913536U, 206044736U, 206176192U, + 206307008U, 206434496U, 206569024U, 206700224U, 206831168U, 206961856U, + 207093056U, 207223616U, 207355328U, 207486784U, 207616832U, 207749056U, + 207879104U, 208010048U, 208141888U, 208273216U, 208404032U, 208534336U, + 208666048U, 208796864U, 208927424U, 209059264U, 209189824U, 209321792U, + 209451584U, 209582656U, 209715136U, 209845568U, 209976896U, 210106432U, + 210239296U, 210370112U, 210501568U, 210630976U, 210763712U, 210894272U, + 211024832U, 211156672U, 211287616U, 211418176U, 211549376U, 211679296U, + 211812032U, 211942592U, 212074432U, 212204864U, 212334016U, 212467648U, + 212597824U, 212727616U, 212860352U, 212991424U, 213120832U, 213253952U, + 213385024U, 213515584U, 213645632U, 213777728U, 213909184U, 214040128U, + 214170688U, 214302656U, 214433728U, 214564544U, 214695232U, 214826048U, + 214956992U, 215089088U, 215219776U, 215350592U, 215482304U, 215613248U, + 215743552U, 215874752U, 216005312U, 216137024U, 216267328U, 216399296U, + 216530752U, 216661696U, 216790592U, 216923968U, 217054528U, 217183168U, + 217316672U, 217448128U, 217579072U, 217709504U, 217838912U, 217972672U, + 218102848U, 218233024U, 218364736U, 218496832U, 218627776U, 218759104U, + 218888896U, 219021248U, 219151936U, 219281728U, 219413056U, 219545024U, + 219675968U, 219807296U, 219938624U, 220069312U, 220200128U, 220331456U, + 220461632U, 220592704U, 220725184U, 220855744U, 220987072U, 221117888U, + 221249216U, 221378368U, 221510336U, 221642048U, 221772736U, 221904832U, + 222031808U, 222166976U, 222297536U, 222428992U, 222559936U, 222690368U, + 222820672U, 222953152U, 223083968U, 223213376U, 223345984U, 223476928U, + 223608512U, 223738688U, 223869376U, 224001472U, 224132672U, 224262848U, + 224394944U, 224524864U, 224657344U, 224788288U, 224919488U, 225050432U, + 225181504U, 225312704U, 225443776U, 225574592U, 225704768U, 225834176U, + 225966784U, 226097216U, 226229824U, 226360384U, 226491712U, 226623424U, + 226754368U, 226885312U, 227015104U, 227147456U, 227278528U, 227409472U, + 227539904U, 227669696U, 227802944U, 227932352U, 228065216U, 228196288U, + 228326464U, 228457792U, 228588736U, 228720064U, 228850112U, 228981056U, + 229113152U, 229243328U, 229375936U, 229505344U, 229636928U, 229769152U, + 229894976U, 230030272U, 230162368U, 230292416U, 230424512U, 230553152U, + 230684864U, 230816704U, 230948416U, 231079616U, 231210944U, 231342016U, + 231472448U, 231603776U, 231733952U, 231866176U, 231996736U, 232127296U, + 232259392U, 232388672U, 232521664U, 232652608U, 232782272U, 232914496U, + 233043904U, 233175616U, 233306816U, 233438528U, 233569984U, 233699776U, + 233830592U, 233962688U, 234092224U, 234221888U, 234353984U, 234485312U, + 234618304U, 234749888U, 234880832U, 235011776U, 235142464U, 235274048U, + 235403456U, 235535936U, 235667392U, 235797568U, 235928768U, 236057152U, + 236190272U, 236322752U, 236453312U, 236583616U, 236715712U, 236846528U, + 236976448U, 237108544U, 237239104U, 237371072U, 237501632U, 237630784U, + 237764416U, 237895232U, 238026688U, 238157632U, 238286912U, 238419392U, + 238548032U, 238681024U, 238812608U, 238941632U, 239075008U, 239206336U, + 239335232U, 239466944U, 239599168U, 239730496U, 239861312U, 239992384U, + 240122816U, 240254656U, 240385856U, 240516928U, 240647872U, 240779072U, + 240909632U, 241040704U, 241171904U, 241302848U, 241433408U, 241565248U, + 241696192U, 241825984U, 241958848U, 242088256U, 242220224U, 242352064U, + 242481856U, 242611648U, 242744896U, 242876224U, 243005632U, 243138496U, + 243268672U, 243400384U, 243531712U, 243662656U, 243793856U, 243924544U, + 244054592U, 244187072U, 244316608U, 244448704U, 244580032U, 244710976U, + 244841536U, 244972864U, 245104448U, 245233984U, 245365312U, 245497792U, + 245628736U, 245759936U, 245889856U, 246021056U, 246152512U, 246284224U, + 246415168U, 246545344U, 246675904U, 246808384U, 246939584U, 247070144U, + 247199552U, 247331648U, 247463872U, 247593536U, 247726016U, 247857088U, + 247987648U, 248116928U, 248249536U, 248380736U, 248512064U, 248643008U, + 248773312U, 248901056U, 249036608U, 249167552U, 249298624U, 249429184U, + 249560512U, 249692096U, 249822784U, 249954112U, 250085312U, 250215488U, + 250345792U, 250478528U, 250608704U, 250739264U, 250870976U, 251002816U, + 251133632U, 251263552U, 251395136U, 251523904U, 251657792U, 251789248U, + 251919424U, 252051392U, 252182464U, 252313408U, 252444224U, 252575552U, + 252706624U, 252836032U, 252968512U, 253099712U, 253227584U, 253361728U, + 253493056U, 253623488U, 253754432U, 253885504U, 254017216U, 254148032U, + 254279488U, 254410432U, 254541376U, 254672576U, 254803264U, 254933824U, + 255065792U, 255196736U, 255326528U, 255458752U, 255589952U, 255721408U, + 255851072U, 255983296U, 256114624U, 256244416U, 256374208U, 256507712U, + 256636096U, 256768832U, 256900544U, 257031616U, 257162176U, 257294272U, + 257424448U, 257555776U, 257686976U, 257818432U, 257949632U, 258079552U, + 258211136U, 258342464U, 258473408U, 258603712U, 258734656U, 258867008U, + 258996544U, 259127744U, 259260224U, 259391296U, 259522112U, 259651904U, + 259784384U, 259915328U, 260045888U, 260175424U, 260308544U, 260438336U, + 260570944U, 260700992U, 260832448U, 260963776U, 261092672U, 261226304U, + 261356864U, 261487936U, 261619648U, 261750592U, 261879872U, 262011968U, + 262143424U, 262274752U, 262404416U, 262537024U, 262667968U, 262799296U, + 262928704U, 263061184U, 263191744U, 263322944U, 263454656U, 263585216U, + 263716672U, 263847872U, 263978944U, 264108608U, 264241088U, 264371648U, + 264501184U, 264632768U, 264764096U, 264895936U, 265024576U, 265158464U, + 265287488U, 265418432U, 265550528U, 265681216U, 265813312U, 265943488U, + 266075968U, 266206144U, 266337728U, 266468032U, 266600384U, 266731072U, + 266862272U, 266993344U, 267124288U, 267255616U, 267386432U, 267516992U, + 267648704U, 267777728U, 267910592U, 268040512U, 268172096U, 268302784U, + 268435264U, 268566208U, 268696256U, 268828096U, 268959296U, 269090368U, + 269221312U, 269352256U, 269482688U, 269614784U, 269745856U, 269876416U, + 270007616U, 270139328U, 270270272U, 270401216U, 270531904U, 270663616U, + 270791744U, 270924736U, 271056832U, 271186112U, 271317184U, 271449536U, + 271580992U, 271711936U, 271843136U, 271973056U, 272105408U, 272236352U, + 272367296U, 272498368U, 272629568U, 272759488U, 272891456U, 273022784U, + 273153856U, 273284672U, 273415616U, 273547072U, 273677632U, 273808448U, + 273937088U, 274071488U, 274200896U, 274332992U, 274463296U, 274595392U, + 274726208U, 274857536U, 274988992U, 275118656U, 275250496U, 275382208U, + 275513024U, 275643968U, 275775296U, 275906368U, 276037184U, 276167872U, + 276297664U, 276429376U, 276560576U, 276692672U, 276822976U, 276955072U, + 277085632U, 277216832U, 277347008U, 277478848U, 277609664U, 277740992U, + 277868608U, 278002624U, 278134336U, 278265536U, 278395328U, 278526784U, + 278657728U, 278789824U, 278921152U, 279052096U, 279182912U, 279313088U, + 279443776U, 279576256U, 279706048U, 279838528U, 279969728U, 280099648U, + 280230976U, 280361408U, 280493632U, 280622528U, 280755392U, 280887104U, + 281018176U, 281147968U, 281278912U, 281411392U, 281542592U, 281673152U, + 281803712U, 281935552U, 282066496U, 282197312U, 282329024U, 282458816U, + 282590272U, 282720832U, 282853184U, 282983744U, 283115072U, 283246144U, + 283377344U, 283508416U, 283639744U, 283770304U, 283901504U, 284032576U, + 284163136U, 284294848U, 284426176U, 284556992U, 284687296U, 284819264U, + 284950208U, 285081536U }; #ifdef __cplusplus diff --git a/include/metaverse/consensus/libethash/endian.h b/include/metaverse/consensus/libethash/endian.h index 6b69367ed..a72b4705e 100644 --- a/include/metaverse/consensus/libethash/endian.h +++ b/include/metaverse/consensus/libethash/endian.h @@ -57,18 +57,18 @@ #define fix_endian32_same(val_) val_ = ethash_swap_u32(val_) #define fix_endian64(dst_, src_) dst_ = ethash_swap_u64(src_ #define fix_endian64_same(val_) val_ = ethash_swap_u64(val_) -#define fix_endian_arr32(arr_, size_) \ - do { \ - for (unsigned i_ = 0; i_ < (size_), ++i_) { \ - arr_[i_] = ethash_swap_u32(arr_[i_]); \ - } \ - while (0) -#define fix_endian_arr64(arr_, size_) \ - do { \ - for (unsigned i_ = 0; i_ < (size_), ++i_) { \ - arr_[i_] = ethash_swap_u64(arr_[i_]); \ - } \ - while (0) \ +#define fix_endian_arr32(arr_, size_) \ + do { \ + for (unsigned i_ = 0; i_ < (size_), ++i_) { \ + arr_[i_] = ethash_swap_u32(arr_[i_]); \ + } \ + while (0) +#define fix_endian_arr64(arr_, size_) \ + do { \ + for (unsigned i_ = 0; i_ < (size_), ++i_) { \ + arr_[i_] = ethash_swap_u64(arr_[i_]); \ + } \ + while (0) \ #else # error "endian not supported" diff --git a/include/metaverse/consensus/libethash/ethash.h b/include/metaverse/consensus/libethash/ethash.h index 0c6a1f9e9..09788078a 100644 --- a/include/metaverse/consensus/libethash/ethash.h +++ b/include/metaverse/consensus/libethash/ethash.h @@ -52,8 +52,8 @@ typedef struct ethash_h256 { uint8_t b[32]; } ethash_h256_t; // ethash_h256_t a = ethash_h256_static_init(1, 2, 3, ... ) // have to provide all 32 values. If you don't provide all the rest // will simply be unitialized (not guranteed to be 0) -#define ethash_h256_static_init(...) \ - { {__VA_ARGS__} } +#define ethash_h256_static_init(...) \ + { {__VA_ARGS__} } struct ethash_light; typedef struct ethash_light* ethash_light_t; @@ -62,9 +62,9 @@ typedef struct ethash_full* ethash_full_t; typedef int(*ethash_callback_t)(unsigned); typedef struct ethash_return_value { - ethash_h256_t result; - ethash_h256_t mix_hash; - bool success; + ethash_h256_t result; + ethash_h256_t mix_hash; + bool success; } ethash_return_value_t; /** @@ -89,9 +89,9 @@ void ethash_light_delete(ethash_light_t light); * @return an object of ethash_return_value_t holding the return values */ ethash_return_value_t ethash_light_compute( - ethash_light_t light, - ethash_h256_t const header_hash, - uint64_t nonce + ethash_light_t light, + ethash_h256_t const header_hash, + uint64_t nonce ); /** @@ -124,9 +124,9 @@ void ethash_full_delete(ethash_full_t full); * @return An object of ethash_return_value to hold the return value */ ethash_return_value_t ethash_full_compute( - ethash_full_t full, - ethash_h256_t const header_hash, - uint64_t nonce + ethash_full_t full, + ethash_h256_t const header_hash, + uint64_t nonce ); /** * Get a pointer to the full DAG data diff --git a/include/metaverse/consensus/libethash/fnv.h b/include/metaverse/consensus/libethash/fnv.h index d23c4e247..ed04b4493 100644 --- a/include/metaverse/consensus/libethash/fnv.h +++ b/include/metaverse/consensus/libethash/fnv.h @@ -31,7 +31,7 @@ extern "C" { static inline uint32_t fnv_hash(uint32_t const x, uint32_t const y) { - return x * FNV_PRIME ^ y; + return x * FNV_PRIME ^ y; } #ifdef __cplusplus diff --git a/include/metaverse/consensus/libethash/internal.c b/include/metaverse/consensus/libethash/internal.c index 11612ccbf..c76a1521b 100644 --- a/include/metaverse/consensus/libethash/internal.c +++ b/include/metaverse/consensus/libethash/internal.c @@ -8,11 +8,11 @@ ethash is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with cpp-ethereum. If not, see . + along with cpp-ethereum. If not, see . */ /** @file internal.c * @author Tim Hughes @@ -43,219 +43,219 @@ uint64_t ethash_get_datasize(uint64_t const block_number) { - assert(block_number / ETHASH_EPOCH_LENGTH < 2048); - return dag_sizes[block_number / ETHASH_EPOCH_LENGTH]; + assert(block_number / ETHASH_EPOCH_LENGTH < 2048); + return dag_sizes[block_number / ETHASH_EPOCH_LENGTH]; } uint64_t ethash_get_cachesize(uint64_t const block_number) { - assert(block_number / ETHASH_EPOCH_LENGTH < 2048); - return cache_sizes[block_number / ETHASH_EPOCH_LENGTH]; + assert(block_number / ETHASH_EPOCH_LENGTH < 2048); + return cache_sizes[block_number / ETHASH_EPOCH_LENGTH]; } // Follows Sergio's "STRICT MEMORY HARD HASHING FUNCTIONS" (2014) // https://bitslog.files.wordpress.com/2013/12/memohash-v0-3.pdf // SeqMemoHash(s, R, N) static bool ethash_compute_cache_nodes( - node* const nodes, - uint64_t cache_size, - ethash_h256_t const* seed + node* const nodes, + uint64_t cache_size, + ethash_h256_t const* seed ) { - if (cache_size % sizeof(node) != 0) { - return false; - } - uint32_t const num_nodes = (uint32_t) (cache_size / sizeof(node)); - - SHA3_512(nodes[0].bytes, (uint8_t*)seed, 32); - - for (uint32_t i = 1; i != num_nodes; ++i) { - SHA3_512(nodes[i].bytes, nodes[i - 1].bytes, 64); - } - - for (uint32_t j = 0; j != ETHASH_CACHE_ROUNDS; j++) { - for (uint32_t i = 0; i != num_nodes; i++) { - uint32_t const idx = nodes[i].words[0] % num_nodes; - node data; - data = nodes[(num_nodes - 1 + i) % num_nodes]; - for (uint32_t w = 0; w != NODE_WORDS; ++w) { - data.words[w] ^= nodes[idx].words[w]; - } - SHA3_512(nodes[i].bytes, data.bytes, sizeof(data)); - } - } - - // now perform endian conversion - fix_endian_arr32(nodes->words, num_nodes * NODE_WORDS); - return true; + if (cache_size % sizeof(node) != 0) { + return false; + } + uint32_t const num_nodes = (uint32_t) (cache_size / sizeof(node)); + + SHA3_512(nodes[0].bytes, (uint8_t*)seed, 32); + + for (uint32_t i = 1; i != num_nodes; ++i) { + SHA3_512(nodes[i].bytes, nodes[i - 1].bytes, 64); + } + + for (uint32_t j = 0; j != ETHASH_CACHE_ROUNDS; j++) { + for (uint32_t i = 0; i != num_nodes; i++) { + uint32_t const idx = nodes[i].words[0] % num_nodes; + node data; + data = nodes[(num_nodes - 1 + i) % num_nodes]; + for (uint32_t w = 0; w != NODE_WORDS; ++w) { + data.words[w] ^= nodes[idx].words[w]; + } + SHA3_512(nodes[i].bytes, data.bytes, sizeof(data)); + } + } + + // now perform endian conversion + fix_endian_arr32(nodes->words, num_nodes * NODE_WORDS); + return true; } void ethash_calculate_dag_item( - node* const ret, - uint32_t node_index, - ethash_light_t const light + node* const ret, + uint32_t node_index, + ethash_light_t const light ) { - uint32_t num_parent_nodes = (uint32_t) (light->cache_size / sizeof(node)); - node const* cache_nodes = (node const *) light->cache; - node const* init = &cache_nodes[node_index % num_parent_nodes]; - memcpy(ret, init, sizeof(node)); - ret->words[0] ^= node_index; - SHA3_512(ret->bytes, ret->bytes, sizeof(node)); + uint32_t num_parent_nodes = (uint32_t) (light->cache_size / sizeof(node)); + node const* cache_nodes = (node const *) light->cache; + node const* init = &cache_nodes[node_index % num_parent_nodes]; + memcpy(ret, init, sizeof(node)); + ret->words[0] ^= node_index; + SHA3_512(ret->bytes, ret->bytes, sizeof(node)); #if defined(_M_X64) && ENABLE_SSE - __m128i const fnv_prime = _mm_set1_epi32(FNV_PRIME); - __m128i xmm0 = ret->xmm[0]; - __m128i xmm1 = ret->xmm[1]; - __m128i xmm2 = ret->xmm[2]; - __m128i xmm3 = ret->xmm[3]; + __m128i const fnv_prime = _mm_set1_epi32(FNV_PRIME); + __m128i xmm0 = ret->xmm[0]; + __m128i xmm1 = ret->xmm[1]; + __m128i xmm2 = ret->xmm[2]; + __m128i xmm3 = ret->xmm[3]; #elif defined(__MIC__) - __m512i const fnv_prime = _mm512_set1_epi32(FNV_PRIME); - __m512i zmm0 = ret->zmm[0]; + __m512i const fnv_prime = _mm512_set1_epi32(FNV_PRIME); + __m512i zmm0 = ret->zmm[0]; #endif - for (uint32_t i = 0; i != ETHASH_DATASET_PARENTS; ++i) { - uint32_t parent_index = fnv_hash(node_index ^ i, ret->words[i % NODE_WORDS]) % num_parent_nodes; - node const *parent = &cache_nodes[parent_index]; + for (uint32_t i = 0; i != ETHASH_DATASET_PARENTS; ++i) { + uint32_t parent_index = fnv_hash(node_index ^ i, ret->words[i % NODE_WORDS]) % num_parent_nodes; + node const *parent = &cache_nodes[parent_index]; #if defined(_M_X64) && ENABLE_SSE - { - xmm0 = _mm_mullo_epi32(xmm0, fnv_prime); - xmm1 = _mm_mullo_epi32(xmm1, fnv_prime); - xmm2 = _mm_mullo_epi32(xmm2, fnv_prime); - xmm3 = _mm_mullo_epi32(xmm3, fnv_prime); - xmm0 = _mm_xor_si128(xmm0, parent->xmm[0]); - xmm1 = _mm_xor_si128(xmm1, parent->xmm[1]); - xmm2 = _mm_xor_si128(xmm2, parent->xmm[2]); - xmm3 = _mm_xor_si128(xmm3, parent->xmm[3]); - - // have to write to ret as values are used to compute index - ret->xmm[0] = xmm0; - ret->xmm[1] = xmm1; - ret->xmm[2] = xmm2; - ret->xmm[3] = xmm3; - } - #elif defined(__MIC__) - { - zmm0 = _mm512_mullo_epi32(zmm0, fnv_prime); - - // have to write to ret as values are used to compute index - zmm0 = _mm512_xor_si512(zmm0, parent->zmm[0]); - ret->zmm[0] = zmm0; - } - #else - { - for (unsigned w = 0; w != NODE_WORDS; ++w) { - ret->words[w] = fnv_hash(ret->words[w], parent->words[w]); - } - } + { + xmm0 = _mm_mullo_epi32(xmm0, fnv_prime); + xmm1 = _mm_mullo_epi32(xmm1, fnv_prime); + xmm2 = _mm_mullo_epi32(xmm2, fnv_prime); + xmm3 = _mm_mullo_epi32(xmm3, fnv_prime); + xmm0 = _mm_xor_si128(xmm0, parent->xmm[0]); + xmm1 = _mm_xor_si128(xmm1, parent->xmm[1]); + xmm2 = _mm_xor_si128(xmm2, parent->xmm[2]); + xmm3 = _mm_xor_si128(xmm3, parent->xmm[3]); + + // have to write to ret as values are used to compute index + ret->xmm[0] = xmm0; + ret->xmm[1] = xmm1; + ret->xmm[2] = xmm2; + ret->xmm[3] = xmm3; + } + #elif defined(__MIC__) + { + zmm0 = _mm512_mullo_epi32(zmm0, fnv_prime); + + // have to write to ret as values are used to compute index + zmm0 = _mm512_xor_si512(zmm0, parent->zmm[0]); + ret->zmm[0] = zmm0; + } + #else + { + for (unsigned w = 0; w != NODE_WORDS; ++w) { + ret->words[w] = fnv_hash(ret->words[w], parent->words[w]); + } + } #endif - } - SHA3_512(ret->bytes, ret->bytes, sizeof(node)); + } + SHA3_512(ret->bytes, ret->bytes, sizeof(node)); } bool ethash_compute_full_data( - void* mem, - uint64_t full_size, - ethash_light_t const light, - ethash_callback_t callback + void* mem, + uint64_t full_size, + ethash_light_t const light, + ethash_callback_t callback ) { - if (full_size % (sizeof(uint32_t) * MIX_WORDS) != 0 || - (full_size % sizeof(node)) != 0) { - return false; - } - uint32_t const max_n = (uint32_t)(full_size / sizeof(node)); - node* full_nodes = mem; - double const progress_change = 1.0f / max_n; - double progress = 0.0f; - // now compute full nodes - for (uint32_t n = 0; n != max_n; ++n) { - if (callback && - n % (max_n / 100) == 0 && - callback((unsigned int)(ceil(progress * 100.0f))) != 0) { - - return false; - } - progress += progress_change; - ethash_calculate_dag_item(&(full_nodes[n]), n, light); - } - return true; + if (full_size % (sizeof(uint32_t) * MIX_WORDS) != 0 || + (full_size % sizeof(node)) != 0) { + return false; + } + uint32_t const max_n = (uint32_t)(full_size / sizeof(node)); + node* full_nodes = mem; + double const progress_change = 1.0f / max_n; + double progress = 0.0f; + // now compute full nodes + for (uint32_t n = 0; n != max_n; ++n) { + if (callback && + n % (max_n / 100) == 0 && + callback((unsigned int)(ceil(progress * 100.0f))) != 0) { + + return false; + } + progress += progress_change; + ethash_calculate_dag_item(&(full_nodes[n]), n, light); + } + return true; } static bool ethash_hash( - ethash_return_value_t* ret, - node const* full_nodes, - ethash_light_t const light, - uint64_t full_size, - ethash_h256_t const header_hash, - uint64_t const nonce + ethash_return_value_t* ret, + node const* full_nodes, + ethash_light_t const light, + uint64_t full_size, + ethash_h256_t const header_hash, + uint64_t const nonce ) { - if (full_size % MIX_WORDS != 0) { - return false; - } - - // pack hash and nonce together into first 40 bytes of s_mix - assert(sizeof(node) * 8 == 512); - node s_mix[MIX_NODES + 1]; - memcpy(s_mix[0].bytes, &header_hash, 32); - fix_endian64(s_mix[0].double_words[4], nonce); - - // compute sha3-512 hash and replicate across mix - SHA3_512(s_mix->bytes, s_mix->bytes, 40); - fix_endian_arr32(s_mix[0].words, 16); - - node* const mix = s_mix + 1; - for (uint32_t w = 0; w != MIX_WORDS; ++w) { - mix->words[w] = s_mix[0].words[w % NODE_WORDS]; - } - - unsigned const page_size = sizeof(uint32_t) * MIX_WORDS; - unsigned const num_full_pages = (unsigned) (full_size / page_size); - - for (unsigned i = 0; i != ETHASH_ACCESSES; ++i) { - uint32_t const index = fnv_hash(s_mix->words[0] ^ i, mix->words[i % MIX_WORDS]) % num_full_pages; - - for (unsigned n = 0; n != MIX_NODES; ++n) { - node const* dag_node; - if (full_nodes) { - dag_node = &full_nodes[MIX_NODES * index + n]; - } else { - node tmp_node; - ethash_calculate_dag_item(&tmp_node, index * MIX_NODES + n, light); - dag_node = &tmp_node; - } + if (full_size % MIX_WORDS != 0) { + return false; + } + + // pack hash and nonce together into first 40 bytes of s_mix + assert(sizeof(node) * 8 == 512); + node s_mix[MIX_NODES + 1]; + memcpy(s_mix[0].bytes, &header_hash, 32); + fix_endian64(s_mix[0].double_words[4], nonce); + + // compute sha3-512 hash and replicate across mix + SHA3_512(s_mix->bytes, s_mix->bytes, 40); + fix_endian_arr32(s_mix[0].words, 16); + + node* const mix = s_mix + 1; + for (uint32_t w = 0; w != MIX_WORDS; ++w) { + mix->words[w] = s_mix[0].words[w % NODE_WORDS]; + } + + unsigned const page_size = sizeof(uint32_t) * MIX_WORDS; + unsigned const num_full_pages = (unsigned) (full_size / page_size); + + for (unsigned i = 0; i != ETHASH_ACCESSES; ++i) { + uint32_t const index = fnv_hash(s_mix->words[0] ^ i, mix->words[i % MIX_WORDS]) % num_full_pages; + + for (unsigned n = 0; n != MIX_NODES; ++n) { + node const* dag_node; + if (full_nodes) { + dag_node = &full_nodes[MIX_NODES * index + n]; + } else { + node tmp_node; + ethash_calculate_dag_item(&tmp_node, index * MIX_NODES + n, light); + dag_node = &tmp_node; + } #if defined(_M_X64) && ENABLE_SSE - { - __m128i fnv_prime = _mm_set1_epi32(FNV_PRIME); - __m128i xmm0 = _mm_mullo_epi32(fnv_prime, mix[n].xmm[0]); - __m128i xmm1 = _mm_mullo_epi32(fnv_prime, mix[n].xmm[1]); - __m128i xmm2 = _mm_mullo_epi32(fnv_prime, mix[n].xmm[2]); - __m128i xmm3 = _mm_mullo_epi32(fnv_prime, mix[n].xmm[3]); - mix[n].xmm[0] = _mm_xor_si128(xmm0, dag_node->xmm[0]); - mix[n].xmm[1] = _mm_xor_si128(xmm1, dag_node->xmm[1]); - mix[n].xmm[2] = _mm_xor_si128(xmm2, dag_node->xmm[2]); - mix[n].xmm[3] = _mm_xor_si128(xmm3, dag_node->xmm[3]); - } - #elif defined(__MIC__) - { - // __m512i implementation via union - // Each vector register (zmm) can store sixteen 32-bit integer numbers - __m512i fnv_prime = _mm512_set1_epi32(FNV_PRIME); - __m512i zmm0 = _mm512_mullo_epi32(fnv_prime, mix[n].zmm[0]); - mix[n].zmm[0] = _mm512_xor_si512(zmm0, dag_node->zmm[0]); - } - #else - { - for (unsigned w = 0; w != NODE_WORDS; ++w) { - mix[n].words[w] = fnv_hash(mix[n].words[w], dag_node->words[w]); - } - } + { + __m128i fnv_prime = _mm_set1_epi32(FNV_PRIME); + __m128i xmm0 = _mm_mullo_epi32(fnv_prime, mix[n].xmm[0]); + __m128i xmm1 = _mm_mullo_epi32(fnv_prime, mix[n].xmm[1]); + __m128i xmm2 = _mm_mullo_epi32(fnv_prime, mix[n].xmm[2]); + __m128i xmm3 = _mm_mullo_epi32(fnv_prime, mix[n].xmm[3]); + mix[n].xmm[0] = _mm_xor_si128(xmm0, dag_node->xmm[0]); + mix[n].xmm[1] = _mm_xor_si128(xmm1, dag_node->xmm[1]); + mix[n].xmm[2] = _mm_xor_si128(xmm2, dag_node->xmm[2]); + mix[n].xmm[3] = _mm_xor_si128(xmm3, dag_node->xmm[3]); + } + #elif defined(__MIC__) + { + // __m512i implementation via union + // Each vector register (zmm) can store sixteen 32-bit integer numbers + __m512i fnv_prime = _mm512_set1_epi32(FNV_PRIME); + __m512i zmm0 = _mm512_mullo_epi32(fnv_prime, mix[n].zmm[0]); + mix[n].zmm[0] = _mm512_xor_si512(zmm0, dag_node->zmm[0]); + } + #else + { + for (unsigned w = 0; w != NODE_WORDS; ++w) { + mix[n].words[w] = fnv_hash(mix[n].words[w], dag_node->words[w]); + } + } #endif - } + } - } + } // Workaround for a GCC regression which causes a bogus -Warray-bounds warning. // The regression was introduced in GCC 4.8.4, fixed in GCC 5.0.0 and backported to GCC 4.9.3 but @@ -273,299 +273,299 @@ static bool ethash_hash( #pragma GCC diagnostic ignored "-Warray-bounds" #endif // define (__GNUC__) - // compress mix - for (uint32_t w = 0; w != MIX_WORDS; w += 4) { - uint32_t reduction = mix->words[w + 0]; - reduction = reduction * FNV_PRIME ^ mix->words[w + 1]; - reduction = reduction * FNV_PRIME ^ mix->words[w + 2]; - reduction = reduction * FNV_PRIME ^ mix->words[w + 3]; - mix->words[w / 4] = reduction; - } + // compress mix + for (uint32_t w = 0; w != MIX_WORDS; w += 4) { + uint32_t reduction = mix->words[w + 0]; + reduction = reduction * FNV_PRIME ^ mix->words[w + 1]; + reduction = reduction * FNV_PRIME ^ mix->words[w + 2]; + reduction = reduction * FNV_PRIME ^ mix->words[w + 3]; + mix->words[w / 4] = reduction; + } #if defined(__GNUC__) && (__GNUC__ < 5) #pragma GCC diagnostic pop #endif // define (__GNUC__) - fix_endian_arr32(mix->words, MIX_WORDS / 4); - memcpy(&ret->mix_hash, mix->bytes, 32); - // final Keccak hash - SHA3_256(&ret->result, s_mix->bytes, 64 + 32); // Keccak-256(s + compressed_mix) - return true; + fix_endian_arr32(mix->words, MIX_WORDS / 4); + memcpy(&ret->mix_hash, mix->bytes, 32); + // final Keccak hash + SHA3_256(&ret->result, s_mix->bytes, 64 + 32); // Keccak-256(s + compressed_mix) + return true; } void ethash_quick_hash( - ethash_h256_t* return_hash, - ethash_h256_t const* header_hash, - uint64_t const nonce, - ethash_h256_t const* mix_hash + ethash_h256_t* return_hash, + ethash_h256_t const* header_hash, + uint64_t const nonce, + ethash_h256_t const* mix_hash ) { - uint8_t buf[64 + 32]; - memcpy(buf, header_hash, 32); - fix_endian64_same(nonce); - memcpy(&(buf[32]), &nonce, 8); - SHA3_512(buf, buf, 40); - memcpy(&(buf[64]), mix_hash, 32); - SHA3_256(return_hash, buf, 64 + 32); + uint8_t buf[64 + 32]; + memcpy(buf, header_hash, 32); + fix_endian64_same(nonce); + memcpy(&(buf[32]), &nonce, 8); + SHA3_512(buf, buf, 40); + memcpy(&(buf[64]), mix_hash, 32); + SHA3_256(return_hash, buf, 64 + 32); } ethash_h256_t ethash_get_seedhash(uint64_t block_number) { - ethash_h256_t ret; - ethash_h256_reset(&ret); - uint64_t const epochs = block_number / ETHASH_EPOCH_LENGTH; - for (uint32_t i = 0; i < epochs; ++i) - SHA3_256(&ret, (uint8_t*)&ret, 32); - return ret; + ethash_h256_t ret; + ethash_h256_reset(&ret); + uint64_t const epochs = block_number / ETHASH_EPOCH_LENGTH; + for (uint32_t i = 0; i < epochs; ++i) + SHA3_256(&ret, (uint8_t*)&ret, 32); + return ret; } bool ethash_quick_check_difficulty( - ethash_h256_t const* header_hash, - uint64_t const nonce, - ethash_h256_t const* mix_hash, - ethash_h256_t const* boundary + ethash_h256_t const* header_hash, + uint64_t const nonce, + ethash_h256_t const* mix_hash, + ethash_h256_t const* boundary ) { - ethash_h256_t return_hash; - ethash_quick_hash(&return_hash, header_hash, nonce, mix_hash); - return ethash_check_difficulty(&return_hash, boundary); + ethash_h256_t return_hash; + ethash_quick_hash(&return_hash, header_hash, nonce, mix_hash); + return ethash_check_difficulty(&return_hash, boundary); } ethash_light_t ethash_light_new_internal(uint64_t cache_size, ethash_h256_t const* seed) { - struct ethash_light *ret; - ret = calloc(sizeof(*ret), 1); - if (!ret) { - return NULL; - } + struct ethash_light *ret; + ret = calloc(sizeof(*ret), 1); + if (!ret) { + return NULL; + } #if defined(__MIC__) - ret->cache = _mm_malloc((size_t)cache_size, 64); + ret->cache = _mm_malloc((size_t)cache_size, 64); #else - ret->cache = malloc((size_t)cache_size); + ret->cache = malloc((size_t)cache_size); #endif - if (!ret->cache) { - goto fail_free_light; - } - node* nodes = (node*)ret->cache; - if (!ethash_compute_cache_nodes(nodes, cache_size, seed)) { - goto fail_free_cache_mem; - } - ret->cache_size = cache_size; - return ret; + if (!ret->cache) { + goto fail_free_light; + } + node* nodes = (node*)ret->cache; + if (!ethash_compute_cache_nodes(nodes, cache_size, seed)) { + goto fail_free_cache_mem; + } + ret->cache_size = cache_size; + return ret; fail_free_cache_mem: #if defined(__MIC__) - _mm_free(ret->cache); + _mm_free(ret->cache); #else - free(ret->cache); + free(ret->cache); #endif fail_free_light: - free(ret); - return NULL; + free(ret); + return NULL; } ethash_light_t ethash_light_new(uint64_t block_number) { - ethash_h256_t seedhash = ethash_get_seedhash(block_number); - ethash_light_t ret; - ret = ethash_light_new_internal(ethash_get_cachesize(block_number), &seedhash); - ret->block_number = block_number; - return ret; + ethash_h256_t seedhash = ethash_get_seedhash(block_number); + ethash_light_t ret; + ret = ethash_light_new_internal(ethash_get_cachesize(block_number), &seedhash); + ret->block_number = block_number; + return ret; } void ethash_light_delete(ethash_light_t light) { - if (light->cache) { - free(light->cache); - } - free(light); + if (light->cache) { + free(light->cache); + } + free(light); } ethash_return_value_t ethash_light_compute_internal( - ethash_light_t light, - uint64_t full_size, - ethash_h256_t const header_hash, - uint64_t nonce + ethash_light_t light, + uint64_t full_size, + ethash_h256_t const header_hash, + uint64_t nonce ) { - ethash_return_value_t ret; - ret.success = true; - if (!ethash_hash(&ret, NULL, light, full_size, header_hash, nonce)) { - ret.success = false; - } - return ret; + ethash_return_value_t ret; + ret.success = true; + if (!ethash_hash(&ret, NULL, light, full_size, header_hash, nonce)) { + ret.success = false; + } + return ret; } ethash_return_value_t ethash_light_compute( - ethash_light_t light, - ethash_h256_t const header_hash, - uint64_t nonce + ethash_light_t light, + ethash_h256_t const header_hash, + uint64_t nonce ) { - uint64_t full_size = ethash_get_datasize(light->block_number); - return ethash_light_compute_internal(light, full_size, header_hash, nonce); + uint64_t full_size = ethash_get_datasize(light->block_number); + return ethash_light_compute_internal(light, full_size, header_hash, nonce); } static bool ethash_mmap(struct ethash_full* ret, FILE* f) { - int fd; - char* mmapped_data; - errno = 0; - ret->file = f; - if ((fd = ethash_fileno(ret->file)) == -1) { - return false; - } - mmapped_data = mmap( - NULL, - (size_t)ret->file_size + ETHASH_DAG_MAGIC_NUM_SIZE, - PROT_READ | PROT_WRITE, - MAP_SHARED, - fd, - 0 - ); - if (mmapped_data == MAP_FAILED) { - return false; - } - ret->data = (node*)(mmapped_data + ETHASH_DAG_MAGIC_NUM_SIZE); - return true; + int fd; + char* mmapped_data; + errno = 0; + ret->file = f; + if ((fd = ethash_fileno(ret->file)) == -1) { + return false; + } + mmapped_data = mmap( + NULL, + (size_t)ret->file_size + ETHASH_DAG_MAGIC_NUM_SIZE, + PROT_READ | PROT_WRITE, + MAP_SHARED, + fd, + 0 + ); + if (mmapped_data == MAP_FAILED) { + return false; + } + ret->data = (node*)(mmapped_data + ETHASH_DAG_MAGIC_NUM_SIZE); + return true; } ethash_full_t ethash_full_new_internal( - char const* dirname, - ethash_h256_t const seed_hash, - uint64_t full_size, - ethash_light_t const light, - ethash_callback_t callback + char const* dirname, + ethash_h256_t const seed_hash, + uint64_t full_size, + ethash_light_t const light, + ethash_callback_t callback ) { - struct ethash_full* ret; - FILE *f = NULL; - ret = calloc(sizeof(*ret), 1); - if (!ret) { - return NULL; - } - ret->file_size = (size_t)full_size; - switch (ethash_io_prepare(dirname, seed_hash, &f, (size_t)full_size, false)) { - case ETHASH_IO_FAIL: - // ethash_io_prepare will do all ETHASH_CRITICAL() logging in fail case - goto fail_free_full; - case ETHASH_IO_MEMO_MATCH: - if (!ethash_mmap(ret, f)) { - ETHASH_CRITICAL("mmap failure()"); - goto fail_close_file; - } + struct ethash_full* ret; + FILE *f = NULL; + ret = calloc(sizeof(*ret), 1); + if (!ret) { + return NULL; + } + ret->file_size = (size_t)full_size; + switch (ethash_io_prepare(dirname, seed_hash, &f, (size_t)full_size, false)) { + case ETHASH_IO_FAIL: + // ethash_io_prepare will do all ETHASH_CRITICAL() logging in fail case + goto fail_free_full; + case ETHASH_IO_MEMO_MATCH: + if (!ethash_mmap(ret, f)) { + ETHASH_CRITICAL("mmap failure()"); + goto fail_close_file; + } #if defined(__MIC__) - node* tmp_nodes = _mm_malloc((size_t)full_size, 64); - //copy all nodes from ret->data - //mmapped_nodes are not aligned properly - uint32_t const countnodes = (uint32_t) ((size_t)ret->file_size / sizeof(node)); - //fprintf(stderr,"ethash_full_new_internal:countnodes:%d",countnodes); - for (uint32_t i = 1; i != countnodes; ++i) { - tmp_nodes[i] = ret->data[i]; - } - ret->data = tmp_nodes; + node* tmp_nodes = _mm_malloc((size_t)full_size, 64); + //copy all nodes from ret->data + //mmapped_nodes are not aligned properly + uint32_t const countnodes = (uint32_t) ((size_t)ret->file_size / sizeof(node)); + //fprintf(stderr,"ethash_full_new_internal:countnodes:%d",countnodes); + for (uint32_t i = 1; i != countnodes; ++i) { + tmp_nodes[i] = ret->data[i]; + } + ret->data = tmp_nodes; #endif - return ret; - case ETHASH_IO_MEMO_SIZE_MISMATCH: - // if a DAG of same filename but unexpected size is found, silently force new file creation - if (ethash_io_prepare(dirname, seed_hash, &f, (size_t)full_size, true) != ETHASH_IO_MEMO_MISMATCH) { - ETHASH_CRITICAL("Could not recreate DAG file after finding existing DAG with unexpected size."); - goto fail_free_full; - } - // fallthrough to the mismatch case here, DO NOT go through match - case ETHASH_IO_MEMO_MISMATCH: - if (!ethash_mmap(ret, f)) { - ETHASH_CRITICAL("mmap failure()"); - goto fail_close_file; - } - break; - } + return ret; + case ETHASH_IO_MEMO_SIZE_MISMATCH: + // if a DAG of same filename but unexpected size is found, silently force new file creation + if (ethash_io_prepare(dirname, seed_hash, &f, (size_t)full_size, true) != ETHASH_IO_MEMO_MISMATCH) { + ETHASH_CRITICAL("Could not recreate DAG file after finding existing DAG with unexpected size."); + goto fail_free_full; + } + // fallthrough to the mismatch case here, DO NOT go through match + case ETHASH_IO_MEMO_MISMATCH: + if (!ethash_mmap(ret, f)) { + ETHASH_CRITICAL("mmap failure()"); + goto fail_close_file; + } + break; + } #if defined(__MIC__) - ret->data = _mm_malloc((size_t)full_size, 64); + ret->data = _mm_malloc((size_t)full_size, 64); #endif - if (!ethash_compute_full_data(ret->data, full_size, light, callback)) { - ETHASH_CRITICAL("Failure at computing DAG data."); - goto fail_free_full_data; - } - - // after the DAG has been filled then we finalize it by writting the magic number at the beginning - if (fseek(f, 0, SEEK_SET) != 0) { - ETHASH_CRITICAL("Could not seek to DAG file start to write magic number."); - goto fail_free_full_data; - } - uint64_t const magic_num = ETHASH_DAG_MAGIC_NUM; - if (fwrite(&magic_num, ETHASH_DAG_MAGIC_NUM_SIZE, 1, f) != 1) { - ETHASH_CRITICAL("Could not write magic number to DAG's beginning."); - goto fail_free_full_data; - } - if (fflush(f) != 0) {// make sure the magic number IS there - ETHASH_CRITICAL("Could not flush memory mapped data to DAG file. Insufficient space?"); - goto fail_free_full_data; - } - return ret; + if (!ethash_compute_full_data(ret->data, full_size, light, callback)) { + ETHASH_CRITICAL("Failure at computing DAG data."); + goto fail_free_full_data; + } + + // after the DAG has been filled then we finalize it by writting the magic number at the beginning + if (fseek(f, 0, SEEK_SET) != 0) { + ETHASH_CRITICAL("Could not seek to DAG file start to write magic number."); + goto fail_free_full_data; + } + uint64_t const magic_num = ETHASH_DAG_MAGIC_NUM; + if (fwrite(&magic_num, ETHASH_DAG_MAGIC_NUM_SIZE, 1, f) != 1) { + ETHASH_CRITICAL("Could not write magic number to DAG's beginning."); + goto fail_free_full_data; + } + if (fflush(f) != 0) {// make sure the magic number IS there + ETHASH_CRITICAL("Could not flush memory mapped data to DAG file. Insufficient space?"); + goto fail_free_full_data; + } + return ret; fail_free_full_data: - // could check that munmap(..) == 0 but even if it did not can't really do anything here - munmap(ret->data, (size_t)full_size); + // could check that munmap(..) == 0 but even if it did not can't really do anything here + munmap(ret->data, (size_t)full_size); #if defined(__MIC__) - _mm_free(ret->data); + _mm_free(ret->data); #endif fail_close_file: - fclose(ret->file); + fclose(ret->file); fail_free_full: - free(ret); - return NULL; + free(ret); + return NULL; } ethash_full_t ethash_full_new(ethash_light_t light, ethash_callback_t callback) { - char strbuf[256]; - if (!ethash_get_default_dirname(strbuf, 256)) { - return NULL; - } - uint64_t full_size = ethash_get_datasize(light->block_number); - ethash_h256_t seedhash = ethash_get_seedhash(light->block_number); - return ethash_full_new_internal(strbuf, seedhash, full_size, light, callback); + char strbuf[256]; + if (!ethash_get_default_dirname(strbuf, 256)) { + return NULL; + } + uint64_t full_size = ethash_get_datasize(light->block_number); + ethash_h256_t seedhash = ethash_get_seedhash(light->block_number); + return ethash_full_new_internal(strbuf, seedhash, full_size, light, callback); } void ethash_full_delete(ethash_full_t full) { - // could check that munmap(..) == 0 but even if it did not can't really do anything here - munmap(full->data, (size_t)full->file_size); - if (full->file) { - fclose(full->file); - } - free(full); + // could check that munmap(..) == 0 but even if it did not can't really do anything here + munmap(full->data, (size_t)full->file_size); + if (full->file) { + fclose(full->file); + } + free(full); } ethash_return_value_t ethash_full_compute( - ethash_full_t full, - ethash_h256_t const header_hash, - uint64_t nonce + ethash_full_t full, + ethash_h256_t const header_hash, + uint64_t nonce ) { - ethash_return_value_t ret; - ret.success = true; - if (!ethash_hash( - &ret, - (node const*)full->data, - NULL, - full->file_size, - header_hash, - nonce)) { - ret.success = false; - } - return ret; + ethash_return_value_t ret; + ret.success = true; + if (!ethash_hash( + &ret, + (node const*)full->data, + NULL, + full->file_size, + header_hash, + nonce)) { + ret.success = false; + } + return ret; } void const* ethash_full_dag(ethash_full_t full) { - return full->data; + return full->data; } uint64_t ethash_full_dag_size(ethash_full_t full) { - return full->file_size; + return full->file_size; } diff --git a/include/metaverse/consensus/libethash/internal.h b/include/metaverse/consensus/libethash/internal.h index 35419c6a9..529c4d650 100644 --- a/include/metaverse/consensus/libethash/internal.h +++ b/include/metaverse/consensus/libethash/internal.h @@ -23,47 +23,47 @@ extern "C" { #include typedef union node { - uint8_t bytes[NODE_WORDS * 4]; - uint32_t words[NODE_WORDS]; - uint64_t double_words[NODE_WORDS / 2]; + uint8_t bytes[NODE_WORDS * 4]; + uint32_t words[NODE_WORDS]; + uint64_t double_words[NODE_WORDS / 2]; #if defined(_M_X64) && ENABLE_SSE - __m128i xmm[NODE_WORDS/4]; + __m128i xmm[NODE_WORDS/4]; #elif defined(__MIC__) - __m512i zmm[NODE_WORDS/16]; + __m512i zmm[NODE_WORDS/16]; #endif } node; static inline uint8_t ethash_h256_get(ethash_h256_t const* hash, unsigned int i) { - return hash->b[i]; + return hash->b[i]; } static inline void ethash_h256_set(ethash_h256_t* hash, unsigned int i, uint8_t v) { - hash->b[i] = v; + hash->b[i] = v; } static inline void ethash_h256_reset(ethash_h256_t* hash) { - memset(hash, 0, 32); + memset(hash, 0, 32); } // Returns if hash is less than or equal to boundary (2^256/difficulty) static inline bool ethash_check_difficulty( - ethash_h256_t const* hash, - ethash_h256_t const* boundary + ethash_h256_t const* hash, + ethash_h256_t const* boundary ) { - // Boundary is big endian - for (int i = 0; i < 32; i++) { - if (ethash_h256_get(hash, i) == ethash_h256_get(boundary, i)) { - continue; - } - return ethash_h256_get(hash, i) < ethash_h256_get(boundary, i); - } - return true; + // Boundary is big endian + for (int i = 0; i < 32; i++) { + if (ethash_h256_get(hash, i) == ethash_h256_get(boundary, i)) { + continue; + } + return ethash_h256_get(hash, i) < ethash_h256_get(boundary, i); + } + return true; } /** @@ -76,16 +76,16 @@ static inline bool ethash_check_difficulty( * @return true for succesful pre-verification and false otherwise */ bool ethash_quick_check_difficulty( - ethash_h256_t const* header_hash, - uint64_t const nonce, - ethash_h256_t const* mix_hash, - ethash_h256_t const* boundary + ethash_h256_t const* header_hash, + uint64_t const nonce, + ethash_h256_t const* mix_hash, + ethash_h256_t const* boundary ); struct ethash_light { - void* cache; - uint64_t cache_size; - uint64_t block_number; + void* cache; + uint64_t cache_size; + uint64_t block_number; }; /** @@ -109,16 +109,16 @@ ethash_light_t ethash_light_new_internal(uint64_t cache_size, ethash_h256_t cons * @return The resulting hash. */ ethash_return_value_t ethash_light_compute_internal( - ethash_light_t light, - uint64_t full_size, - ethash_h256_t const header_hash, - uint64_t nonce + ethash_light_t light, + uint64_t full_size, + ethash_h256_t const header_hash, + uint64_t nonce ); struct ethash_full { - FILE* file; - uint64_t file_size; - node* data; + FILE* file; + uint64_t file_size; + node* data; }; /** @@ -139,24 +139,24 @@ struct ethash_full { * ERRNOMEM or invalid parameters used for @ref ethash_compute_full_data() */ ethash_full_t ethash_full_new_internal( - char const* dirname, - ethash_h256_t const seed_hash, - uint64_t full_size, - ethash_light_t const light, - ethash_callback_t callback + char const* dirname, + ethash_h256_t const seed_hash, + uint64_t full_size, + ethash_light_t const light, + ethash_callback_t callback ); void ethash_calculate_dag_item( - node* const ret, - uint32_t node_index, - ethash_light_t const cache + node* const ret, + uint32_t node_index, + ethash_light_t const cache ); void ethash_quick_hash( - ethash_h256_t* return_hash, - ethash_h256_t const* header_hash, - const uint64_t nonce, - ethash_h256_t const* mix_hash + ethash_h256_t* return_hash, + ethash_h256_t const* header_hash, + const uint64_t nonce, + ethash_h256_t const* mix_hash ); uint64_t ethash_get_datasize(uint64_t const block_number); @@ -172,10 +172,10 @@ uint64_t ethash_get_cachesize(uint64_t const block_number); * @return true if all went fine and false for invalid parameters */ bool ethash_compute_full_data( - void* mem, - uint64_t full_size, - ethash_light_t const light, - ethash_callback_t callback + void* mem, + uint64_t full_size, + ethash_light_t const light, + ethash_callback_t callback ); #ifdef __cplusplus diff --git a/include/metaverse/consensus/libethash/io.c b/include/metaverse/consensus/libethash/io.c index f4db477c2..893b2a26b 100644 --- a/include/metaverse/consensus/libethash/io.c +++ b/include/metaverse/consensus/libethash/io.c @@ -24,96 +24,96 @@ #include enum ethash_io_rc ethash_io_prepare( - char const* dirname, - ethash_h256_t const seedhash, - FILE** output_file, - uint64_t file_size, - bool force_create + char const* dirname, + ethash_h256_t const seedhash, + FILE** output_file, + uint64_t file_size, + bool force_create ) { - char mutable_name[DAG_MUTABLE_NAME_MAX_SIZE]; - enum ethash_io_rc ret = ETHASH_IO_FAIL; - // reset errno before io calls - errno = 0; + char mutable_name[DAG_MUTABLE_NAME_MAX_SIZE]; + enum ethash_io_rc ret = ETHASH_IO_FAIL; + // reset errno before io calls + errno = 0; - // assert directory exists - if (!ethash_mkdir(dirname)) { - ETHASH_CRITICAL("Could not create the ethash directory"); - goto end; - } + // assert directory exists + if (!ethash_mkdir(dirname)) { + ETHASH_CRITICAL("Could not create the ethash directory"); + goto end; + } - ethash_io_mutable_name(ETHASH_REVISION, &seedhash, mutable_name); - char* tmpfile = ethash_io_create_filename(dirname, mutable_name, strlen(mutable_name)); - if (!tmpfile) { - ETHASH_CRITICAL("Could not create the full DAG pathname"); - goto end; - } + ethash_io_mutable_name(ETHASH_REVISION, &seedhash, mutable_name); + char* tmpfile = ethash_io_create_filename(dirname, mutable_name, strlen(mutable_name)); + if (!tmpfile) { + ETHASH_CRITICAL("Could not create the full DAG pathname"); + goto end; + } - FILE *f; - if (!force_create) { - // try to open the file - f = ethash_fopen(tmpfile, "rb+"); - if (f) { - size_t found_size; - if (!ethash_file_size(f, &found_size)) { - fclose(f); - ETHASH_CRITICAL("Could not query size of DAG file: \"%s\"", tmpfile); - goto free_memo; - } - if (file_size != found_size - ETHASH_DAG_MAGIC_NUM_SIZE) { - fclose(f); - ret = ETHASH_IO_MEMO_SIZE_MISMATCH; - goto free_memo; - } - // compare the magic number, no need to care about endianess since it's local - uint64_t magic_num; - if (fread(&magic_num, ETHASH_DAG_MAGIC_NUM_SIZE, 1, f) != 1) { - // I/O error - fclose(f); - ETHASH_CRITICAL("Could not read from DAG file: \"%s\"", tmpfile); - ret = ETHASH_IO_MEMO_SIZE_MISMATCH; - goto free_memo; - } - if (magic_num != ETHASH_DAG_MAGIC_NUM) { - fclose(f); - ret = ETHASH_IO_MEMO_SIZE_MISMATCH; - goto free_memo; - } - ret = ETHASH_IO_MEMO_MATCH; - goto set_file; - } - } - - // file does not exist, will need to be created - f = ethash_fopen(tmpfile, "wb+"); - if (!f) { - ETHASH_CRITICAL("Could not create DAG file: \"%s\"", tmpfile); - goto free_memo; - } - // make sure it's of the proper size - if (fseek(f, (long int)(file_size + ETHASH_DAG_MAGIC_NUM_SIZE - 1), SEEK_SET) != 0) { - fclose(f); - ETHASH_CRITICAL("Could not seek to the end of DAG file: \"%s\". Insufficient space?", tmpfile); - goto free_memo; - } - if (fputc('\n', f) == EOF) { - fclose(f); - ETHASH_CRITICAL("Could not write in the end of DAG file: \"%s\". Insufficient space?", tmpfile); - goto free_memo; - } - if (fflush(f) != 0) { - fclose(f); - ETHASH_CRITICAL("Could not flush at end of DAG file: \"%s\". Insufficient space?", tmpfile); - goto free_memo; - } - ret = ETHASH_IO_MEMO_MISMATCH; - goto set_file; + FILE *f; + if (!force_create) { + // try to open the file + f = ethash_fopen(tmpfile, "rb+"); + if (f) { + size_t found_size; + if (!ethash_file_size(f, &found_size)) { + fclose(f); + ETHASH_CRITICAL("Could not query size of DAG file: \"%s\"", tmpfile); + goto free_memo; + } + if (file_size != found_size - ETHASH_DAG_MAGIC_NUM_SIZE) { + fclose(f); + ret = ETHASH_IO_MEMO_SIZE_MISMATCH; + goto free_memo; + } + // compare the magic number, no need to care about endianess since it's local + uint64_t magic_num; + if (fread(&magic_num, ETHASH_DAG_MAGIC_NUM_SIZE, 1, f) != 1) { + // I/O error + fclose(f); + ETHASH_CRITICAL("Could not read from DAG file: \"%s\"", tmpfile); + ret = ETHASH_IO_MEMO_SIZE_MISMATCH; + goto free_memo; + } + if (magic_num != ETHASH_DAG_MAGIC_NUM) { + fclose(f); + ret = ETHASH_IO_MEMO_SIZE_MISMATCH; + goto free_memo; + } + ret = ETHASH_IO_MEMO_MATCH; + goto set_file; + } + } - ret = ETHASH_IO_MEMO_MATCH; + // file does not exist, will need to be created + f = ethash_fopen(tmpfile, "wb+"); + if (!f) { + ETHASH_CRITICAL("Could not create DAG file: \"%s\"", tmpfile); + goto free_memo; + } + // make sure it's of the proper size + if (fseek(f, (long int)(file_size + ETHASH_DAG_MAGIC_NUM_SIZE - 1), SEEK_SET) != 0) { + fclose(f); + ETHASH_CRITICAL("Could not seek to the end of DAG file: \"%s\". Insufficient space?", tmpfile); + goto free_memo; + } + if (fputc('\n', f) == EOF) { + fclose(f); + ETHASH_CRITICAL("Could not write in the end of DAG file: \"%s\". Insufficient space?", tmpfile); + goto free_memo; + } + if (fflush(f) != 0) { + fclose(f); + ETHASH_CRITICAL("Could not flush at end of DAG file: \"%s\". Insufficient space?", tmpfile); + goto free_memo; + } + ret = ETHASH_IO_MEMO_MISMATCH; + goto set_file; + + ret = ETHASH_IO_MEMO_MATCH; set_file: - *output_file = f; + *output_file = f; free_memo: - free(tmpfile); + free(tmpfile); end: - return ret; + return ret; } diff --git a/include/metaverse/consensus/libethash/io.h b/include/metaverse/consensus/libethash/io.h index 7a27089c7..91dde11ef 100644 --- a/include/metaverse/consensus/libethash/io.h +++ b/include/metaverse/consensus/libethash/io.h @@ -42,10 +42,10 @@ extern "C" { #define DAG_MUTABLE_NAME_MAX_SIZE (6 + 10 + 1 + 16 + 1) /// Possible return values of @see ethash_io_prepare enum ethash_io_rc { - ETHASH_IO_FAIL = 0, ///< There has been an IO failure - ETHASH_IO_MEMO_SIZE_MISMATCH, ///< DAG with revision/hash match, but file size was wrong. - ETHASH_IO_MEMO_MISMATCH, ///< The DAG file did not exist or there was revision/hash mismatch - ETHASH_IO_MEMO_MATCH, ///< DAG file existed and revision/hash matched. No need to do anything + ETHASH_IO_FAIL = 0, ///< There has been an IO failure + ETHASH_IO_MEMO_SIZE_MISMATCH, ///< DAG with revision/hash match, but file size was wrong. + ETHASH_IO_MEMO_MISMATCH, ///< The DAG file did not exist or there was revision/hash mismatch + ETHASH_IO_MEMO_MATCH, ///< DAG file existed and revision/hash matched. No need to do anything }; // small hack for windows. I don't feel I should use va_args and forward just @@ -60,15 +60,15 @@ enum ethash_io_rc { * ethash_full_t */ #ifdef ETHASH_PRINT_CRITICAL_OUTPUT -#define ETHASH_CRITICAL(...) \ - do \ - { \ - printf("ETHASH CRITICAL ERROR: "__VA_ARGS__); \ - printf("\n"); \ - fflush(stdout); \ - } while (0) +#define ETHASH_CRITICAL(...) \ + do \ + { \ + printf("ETHASH CRITICAL ERROR: "__VA_ARGS__); \ + printf("\n"); \ + fflush(stdout); \ + } while (0) #else -#define ETHASH_CRITICAL(...) +#define ETHASH_CRITICAL(...) #endif /** @@ -92,11 +92,11 @@ enum ethash_io_rc { * @return For possible return values @see enum ethash_io_rc */ enum ethash_io_rc ethash_io_prepare( - char const* dirname, - ethash_h256_t const seedhash, - FILE** output_file, - uint64_t file_size, - bool force_create + char const* dirname, + ethash_h256_t const seedhash, + FILE** output_file, + uint64_t file_size, + bool force_create ); /** @@ -167,9 +167,9 @@ int ethash_fileno(FILE* f); * @return A char* containing the full name. User must deallocate. */ char* ethash_io_create_filename( - char const* dirname, - char const* filename, - size_t filename_length + char const* dirname, + char const* filename, + size_t filename_length ); /** @@ -185,9 +185,9 @@ char* ethash_io_create_filename( bool ethash_get_default_dirname(char* strbuf, size_t buffsize); static inline bool ethash_io_mutable_name( - uint32_t revision, - ethash_h256_t const* seed_hash, - char* output + uint32_t revision, + ethash_h256_t const* seed_hash, + char* output ) { uint64_t hash = *((uint64_t*)seed_hash); diff --git a/include/metaverse/consensus/libethash/io_posix.c b/include/metaverse/consensus/libethash/io_posix.c index 44667ea45..fd444389c 100644 --- a/include/metaverse/consensus/libethash/io_posix.c +++ b/include/metaverse/consensus/libethash/io_posix.c @@ -31,83 +31,83 @@ FILE* ethash_fopen(char const* file_name, char const* mode) { - return fopen(file_name, mode); + return fopen(file_name, mode); } char* ethash_strncat(char* dest, size_t dest_size, char const* src, size_t count) { - return strlen(dest) + count + 1 <= dest_size ? strncat(dest, src, count) : NULL; + return strlen(dest) + count + 1 <= dest_size ? strncat(dest, src, count) : NULL; } bool ethash_mkdir(char const* dirname) { - int rc = mkdir(dirname, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH); - return rc != -1 || errno == EEXIST; + int rc = mkdir(dirname, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH); + return rc != -1 || errno == EEXIST; } int ethash_fileno(FILE *f) { - return fileno(f); + return fileno(f); } char* ethash_io_create_filename( - char const* dirname, - char const* filename, - size_t filename_length + char const* dirname, + char const* filename, + size_t filename_length ) { - size_t dirlen = strlen(dirname); - size_t dest_size = dirlen + filename_length + 1; - if (dirname[dirlen] != '/') { - dest_size += 1; - } - char* name = malloc(dest_size); - if (!name) { - return NULL; - } + size_t dirlen = strlen(dirname); + size_t dest_size = dirlen + filename_length + 1; + if (dirname[dirlen] != '/') { + dest_size += 1; + } + char* name = malloc(dest_size); + if (!name) { + return NULL; + } - name[0] = '\0'; - ethash_strncat(name, dest_size, dirname, dirlen); - if (dirname[dirlen] != '/') { - ethash_strncat(name, dest_size, "/", 1); - } - ethash_strncat(name, dest_size, filename, filename_length); - return name; + name[0] = '\0'; + ethash_strncat(name, dest_size, dirname, dirlen); + if (dirname[dirlen] != '/') { + ethash_strncat(name, dest_size, "/", 1); + } + ethash_strncat(name, dest_size, filename, filename_length); + return name; } bool ethash_file_size(FILE* f, size_t* ret_size) { - struct stat st; - int fd; - if ((fd = fileno(f)) == -1 || fstat(fd, &st) != 0) { - return false; - } - *ret_size = st.st_size; - return true; + struct stat st; + int fd; + if ((fd = fileno(f)) == -1 || fstat(fd, &st) != 0) { + return false; + } + *ret_size = st.st_size; + return true; } bool ethash_get_default_dirname(char* strbuf, size_t buffsize) { - static const char dir_suffix[] = ".ethash/"; - strbuf[0] = '\0'; - char* home_dir = getenv("HOME"); - if (!home_dir || strlen(home_dir) == 0) - { - struct passwd* pwd = getpwuid(getuid()); - if (pwd) - home_dir = pwd->pw_dir; - if (!home_dir) - return false; - } - - size_t len = strlen(home_dir); - if (!ethash_strncat(strbuf, buffsize, home_dir, len)) { - return false; - } - if (home_dir[len] != '/') { - if (!ethash_strncat(strbuf, buffsize, "/", 1)) { - return false; - } - } - return ethash_strncat(strbuf, buffsize, dir_suffix, sizeof(dir_suffix)); + static const char dir_suffix[] = ".ethash/"; + strbuf[0] = '\0'; + char* home_dir = getenv("HOME"); + if (!home_dir || strlen(home_dir) == 0) + { + struct passwd* pwd = getpwuid(getuid()); + if (pwd) + home_dir = pwd->pw_dir; + if (!home_dir) + return false; + } + + size_t len = strlen(home_dir); + if (!ethash_strncat(strbuf, buffsize, home_dir, len)) { + return false; + } + if (home_dir[len] != '/') { + if (!ethash_strncat(strbuf, buffsize, "/", 1)) { + return false; + } + } + return ethash_strncat(strbuf, buffsize, dir_suffix, sizeof(dir_suffix)); } diff --git a/include/metaverse/consensus/libethash/io_win32.c b/include/metaverse/consensus/libethash/io_win32.c index 34f1aaa77..6fcf041b5 100644 --- a/include/metaverse/consensus/libethash/io_win32.c +++ b/include/metaverse/consensus/libethash/io_win32.c @@ -29,72 +29,72 @@ FILE* ethash_fopen(char const* file_name, char const* mode) { - FILE* f; - return fopen_s(&f, file_name, mode) == 0 ? f : NULL; + FILE* f; + return fopen_s(&f, file_name, mode) == 0 ? f : NULL; } char* ethash_strncat(char* dest, size_t dest_size, char const* src, size_t count) { - return strncat_s(dest, dest_size, src, count) == 0 ? dest : NULL; + return strncat_s(dest, dest_size, src, count) == 0 ? dest : NULL; } bool ethash_mkdir(char const* dirname) { - int rc = _mkdir(dirname); - return rc != -1 || errno == EEXIST; + int rc = _mkdir(dirname); + return rc != -1 || errno == EEXIST; } int ethash_fileno(FILE* f) { - return _fileno(f); + return _fileno(f); } char* ethash_io_create_filename( - char const* dirname, - char const* filename, - size_t filename_length + char const* dirname, + char const* filename, + size_t filename_length ) { - size_t dirlen = strlen(dirname); - size_t dest_size = dirlen + filename_length + 1; - if (dirname[dirlen] != '\\' || dirname[dirlen] != '/') { - dest_size += 1; - } - char* name = malloc(dest_size); - if (!name) { - return NULL; - } + size_t dirlen = strlen(dirname); + size_t dest_size = dirlen + filename_length + 1; + if (dirname[dirlen] != '\\' || dirname[dirlen] != '/') { + dest_size += 1; + } + char* name = malloc(dest_size); + if (!name) { + return NULL; + } - name[0] = '\0'; - ethash_strncat(name, dest_size, dirname, dirlen); - if (dirname[dirlen] != '\\' || dirname[dirlen] != '/') { - ethash_strncat(name, dest_size, "\\", 1); - } - ethash_strncat(name, dest_size, filename, filename_length); - return name; + name[0] = '\0'; + ethash_strncat(name, dest_size, dirname, dirlen); + if (dirname[dirlen] != '\\' || dirname[dirlen] != '/') { + ethash_strncat(name, dest_size, "\\", 1); + } + ethash_strncat(name, dest_size, filename, filename_length); + return name; } bool ethash_file_size(FILE* f, size_t* ret_size) { - struct _stat st; - int fd; - if ((fd = _fileno(f)) == -1 || _fstat(fd, &st) != 0) { - return false; - } - *ret_size = st.st_size; - return true; + struct _stat st; + int fd; + if ((fd = _fileno(f)) == -1 || _fstat(fd, &st) != 0) { + return false; + } + *ret_size = st.st_size; + return true; } bool ethash_get_default_dirname(char* strbuf, size_t buffsize) { - static const char dir_suffix[] = "Ethash\\"; - strbuf[0] = '\0'; - if (!SUCCEEDED(SHGetFolderPathA(NULL, CSIDL_LOCAL_APPDATA, NULL, 0, (CHAR*)strbuf))) { - return false; - } - if (!ethash_strncat(strbuf, buffsize, "\\", 1)) { - return false; - } + static const char dir_suffix[] = "Ethash\\"; + strbuf[0] = '\0'; + if (!SUCCEEDED(SHGetFolderPathA(NULL, CSIDL_LOCAL_APPDATA, NULL, 0, (CHAR*)strbuf))) { + return false; + } + if (!ethash_strncat(strbuf, buffsize, "\\", 1)) { + return false; + } - return ethash_strncat(strbuf, buffsize, dir_suffix, sizeof(dir_suffix)); + return ethash_strncat(strbuf, buffsize, dir_suffix, sizeof(dir_suffix)); } diff --git a/include/metaverse/consensus/libethash/mmap_win32.c b/include/metaverse/consensus/libethash/mmap_win32.c index 42968b98a..9d548cdf3 100644 --- a/include/metaverse/consensus/libethash/mmap_win32.c +++ b/include/metaverse/consensus/libethash/mmap_win32.c @@ -25,59 +25,59 @@ void* mmap(void* start, size_t length, int prot, int flags, int fd, off_t offset) { - if (prot & ~(PROT_READ | PROT_WRITE | PROT_EXEC)) - return MAP_FAILED; - if (fd == -1) { - if (!(flags & MAP_ANON) || offset) - return MAP_FAILED; - } else if (flags & MAP_ANON) - return MAP_FAILED; + if (prot & ~(PROT_READ | PROT_WRITE | PROT_EXEC)) + return MAP_FAILED; + if (fd == -1) { + if (!(flags & MAP_ANON) || offset) + return MAP_FAILED; + } else if (flags & MAP_ANON) + return MAP_FAILED; - DWORD flProtect; - if (prot & PROT_WRITE) { - if (prot & PROT_EXEC) - flProtect = PAGE_EXECUTE_READWRITE; - else - flProtect = PAGE_READWRITE; - } else if (prot & PROT_EXEC) { - if (prot & PROT_READ) - flProtect = PAGE_EXECUTE_READ; - else if (prot & PROT_EXEC) - flProtect = PAGE_EXECUTE; - } else - flProtect = PAGE_READONLY; + DWORD flProtect; + if (prot & PROT_WRITE) { + if (prot & PROT_EXEC) + flProtect = PAGE_EXECUTE_READWRITE; + else + flProtect = PAGE_READWRITE; + } else if (prot & PROT_EXEC) { + if (prot & PROT_READ) + flProtect = PAGE_EXECUTE_READ; + else if (prot & PROT_EXEC) + flProtect = PAGE_EXECUTE; + } else + flProtect = PAGE_READONLY; - off_t end = length + offset; - HANDLE mmap_fd, h; - if (fd == -1) - mmap_fd = INVALID_HANDLE_VALUE; - else - mmap_fd = (HANDLE)_get_osfhandle(fd); - h = CreateFileMapping(mmap_fd, NULL, flProtect, DWORD_HI(end), DWORD_LO(end), NULL); - if (h == NULL) - return MAP_FAILED; + off_t end = length + offset; + HANDLE mmap_fd, h; + if (fd == -1) + mmap_fd = INVALID_HANDLE_VALUE; + else + mmap_fd = (HANDLE)_get_osfhandle(fd); + h = CreateFileMapping(mmap_fd, NULL, flProtect, DWORD_HI(end), DWORD_LO(end), NULL); + if (h == NULL) + return MAP_FAILED; - DWORD dwDesiredAccess; - if (prot & PROT_WRITE) - dwDesiredAccess = FILE_MAP_WRITE; - else - dwDesiredAccess = FILE_MAP_READ; - if (prot & PROT_EXEC) - dwDesiredAccess |= FILE_MAP_EXECUTE; - if (flags & MAP_PRIVATE) - dwDesiredAccess |= FILE_MAP_COPY; - void *ret = MapViewOfFile(h, dwDesiredAccess, DWORD_HI(offset), DWORD_LO(offset), length); - if (ret == NULL) { - ret = MAP_FAILED; - } - // since we are handling the file ourselves with fd, close the Windows Handle here - CloseHandle(h); - return ret; + DWORD dwDesiredAccess; + if (prot & PROT_WRITE) + dwDesiredAccess = FILE_MAP_WRITE; + else + dwDesiredAccess = FILE_MAP_READ; + if (prot & PROT_EXEC) + dwDesiredAccess |= FILE_MAP_EXECUTE; + if (flags & MAP_PRIVATE) + dwDesiredAccess |= FILE_MAP_COPY; + void *ret = MapViewOfFile(h, dwDesiredAccess, DWORD_HI(offset), DWORD_LO(offset), length); + if (ret == NULL) { + ret = MAP_FAILED; + } + // since we are handling the file ourselves with fd, close the Windows Handle here + CloseHandle(h); + return ret; } void munmap(void* addr, size_t length) { - UnmapViewOfFile(addr); + UnmapViewOfFile(addr); } #undef DWORD_HI diff --git a/include/metaverse/consensus/libethash/sha3.c b/include/metaverse/consensus/libethash/sha3.c index e72fe1018..fb1fa7803 100644 --- a/include/metaverse/consensus/libethash/sha3.c +++ b/include/metaverse/consensus/libethash/sha3.c @@ -17,65 +17,65 @@ /*** Constants. ***/ static const uint8_t rho[24] = \ - { 1, 3, 6, 10, 15, 21, - 28, 36, 45, 55, 2, 14, - 27, 41, 56, 8, 25, 43, - 62, 18, 39, 61, 20, 44}; + { 1, 3, 6, 10, 15, 21, + 28, 36, 45, 55, 2, 14, + 27, 41, 56, 8, 25, 43, + 62, 18, 39, 61, 20, 44}; static const uint8_t pi[24] = \ - {10, 7, 11, 17, 18, 3, - 5, 16, 8, 21, 24, 4, - 15, 23, 19, 13, 12, 2, - 20, 14, 22, 9, 6, 1}; + {10, 7, 11, 17, 18, 3, + 5, 16, 8, 21, 24, 4, + 15, 23, 19, 13, 12, 2, + 20, 14, 22, 9, 6, 1}; static const uint64_t RC[24] = \ - {1ULL, 0x8082ULL, 0x800000000000808aULL, 0x8000000080008000ULL, - 0x808bULL, 0x80000001ULL, 0x8000000080008081ULL, 0x8000000000008009ULL, - 0x8aULL, 0x88ULL, 0x80008009ULL, 0x8000000aULL, - 0x8000808bULL, 0x800000000000008bULL, 0x8000000000008089ULL, 0x8000000000008003ULL, - 0x8000000000008002ULL, 0x8000000000000080ULL, 0x800aULL, 0x800000008000000aULL, - 0x8000000080008081ULL, 0x8000000000008080ULL, 0x80000001ULL, 0x8000000080008008ULL}; + {1ULL, 0x8082ULL, 0x800000000000808aULL, 0x8000000080008000ULL, + 0x808bULL, 0x80000001ULL, 0x8000000080008081ULL, 0x8000000000008009ULL, + 0x8aULL, 0x88ULL, 0x80008009ULL, 0x8000000aULL, + 0x8000808bULL, 0x800000000000008bULL, 0x8000000000008089ULL, 0x8000000000008003ULL, + 0x8000000000008002ULL, 0x8000000000000080ULL, 0x800aULL, 0x800000008000000aULL, + 0x8000000080008081ULL, 0x8000000000008080ULL, 0x80000001ULL, 0x8000000080008008ULL}; /*** Helper macros to unroll the permutation. ***/ #define rol(x, s) (((x) << s) | ((x) >> (64 - s))) #define REPEAT6(e) e e e e e e #define REPEAT24(e) REPEAT6(e e e e) #define REPEAT5(e) e e e e e -#define FOR5(v, s, e) \ - v = 0; \ - REPEAT5(e; v += s;) +#define FOR5(v, s, e) \ + v = 0; \ + REPEAT5(e; v += s;) /*** Keccak-f[1600] ***/ static inline void keccakf(void* state) { - uint64_t* a = (uint64_t*)state; - uint64_t b[5] = {0}; - uint64_t t = 0; - uint8_t x, y; + uint64_t* a = (uint64_t*)state; + uint64_t b[5] = {0}; + uint64_t t = 0; + uint8_t x, y; - for (int i = 0; i < 24; i++) { - // Theta - FOR5(x, 1, - b[x] = 0; - FOR5(y, 5, - b[x] ^= a[x + y]; )) - FOR5(x, 1, - FOR5(y, 5, - a[y + x] ^= b[(x + 4) % 5] ^ rol(b[(x + 1) % 5], 1); )) - // Rho and pi - t = a[1]; - x = 0; - REPEAT24(b[0] = a[pi[x]]; - a[pi[x]] = rol(t, rho[x]); - t = b[0]; - x++; ) - // Chi - FOR5(y, - 5, - FOR5(x, 1, - b[x] = a[y + x];) - FOR5(x, 1, - a[y + x] = b[x] ^ ((~b[(x + 1) % 5]) & b[(x + 2) % 5]); )) - // Iota - a[0] ^= RC[i]; - } + for (int i = 0; i < 24; i++) { + // Theta + FOR5(x, 1, + b[x] = 0; + FOR5(y, 5, + b[x] ^= a[x + y]; )) + FOR5(x, 1, + FOR5(y, 5, + a[y + x] ^= b[(x + 4) % 5] ^ rol(b[(x + 1) % 5], 1); )) + // Rho and pi + t = a[1]; + x = 0; + REPEAT24(b[0] = a[pi[x]]; + a[pi[x]] = rol(t, rho[x]); + t = b[0]; + x++; ) + // Chi + FOR5(y, + 5, + FOR5(x, 1, + b[x] = a[y + x];) + FOR5(x, 1, + a[y + x] = b[x] ^ ((~b[(x + 1) % 5]) & b[(x + 2) % 5]); )) + // Iota + a[0] ^= RC[i]; + } } /******** The FIPS202-defined functions. ********/ @@ -83,20 +83,20 @@ static inline void keccakf(void* state) { /*** Some helper macros. ***/ #define _(S) do { S } while (0) -#define FOR(i, ST, L, S) \ - _(for (size_t i = 0; i < L; i += ST) { S; }) -#define mkapply_ds(NAME, S) \ - static inline void NAME(uint8_t* dst, \ - const uint8_t* src, \ - size_t len) { \ - FOR(i, 1, len, S); \ - } -#define mkapply_sd(NAME, S) \ - static inline void NAME(const uint8_t* src, \ - uint8_t* dst, \ - size_t len) { \ - FOR(i, 1, len, S); \ - } +#define FOR(i, ST, L, S) \ + _(for (size_t i = 0; i < L; i += ST) { S; }) +#define mkapply_ds(NAME, S) \ + static inline void NAME(uint8_t* dst, \ + const uint8_t* src, \ + size_t len) { \ + FOR(i, 1, len, S); \ + } +#define mkapply_sd(NAME, S) \ + static inline void NAME(const uint8_t* src, \ + uint8_t* dst, \ + size_t len) { \ + FOR(i, 1, len, S); \ + } mkapply_ds(xorin, dst[i] ^= src[i]) // xorin mkapply_sd(setout, dst[i] = src[i]) // setout @@ -105,46 +105,46 @@ mkapply_sd(setout, dst[i] = src[i]) // setout #define Plen 200 // Fold P*F over the full blocks of an input. -#define foldP(I, L, F) \ - while (L >= rate) { \ - F(a, I, rate); \ - P(a); \ - I += rate; \ - L -= rate; \ - } +#define foldP(I, L, F) \ + while (L >= rate) { \ + F(a, I, rate); \ + P(a); \ + I += rate; \ + L -= rate; \ + } /** The sponge-based hash construction. **/ static inline int hash(uint8_t* out, size_t outlen, - const uint8_t* in, size_t inlen, - size_t rate, uint8_t delim) { - if ((out == NULL) || ((in == NULL) && inlen != 0) || (rate >= Plen)) { - return -1; - } - uint8_t a[Plen] = {0}; - // Absorb input. - foldP(in, inlen, xorin); - // Xor in the DS and pad frame. - a[inlen] ^= delim; - a[rate - 1] ^= 0x80; - // Xor in the last block. - xorin(a, in, inlen); - // Apply P - P(a); - // Squeeze output. - foldP(out, outlen, setout); - setout(a, out, outlen); - memset(a, 0, 200); - return 0; + const uint8_t* in, size_t inlen, + size_t rate, uint8_t delim) { + if ((out == NULL) || ((in == NULL) && inlen != 0) || (rate >= Plen)) { + return -1; + } + uint8_t a[Plen] = {0}; + // Absorb input. + foldP(in, inlen, xorin); + // Xor in the DS and pad frame. + a[inlen] ^= delim; + a[rate - 1] ^= 0x80; + // Xor in the last block. + xorin(a, in, inlen); + // Apply P + P(a); + // Squeeze output. + foldP(out, outlen, setout); + setout(a, out, outlen); + memset(a, 0, 200); + return 0; } -#define defsha3(bits) \ - int sha3_##bits(uint8_t* out, size_t outlen, \ - const uint8_t* in, size_t inlen) { \ - if (outlen > (bits/8)) { \ - return -1; \ - } \ - return hash(out, outlen, in, inlen, 200 - (bits / 4), 0x01); \ - } +#define defsha3(bits) \ + int sha3_##bits(uint8_t* out, size_t outlen, \ + const uint8_t* in, size_t inlen) { \ + if (outlen > (bits/8)) { \ + return -1; \ + } \ + return hash(out, outlen, in, inlen, 200 - (bits / 4), 0x01); \ + } /*** FIPS202 SHA3 FOFs ***/ defsha3(256) diff --git a/include/metaverse/consensus/libethash/sha3.h b/include/metaverse/consensus/libethash/sha3.h index a38006292..87dfcaed4 100644 --- a/include/metaverse/consensus/libethash/sha3.h +++ b/include/metaverse/consensus/libethash/sha3.h @@ -11,19 +11,19 @@ extern "C" { struct ethash_h256; #define decsha3(bits) \ - int sha3_##bits(uint8_t*, size_t, uint8_t const*, size_t); + int sha3_##bits(uint8_t*, size_t, uint8_t const*, size_t); decsha3(256) decsha3(512) static inline void SHA3_256(struct ethash_h256 const* ret, uint8_t const* data, size_t const size) { - sha3_256((uint8_t*)ret, 32, data, size); + sha3_256((uint8_t*)ret, 32, data, size); } static inline void SHA3_512(uint8_t* ret, uint8_t const* data, size_t const size) { - sha3_512(ret, 64, data, size); + sha3_512(ret, 64, data, size); } #ifdef __cplusplus diff --git a/include/metaverse/consensus/libethash/util.c b/include/metaverse/consensus/libethash/util.c index fbf268b7d..9309314d0 100644 --- a/include/metaverse/consensus/libethash/util.c +++ b/include/metaverse/consensus/libethash/util.c @@ -29,13 +29,13 @@ __declspec(dllimport) void __stdcall OutputDebugStringA(const char* lpOutputStri void debugf(const char *str, ...) { - va_list args; + va_list args; va_start(args, str); - char buf[1<<16]; - _vsnprintf_s(buf, sizeof(buf), sizeof(buf), str, args); - buf[sizeof(buf)-1] = '\0'; - OutputDebugStringA(buf); + char buf[1<<16]; + _vsnprintf_s(buf, sizeof(buf), sizeof(buf), str, args); + buf[sizeof(buf)-1] = '\0'; + OutputDebugStringA(buf); } #endif diff --git a/include/metaverse/consensus/libethash/util.h b/include/metaverse/consensus/libethash/util.h index c5fc6e55b..e89319ff0 100644 --- a/include/metaverse/consensus/libethash/util.h +++ b/include/metaverse/consensus/libethash/util.h @@ -34,12 +34,12 @@ void debugf(char const* str, ...); static inline uint32_t min_u32(uint32_t a, uint32_t b) { - return a < b ? a : b; + return a < b ? a : b; } static inline uint32_t clamp_u32(uint32_t x, uint32_t min_, uint32_t max_) { - return x < min_ ? min_ : (x > max_ ? max_ : x); + return x < min_ ? min_ : (x > max_ ? max_ : x); } #ifdef __cplusplus diff --git a/include/metaverse/consensus/libethash/util_win32.c b/include/metaverse/consensus/libethash/util_win32.c index 268e6db05..d980fbdda 100644 --- a/include/metaverse/consensus/libethash/util_win32.c +++ b/include/metaverse/consensus/libethash/util_win32.c @@ -28,11 +28,11 @@ __declspec(dllimport) void __stdcall OutputDebugStringA(char const* lpOutputStri void debugf(char const* str, ...) { - va_list args; - va_start(args, str); + va_list args; + va_start(args, str); - char buf[1<<16]; - _vsnprintf_s(buf, sizeof(buf), sizeof(buf), str, args); - buf[sizeof(buf)-1] = '\0'; - OutputDebugStringA(buf); + char buf[1<<16]; + _vsnprintf_s(buf, sizeof(buf), sizeof(buf), str, args); + buf[sizeof(buf)-1] = '\0'; + OutputDebugStringA(buf); } diff --git a/include/metaverse/consensus/miner/MinerAux.h b/include/metaverse/consensus/miner/MinerAux.h index 3b72b8397..0104a765d 100644 --- a/include/metaverse/consensus/miner/MinerAux.h +++ b/include/metaverse/consensus/miner/MinerAux.h @@ -15,21 +15,21 @@ namespace libbitcoin class MinerAux { public: - ~MinerAux(); - static MinerAux* get(); - //static h256 mixHash(chain::header& _bi) { return _bi;} - static void setNonce(chain::header& _bi, Nonce _v){_bi.nonce = (FixedHash<8>::Arith)_v; } - static void setMixHash(chain::header& _bi, h256& _v){_bi.mixhash = (FixedHash<32>::Arith)_v; } - static LightType get_light(h256& _seedHash); - static FullType get_full(h256& _seedHash); - static bool verifySeal(chain::header& header,chain::header& _parent); - static bool search(chain::header& header, std::function is_exit); + ~MinerAux(); + static MinerAux* get(); + //static h256 mixHash(chain::header& _bi) { return _bi;} + static void setNonce(chain::header& _bi, Nonce _v){_bi.nonce = (FixedHash<8>::Arith)_v; } + static void setMixHash(chain::header& _bi, h256& _v){_bi.mixhash = (FixedHash<32>::Arith)_v; } + static LightType get_light(h256& _seedHash); + static FullType get_full(h256& _seedHash); + static bool verifySeal(chain::header& header,chain::header& _parent); + static bool search(chain::header& header, std::function is_exit); static uint64_t getRate(){ return get()->m_rate; } private: - MinerAux() {m_rate = 0;} + MinerAux() {m_rate = 0;} static MinerAux* s_this; SharedMutex x_lights; std::unordered_map> m_lights; diff --git a/include/metaverse/database.hpp b/include/metaverse/database.hpp index a60d00536..18498c252 100644 --- a/include/metaverse/database.hpp +++ b/include/metaverse/database.hpp @@ -8,7 +8,7 @@ #define MVS_DATABASE_HPP /** - * API Users: Include only this header. Direct use of other headers is fragile + * API Users: Include only this header. Direct use of other headers is fragile * and unsupported as header organization is subject to change. * * Maintainers: Do not include this header internal to this library. diff --git a/include/metaverse/database/databases/account_address_database.hpp b/include/metaverse/database/databases/account_address_database.hpp index 91232abfb..5ca081424 100644 --- a/include/metaverse/database/databases/account_address_database.hpp +++ b/include/metaverse/database/databases/account_address_database.hpp @@ -72,15 +72,15 @@ class BCD_API account_address_database /// Call to unload the memory map. bool close(); - /// store account address into database - void store(const short_hash& key, const account_address& account_address); - - /// get account address vector by key - account_address::list get(const short_hash& key) const; - - /// get account address according by key and address - std::shared_ptr get(const short_hash& key, const std::string& address) const; - + /// store account address into database + void store(const short_hash& key, const account_address& account_address); + + /// get account address vector by key + account_address::list get(const short_hash& key) const; + + /// get account address according by key and address + std::shared_ptr get(const short_hash& key, const std::string& address) const; + /// Delete the last row that was added to key. void delete_last_row(const short_hash& key); diff --git a/include/metaverse/database/databases/address_did_database.hpp b/include/metaverse/database/databases/address_did_database.hpp index 10deba774..158d2e3c3 100644 --- a/include/metaverse/database/databases/address_did_database.hpp +++ b/include/metaverse/database/databases/address_did_database.hpp @@ -71,53 +71,53 @@ class BCD_API address_did_database /// Call to unload the memory map. bool close(); - - template - void store_output(const short_hash& key, const output_point& outpoint, - uint32_t output_height, uint64_t value, uint16_t business_kd, uint32_t timestamp, BusinessDataType& business_data) - { + + template + void store_output(const short_hash& key, const output_point& outpoint, + uint32_t output_height, uint64_t value, uint16_t business_kd, uint32_t timestamp, BusinessDataType& business_data) + { //delete_last_row(key); - auto write = [&](memory_ptr data) - { - auto serial = make_serializer(REMAP_ADDRESS(data)); - serial.write_byte(static_cast(point_kind::output)); // 1 - serial.write_data(outpoint.to_data()); // 36 - serial.write_4_bytes_little_endian(output_height); // 4 - serial.write_8_bytes_little_endian(value); // 8 - serial.write_2_bytes_little_endian(business_kd); // 2 - serial.write_4_bytes_little_endian(timestamp); // 4 - serial.write_data(business_data.to_data()); - }; - rows_multimap_.add_row(key, write); - } - - void store_input(const short_hash& key, - const output_point& inpoint, uint32_t input_height, - const input_point& previous, uint32_t timestamp); - - business_record::list get(const short_hash& key, size_t from_height, size_t limit) const; - std::shared_ptr> get(const std::string& address, size_t start, size_t end) const; - std::shared_ptr> get(const std::string& address, const std::string& symbol, + auto write = [&](memory_ptr data) + { + auto serial = make_serializer(REMAP_ADDRESS(data)); + serial.write_byte(static_cast(point_kind::output)); // 1 + serial.write_data(outpoint.to_data()); // 36 + serial.write_4_bytes_little_endian(output_height); // 4 + serial.write_8_bytes_little_endian(value); // 8 + serial.write_2_bytes_little_endian(business_kd); // 2 + serial.write_4_bytes_little_endian(timestamp); // 4 + serial.write_data(business_data.to_data()); + }; + rows_multimap_.add_row(key, write); + } + + void store_input(const short_hash& key, + const output_point& inpoint, uint32_t input_height, + const input_point& previous, uint32_t timestamp); + + business_record::list get(const short_hash& key, size_t from_height, size_t limit) const; + std::shared_ptr> get(const std::string& address, size_t start, size_t end) const; + std::shared_ptr> get(const std::string& address, const std::string& symbol, size_t start_height, size_t end_height, uint64_t limit, uint64_t page_number) const; - std::shared_ptr> get(size_t idx) const; + std::shared_ptr> get(size_t idx) const; business_record get_record(size_t idx) const; - business_history::list get_business_history(const short_hash& key, - size_t from_height) const; - business_history::list get_business_history(const std::string& address, - size_t from_height, business_kind kind, uint8_t status) const; - business_history::list get_business_history(const std::string& address, - size_t from_height, business_kind kind, uint32_t time_begin, uint32_t time_end) const; - std::shared_ptr> get_address_business_history(const std::string& address, - size_t from_height) const; - business_address_did::list get_dids(const std::string& address, - size_t from_height, business_kind kind) const; - business_address_did::list get_dids(const std::string& address, - size_t from_height) const; - business_address_message::list get_messages(const std::string& address, - size_t from_height) const; - - //unbind the old did with address - void delete_old_did(const short_hash& key); + business_history::list get_business_history(const short_hash& key, + size_t from_height) const; + business_history::list get_business_history(const std::string& address, + size_t from_height, business_kind kind, uint8_t status) const; + business_history::list get_business_history(const std::string& address, + size_t from_height, business_kind kind, uint32_t time_begin, uint32_t time_end) const; + std::shared_ptr> get_address_business_history(const std::string& address, + size_t from_height) const; + business_address_did::list get_dids(const std::string& address, + size_t from_height, business_kind kind) const; + business_address_did::list get_dids(const std::string& address, + size_t from_height) const; + business_address_message::list get_messages(const std::string& address, + size_t from_height) const; + + //unbind the old did with address + void delete_old_did(const short_hash& key); /// Delete the last row that was added to key. void delete_last_row(const short_hash& key); diff --git a/include/metaverse/database/databases/asset_database.hpp b/include/metaverse/database/databases/asset_database.hpp index a82cd42fb..21e1fbc85 100644 --- a/include/metaverse/database/databases/asset_database.hpp +++ b/include/metaverse/database/databases/asset_database.hpp @@ -48,11 +48,11 @@ class BCD_API asset_database: public base_database /// Close the database (all threads must first be stopped). ~asset_database(); - - /// get asset info by symbol hash - asset_result get_asset_result(const hash_digest& hash) const; - /// get all assets in the blockchain - std::shared_ptr> get_asset_details() const; + + /// get asset info by symbol hash + asset_result get_asset_result(const hash_digest& hash) const; + /// get all assets in the blockchain + std::shared_ptr> get_asset_details() const; /// Store a asset in the database. Returns a unique index /// which can be used to reference the asset. void store(const hash_digest& hash, const asset_detail& sp_detail); diff --git a/include/metaverse/database/databases/block_database.hpp b/include/metaverse/database/databases/block_database.hpp index 4638f9490..726b98c24 100644 --- a/include/metaverse/database/databases/block_database.hpp +++ b/include/metaverse/database/databases/block_database.hpp @@ -76,10 +76,10 @@ class BCD_API block_database /// Unlink all blocks upwards from (and including) from_height. void unlink(size_t from_height); - - /// Remove block from block hash table - void remove(const hash_digest& hash); - + + /// Remove block from block hash table + void remove(const hash_digest& hash); + /// Synchronise storage with disk so things are consistent. /// Should be done at the end of every block write. void sync(); diff --git a/include/metaverse/database/databases/blockchain_did_database.hpp b/include/metaverse/database/databases/blockchain_did_database.hpp index cd2311efb..c56d624b7 100644 --- a/include/metaverse/database/databases/blockchain_did_database.hpp +++ b/include/metaverse/database/databases/blockchain_did_database.hpp @@ -60,14 +60,14 @@ class BCD_API blockchain_did_database /// Call to unload the memory map. bool close(); - std::shared_ptr get(const hash_digest& hash) const; - + std::shared_ptr get(const hash_digest& hash) const; + /// std::shared_ptr > get_history_dids(const hash_digest& hash) const; - /// - std::shared_ptr > get_blockchain_dids() const; - - void store(const hash_digest& hash, const blockchain_did& sp_detail); + /// + std::shared_ptr > get_blockchain_dids() const; + + void store(const hash_digest& hash, const blockchain_did& sp_detail); /// Delete a transaction from database. void remove(const hash_digest& hash); diff --git a/include/metaverse/database/impl/hash_table_header.ipp b/include/metaverse/database/impl/hash_table_header.ipp index 9ff4619f6..e6940d3ad 100644 --- a/include/metaverse/database/impl/hash_table_header.ipp +++ b/include/metaverse/database/impl/hash_table_header.ipp @@ -29,7 +29,7 @@ namespace libbitcoin { namespace database { -// This VC++ workaround is OK because ValueType must be unsigned. +// This VC++ workaround is OK because ValueType must be unsigned. //static constexpr ValueType empty = std::numeric_limits::max(); template const ValueType hash_table_header::empty = @@ -101,7 +101,7 @@ ValueType hash_table_header::read(IndexType index) const { // This is not runtime safe but test is avoided as an optimization. BITCOIN_ASSERT(index < buckets_); - + // The accessor must remain in scope until the end of the block. const auto memory = file_.access(); const auto value_address = REMAP_ADDRESS(memory) + item_position(index); @@ -119,7 +119,7 @@ void hash_table_header::write(IndexType index, { // This is not runtime safe but test is avoided as an optimization. BITCOIN_ASSERT(index < buckets_); - + // The accessor must remain in scope until the end of the block. const auto memory = file_.access(); const auto value_address = REMAP_ADDRESS(memory) + item_position(index); diff --git a/include/metaverse/database/impl/record_hash_table.ipp b/include/metaverse/database/impl/record_hash_table.ipp index 8f5bae22f..e184a4a25 100644 --- a/include/metaverse/database/impl/record_hash_table.ipp +++ b/include/metaverse/database/impl/record_hash_table.ipp @@ -44,7 +44,7 @@ template void record_hash_table::store(const KeyType& key, const write_function write) { - mutex_.lock(); + mutex_.lock(); // Store current bucket value. const auto old_begin = read_bucket_value(key); record_row item(manager_, 0); @@ -90,11 +90,11 @@ const memory_ptr record_hash_table::find(const KeyType& key) const template std::shared_ptr> record_hash_table::find(array_index index) const { - auto vec_memo = std::make_shared>(); - // find first item + auto vec_memo = std::make_shared>(); + // find first item auto current = header_.read(index); static_assert(sizeof(current) == sizeof(array_index), "Invalid size"); - + // Iterate through list... while (current != header_.empty) { diff --git a/include/metaverse/database/impl/record_multimap.ipp b/include/metaverse/database/impl/record_multimap.ipp index c1015ed2e..4be31275b 100644 --- a/include/metaverse/database/impl/record_multimap.ipp +++ b/include/metaverse/database/impl/record_multimap.ipp @@ -54,16 +54,16 @@ array_index record_multimap::lookup(const KeyType& key) const template std::shared_ptr> record_multimap::lookup(array_index index) const { - auto sh_ret_vec = std::make_shared>(); + auto sh_ret_vec = std::make_shared>(); auto sh_vec = map_.find(index); - + // Critical Section /////////////////////////////////////////////////////////////////////////// unique_lock lock(mutex_); - for(auto each : *sh_vec) { - const auto address = REMAP_ADDRESS(each); - sh_ret_vec->push_back(from_little_endian_unsafe(address)); - } + for(auto each : *sh_vec) { + const auto address = REMAP_ADDRESS(each); + sh_ret_vec->push_back(from_little_endian_unsafe(address)); + } /////////////////////////////////////////////////////////////////////////// return sh_ret_vec; } diff --git a/include/metaverse/database/impl/slab_hash_table.ipp b/include/metaverse/database/impl/slab_hash_table.ipp index 4b75869f7..37ce68e4d 100644 --- a/include/metaverse/database/impl/slab_hash_table.ipp +++ b/include/metaverse/database/impl/slab_hash_table.ipp @@ -44,7 +44,7 @@ template file_offset slab_hash_table::store(const KeyType& key, write_function write, const size_t value_size) { - mutex_.lock(); + mutex_.lock(); // Store current bucket value. const auto old_begin = read_bucket_value(key); slab_row item(manager_, 0); @@ -53,7 +53,7 @@ file_offset slab_hash_table::store(const KeyType& key, // Link record to header. link(key, new_begin); - + mutex_.unlock(); // Return position, @@ -68,7 +68,7 @@ template file_offset slab_hash_table::restore(const KeyType& key, write_function write, const size_t value_size) { - mutex_.lock(); + mutex_.lock(); // Store current bucket value. const auto old_begin = read_bucket_value(key); slab_row item(manager_, old_begin); @@ -77,7 +77,7 @@ file_offset slab_hash_table::restore(const KeyType& key, // Link record to header. //link(key, new_begin); - + mutex_.unlock(); // Return position, @@ -186,8 +186,8 @@ std::vector slab_hash_table::finds(const KeyType& key) cons template std::shared_ptr> slab_hash_table::find(uint64_t index) const { - auto vec_memo = std::make_shared>(); - // find first item + auto vec_memo = std::make_shared>(); + // find first item auto current = header_.read(index); static_assert(sizeof(current) == sizeof(file_offset), "Invalid size"); @@ -223,7 +223,7 @@ bool slab_hash_table::unlink(const KeyType& key) // Find start item... const auto begin = read_bucket_value(key); const slab_row begin_item(manager_, begin); - + if (begin_item.out_of_memory()) return false; @@ -245,7 +245,7 @@ bool slab_hash_table::unlink(const KeyType& key) if (item.out_of_memory()) return false; - + // Found, unlink current item from previous. if (item.compare(key)) { diff --git a/include/metaverse/database/impl/slab_row.ipp b/include/metaverse/database/impl/slab_row.ipp index e0c6855cf..34e1c7a43 100644 --- a/include/metaverse/database/impl/slab_row.ipp +++ b/include/metaverse/database/impl/slab_row.ipp @@ -58,9 +58,9 @@ public: /// Write a new next position. void write_next_position(file_offset next); - //whether cross the memory + //whether cross the memory bool out_of_memory() const; - + private: const memory_ptr raw_next_data() const; const memory_ptr raw_data(file_offset offset) const; diff --git a/include/metaverse/database/primitives/record_hash_table.hpp b/include/metaverse/database/primitives/record_hash_table.hpp index e2143f947..65c9546ef 100644 --- a/include/metaverse/database/primitives/record_hash_table.hpp +++ b/include/metaverse/database/primitives/record_hash_table.hpp @@ -74,7 +74,7 @@ class record_hash_table /// Find the record for a given hash. /// Returns a null pointer if not found. const memory_ptr find(const KeyType& key) const; - std::shared_ptr> find(array_index index) const; + std::shared_ptr> find(array_index index) const; /// Delete a key-value pair from the hashtable by unlinking the node. bool unlink(const KeyType& key); diff --git a/include/metaverse/database/primitives/record_multimap.hpp b/include/metaverse/database/primitives/record_multimap.hpp index 578a67885..440ab451c 100644 --- a/include/metaverse/database/primitives/record_multimap.hpp +++ b/include/metaverse/database/primitives/record_multimap.hpp @@ -57,7 +57,7 @@ class record_multimap /// Lookup a key, returning an iterable result with multiple values. array_index lookup(const KeyType& key) const; - std::shared_ptr> lookup(array_index index) const; + std::shared_ptr> lookup(array_index index) const; /// Add a new row for a key. If the key doesn't exist, it will be created. /// If it does exist, the value will be added at the start of the chain. void add_row(const KeyType& key, write_function write); diff --git a/include/metaverse/database/primitives/slab_hash_table.hpp b/include/metaverse/database/primitives/slab_hash_table.hpp index b3e2aca14..a45292a94 100644 --- a/include/metaverse/database/primitives/slab_hash_table.hpp +++ b/include/metaverse/database/primitives/slab_hash_table.hpp @@ -65,13 +65,13 @@ class slab_hash_table /// Returns the position of the inserted value in the slab_manager. file_offset store(const KeyType& key, write_function write, const size_t value_size); - file_offset restore(const KeyType& key, - write_function write, const size_t value_size); + file_offset restore(const KeyType& key, + write_function write, const size_t value_size); /// Find the slab for a given hash. Returns a null pointer if not found. const memory_ptr find(const KeyType& key) const; - std::shared_ptr> find(uint64_t index) const; - const memory_ptr rfind(const KeyType& key) const; - std::vector finds(const KeyType& key) const; + std::shared_ptr> find(uint64_t index) const; + const memory_ptr rfind(const KeyType& key) const; + std::vector finds(const KeyType& key) const; /// Delete a key-value pair from the hashtable by unlinking the node. bool unlink(const KeyType& key); diff --git a/include/metaverse/database/result/account_address_result.hpp b/include/metaverse/database/result/account_address_result.hpp index a40efee56..f754e589b 100644 --- a/include/metaverse/database/result/account_address_result.hpp +++ b/include/metaverse/database/result/account_address_result.hpp @@ -32,7 +32,7 @@ using namespace libbitcoin::chain; namespace libbitcoin { namespace database { - + /// read account_address detail information from account_address database. class BCD_API account_address_result : public base_result { @@ -40,7 +40,7 @@ class BCD_API account_address_result : public base_result account_address_result(const memory_ptr slab); /// The account_address. - std::shared_ptr get_account_address_detail() const; + std::shared_ptr get_account_address_detail() const; }; } // namespace database diff --git a/include/metaverse/database/result/account_asset_result.hpp b/include/metaverse/database/result/account_asset_result.hpp index b9d309e47..9fb7a5190 100644 --- a/include/metaverse/database/result/account_asset_result.hpp +++ b/include/metaverse/database/result/account_asset_result.hpp @@ -32,7 +32,7 @@ using namespace libbitcoin::chain; namespace libbitcoin { namespace database { - + /// read asset detail information from asset database. class BCD_API account_asset_result : public base_result { @@ -40,7 +40,7 @@ class BCD_API account_asset_result : public base_result account_asset_result(const memory_ptr slab); /// The asset account relationship. - asset_transfer get_account_asset_transfer() const; + asset_transfer get_account_asset_transfer() const; }; } // namespace database diff --git a/include/metaverse/database/result/account_result.hpp b/include/metaverse/database/result/account_result.hpp index 57e233201..633960537 100644 --- a/include/metaverse/database/result/account_result.hpp +++ b/include/metaverse/database/result/account_result.hpp @@ -34,7 +34,7 @@ using namespace std; namespace libbitcoin { namespace database { - + /// read account detail information from account database. class BCD_API account_result : public base_result { @@ -43,7 +43,7 @@ class BCD_API account_result : public base_result /// The account. //account get_account_detail() const; - std::shared_ptr get_account_detail() const; + std::shared_ptr get_account_detail() const; }; } // namespace database diff --git a/include/metaverse/database/result/asset_result.hpp b/include/metaverse/database/result/asset_result.hpp index 0197da60a..959c85b47 100644 --- a/include/metaverse/database/result/asset_result.hpp +++ b/include/metaverse/database/result/asset_result.hpp @@ -32,7 +32,7 @@ using namespace libbitcoin::chain; namespace libbitcoin { namespace database { - + /// read asset detail information from asset database. class BCD_API asset_result : public base_result { @@ -40,7 +40,7 @@ class BCD_API asset_result : public base_result asset_result(const memory_ptr slab); /// The asset. - std::shared_ptr get_asset_detail() const; + std::shared_ptr get_asset_detail() const; }; } // namespace database diff --git a/include/metaverse/database/result/base_result.hpp b/include/metaverse/database/result/base_result.hpp index 42b3598fb..bc9b053bf 100644 --- a/include/metaverse/database/result/base_result.hpp +++ b/include/metaverse/database/result/base_result.hpp @@ -29,24 +29,24 @@ namespace libbitcoin { namespace database { - + /// Deferred read base result. class BCD_API base_result { public: base_result(const memory_ptr slab): slab_(slab) - { - } + { + } /// True if this base result is valid (found). operator bool() const - { - return slab_ != nullptr; - } - memory_ptr get_slab() const - { - return slab_; - } + { + return slab_ != nullptr; + } + memory_ptr get_slab() const + { + return slab_; + } private: const memory_ptr slab_; }; @@ -63,7 +63,7 @@ base_result::operator bool() const memory_ptr base_result::get_slab() const { - return slab_; + return slab_; } #endif diff --git a/include/metaverse/database/result/transaction_result.hpp b/include/metaverse/database/result/transaction_result.hpp index 1825f6de7..c1ca2e251 100644 --- a/include/metaverse/database/result/transaction_result.hpp +++ b/include/metaverse/database/result/transaction_result.hpp @@ -29,7 +29,7 @@ namespace libbitcoin { namespace database { - + /// Deferred read transaction result. class BCD_API transaction_result { diff --git a/include/metaverse/database/version.hpp b/include/metaverse/database/version.hpp index b4d2fa6a2..9ba10b486 100644 --- a/include/metaverse/database/version.hpp +++ b/include/metaverse/database/version.hpp @@ -12,13 +12,13 @@ * For interpretation of the versioning scheme see: http://semver.org */ /* chenhao init value 0.6.0 - * 2017.6.11 wangdongyun modify from 0.6.0 to 0.6.1 - * 1. replace asset with blockchain_asset, to contain asset blockchain height - * to resolve block not sync when same asset exist + * 2017.6.11 wangdongyun modify from 0.6.0 to 0.6.1 + * 1. replace asset with blockchain_asset, to contain asset blockchain height + * to resolve block not sync when same asset exist * * 2017.7.7 wangdongyun modify to 0.6.2 * 1. modification in 0.6.1 must let user to resync block data from height 1. this will waste too long time. - * this version is enhanced to read block data from local block database not resysn block data from p2p network. + * this version is enhanced to read block data from local block database not resysn block data from p2p network. * * 2018.3.21 jowenshaw modify to 0.6.3 * 1. for DID (Digital IDentities) support, adding some new tables. diff --git a/include/metaverse/explorer.hpp b/include/metaverse/explorer.hpp index 1e14271a4..6382affea 100644 --- a/include/metaverse/explorer.hpp +++ b/include/metaverse/explorer.hpp @@ -8,7 +8,7 @@ #define MVS_EXPLORER_HPP /** - * API Users: Include only this header. Direct use of other headers is fragile + * API Users: Include only this header. Direct use of other headers is fragile * and unsupported as header organization is subject to change. * * Maintainers: Do not include this header internal to this library. diff --git a/include/metaverse/explorer/callback_state.hpp b/include/metaverse/explorer/callback_state.hpp index 6c7d7b2d2..bf03322f3 100644 --- a/include/metaverse/explorer/callback_state.hpp +++ b/include/metaverse/explorer/callback_state.hpp @@ -60,49 +60,49 @@ class callback_state BCX_API callback_state(std::ostream& error, std::ostream& output); /** - * Serialize a property tree to output. The stream must be flushed before + * Serialize a property tree to output. The stream must be flushed before * returning in order to prevent interleaving on the shared stream. * @param[in] tree The property tree to write to output. */ BCX_API virtual void error(const Json::Value& tree); /** - * Write a line to the error stream. The stream must be flushed before + * Write a line to the error stream. The stream must be flushed before * returning in order to prevent interleaving on the shared stream. * @param[in] message The unterminated error message to write. */ BCX_API virtual void error(const format& message); - + /** - * Write a line to the error stream. The stream must be flushed before + * Write a line to the error stream. The stream must be flushed before * returning in order to prevent interleaving on the shared stream. * @param[in] message The unterminated error message to write. */ BCX_API virtual void error(const std::string& message); /** - * Serialize a property tree to output. The stream must be flushed before + * Serialize a property tree to output. The stream must be flushed before * returning in order to prevent interleaving on the shared stream. * @param[in] tree The property tree to write to output. */ BCX_API virtual void output(const Json::Value& tree); /** - * Write a line to the output stream. The stream must be flushed before + * Write a line to the output stream. The stream must be flushed before * returning in order to prevent interleaving on the shared stream. * @param[in] message The unterminated output message to write. */ BCX_API virtual void output(const format& message); /** - * Write a line to the output stream. The stream must be flushed before + * Write a line to the output stream. The stream must be flushed before * returning in order to prevent interleaving on the shared stream. * @param[in] message The unterminated output message to write. */ BCX_API virtual void output(const std::string& message); /** - * Write a number to the output stream. The stream must be flushed before + * Write a number to the output stream. The stream must be flushed before * returning in order to prevent interleaving on the shared stream. * @param[in] value The numeric value to write. */ @@ -112,14 +112,14 @@ class callback_state * Set the callback refcount to one and reset result to okay. */ BCX_API virtual void start(); - + /** * Set the callback refcount to zero and assign the result. * This overrides any outstanding callback references. * @param[in] result The desired callback result code, defaults to okay. */ BCX_API virtual void stop(console_result result=console_result::okay); - + /** * Get a value indicating whether the callback reference count is zero. * @return True if the reference count is zero. @@ -130,7 +130,7 @@ class callback_state * Handle the callback error with standard behavior. * @param[in] ec The callback error result. * @param[in] format A single parameter format string or empty/default. - * @return True if no error. + * @return True if no error. */ BCX_API virtual bool succeeded(const std::error_code& ec, const std::string& format="%1%"); @@ -149,7 +149,7 @@ class callback_state * Set the callback result code. */ BCX_API virtual void set_result(console_result result); - + /** * Increment the callback synchronization reference count. * @return The callback synchronization counter value. diff --git a/include/metaverse/explorer/commands/fetch-stealth.hpp b/include/metaverse/explorer/commands/fetch-stealth.hpp index 3fdc43567..1bfe24a80 100644 --- a/include/metaverse/explorer/commands/fetch-stealth.hpp +++ b/include/metaverse/explorer/commands/fetch-stealth.hpp @@ -66,7 +66,7 @@ namespace commands { /** * Class to implement the fetch-stealth command. */ -class BCX_API fetch_stealth +class BCX_API fetch_stealth : public command { public: @@ -115,12 +115,12 @@ class BCX_API fetch_stealth .add("FILTER", 1); } - /** + /** * Load parameter fallbacks from file or input as appropriate. * @param[in] input The input stream for loading the parameters. * @param[in] The loaded variables. */ - virtual void load_fallbacks(std::istream& input, + virtual void load_fallbacks(std::istream& input, po::variables_map& variables) { } diff --git a/include/metaverse/explorer/commands/offline_commands_impl.hpp b/include/metaverse/explorer/commands/offline_commands_impl.hpp index a48cfbdff..c4c1d8eb6 100644 --- a/include/metaverse/explorer/commands/offline_commands_impl.hpp +++ b/include/metaverse/explorer/commands/offline_commands_impl.hpp @@ -22,7 +22,7 @@ #pragma once #include -#include +#include #include namespace libbitcoin { @@ -69,7 +69,7 @@ data_chunk get_seed(uint16_t bit_length = 256u); bw::word_list get_mnemonic_new(const bw::dictionary_list& language, const data_chunk& entropy); -data_chunk get_mnemonic_to_seed(const bw::dictionary_list& language, +data_chunk get_mnemonic_to_seed(const bw::dictionary_list& language, const bw::word_list& words, std::string passphrase = ""); diff --git a/include/metaverse/explorer/commands/send-tx.hpp b/include/metaverse/explorer/commands/send-tx.hpp index 8d412d756..a78d921ae 100644 --- a/include/metaverse/explorer/commands/send-tx.hpp +++ b/include/metaverse/explorer/commands/send-tx.hpp @@ -66,7 +66,7 @@ namespace commands { /** * Class to implement the send-tx command. */ -class BCX_API send_tx +class BCX_API send_tx : public command { public: @@ -122,12 +122,12 @@ class BCX_API send_tx .add("TRANSACTION", 1); } - /** + /** * Load parameter fallbacks from file or input as appropriate. * @param[in] input The input stream for loading the parameters. * @param[in] The loaded variables. */ - virtual void load_fallbacks(std::istream& input, + virtual void load_fallbacks(std::istream& input, po::variables_map& variables) { const auto raw = requires_raw_input(); diff --git a/include/metaverse/explorer/commands/settings.hpp b/include/metaverse/explorer/commands/settings.hpp index 6663bb287..55bcb7097 100644 --- a/include/metaverse/explorer/commands/settings.hpp +++ b/include/metaverse/explorer/commands/settings.hpp @@ -60,7 +60,7 @@ namespace commands { /** * Class to implement the settings command. */ -class BCX_API settings +class BCX_API settings : public command { public: @@ -108,12 +108,12 @@ class BCX_API settings return get_argument_metadata(); } - /** + /** * Load parameter fallbacks from file or input as appropriate. * @param[in] input The input stream for loading the parameters. * @param[in] The loaded variables. */ - virtual void load_fallbacks(std::istream& input, + virtual void load_fallbacks(std::istream& input, po::variables_map& variables) { } diff --git a/include/metaverse/explorer/commands/stealth-decode.hpp b/include/metaverse/explorer/commands/stealth-decode.hpp index 87b4cd8a9..3ab4ec54a 100644 --- a/include/metaverse/explorer/commands/stealth-decode.hpp +++ b/include/metaverse/explorer/commands/stealth-decode.hpp @@ -60,7 +60,7 @@ namespace commands { /** * Class to implement the stealth-decode command. */ -class BCX_API stealth_decode +class BCX_API stealth_decode : public command { public: @@ -116,12 +116,12 @@ class BCX_API stealth_decode .add("STEALTH_ADDRESS", 1); } - /** + /** * Load parameter fallbacks from file or input as appropriate. * @param[in] input The input stream for loading the parameters. * @param[in] The loaded variables. */ - virtual void load_fallbacks(std::istream& input, + virtual void load_fallbacks(std::istream& input, po::variables_map& variables) { const auto raw = requires_raw_input(); diff --git a/include/metaverse/explorer/commands/stealth-encode.hpp b/include/metaverse/explorer/commands/stealth-encode.hpp index 9de5fbf00..663722f72 100644 --- a/include/metaverse/explorer/commands/stealth-encode.hpp +++ b/include/metaverse/explorer/commands/stealth-encode.hpp @@ -70,7 +70,7 @@ namespace commands { /** * Class to implement the stealth-encode command. */ -class BCX_API stealth_encode +class BCX_API stealth_encode : public command { public: @@ -120,12 +120,12 @@ class BCX_API stealth_encode .add("SPEND_PUBKEY", -1); } - /** + /** * Load parameter fallbacks from file or input as appropriate. * @param[in] input The input stream for loading the parameters. * @param[in] The loaded variables. */ - virtual void load_fallbacks(std::istream& input, + virtual void load_fallbacks(std::istream& input, po::variables_map& variables) { } diff --git a/include/metaverse/explorer/commands/stealth-public.hpp b/include/metaverse/explorer/commands/stealth-public.hpp index 3d19b46d9..dab69817a 100644 --- a/include/metaverse/explorer/commands/stealth-public.hpp +++ b/include/metaverse/explorer/commands/stealth-public.hpp @@ -66,7 +66,7 @@ namespace commands { /** * Class to implement the stealth-public command. */ -class BCX_API stealth_public +class BCX_API stealth_public : public command { public: @@ -123,12 +123,12 @@ class BCX_API stealth_public .add("SHARED_SECRET", 1); } - /** + /** * Load parameter fallbacks from file or input as appropriate. * @param[in] input The input stream for loading the parameters. * @param[in] The loaded variables. */ - virtual void load_fallbacks(std::istream& input, + virtual void load_fallbacks(std::istream& input, po::variables_map& variables) { const auto raw = requires_raw_input(); diff --git a/include/metaverse/explorer/commands/stealth-secret.hpp b/include/metaverse/explorer/commands/stealth-secret.hpp index 6d13cfabe..f83e9e92b 100644 --- a/include/metaverse/explorer/commands/stealth-secret.hpp +++ b/include/metaverse/explorer/commands/stealth-secret.hpp @@ -66,7 +66,7 @@ namespace commands { /** * Class to implement the stealth-secret command. */ -class BCX_API stealth_secret +class BCX_API stealth_secret : public command { public: @@ -123,12 +123,12 @@ class BCX_API stealth_secret .add("SHARED_SECRET", 1); } - /** + /** * Load parameter fallbacks from file or input as appropriate. * @param[in] input The input stream for loading the parameters. * @param[in] The loaded variables. */ - virtual void load_fallbacks(std::istream& input, + virtual void load_fallbacks(std::istream& input, po::variables_map& variables) { const auto raw = requires_raw_input(); diff --git a/include/metaverse/explorer/commands/stealth-shared.hpp b/include/metaverse/explorer/commands/stealth-shared.hpp index f3d20bf05..5a374bf82 100644 --- a/include/metaverse/explorer/commands/stealth-shared.hpp +++ b/include/metaverse/explorer/commands/stealth-shared.hpp @@ -66,7 +66,7 @@ namespace commands { /** * Class to implement the stealth-shared command. */ -class BCX_API stealth_shared +class BCX_API stealth_shared : public command { public: @@ -116,12 +116,12 @@ class BCX_API stealth_shared .add("PUBKEY", 1); } - /** + /** * Load parameter fallbacks from file or input as appropriate. * @param[in] input The input stream for loading the parameters. * @param[in] The loaded variables. */ - virtual void load_fallbacks(std::istream& input, + virtual void load_fallbacks(std::istream& input, po::variables_map& variables) { const auto raw = requires_raw_input(); diff --git a/include/metaverse/explorer/commands/tx-decode.hpp b/include/metaverse/explorer/commands/tx-decode.hpp index 95d9bf289..a88419960 100644 --- a/include/metaverse/explorer/commands/tx-decode.hpp +++ b/include/metaverse/explorer/commands/tx-decode.hpp @@ -60,7 +60,7 @@ namespace commands { /** * Class to implement the tx-decode command. */ -class BCX_API tx_decode +class BCX_API tx_decode : public command { public: @@ -109,12 +109,12 @@ class BCX_API tx_decode .add("TRANSACTION", 1); } - /** + /** * Load parameter fallbacks from file or input as appropriate. * @param[in] input The input stream for loading the parameters. * @param[in] The loaded variables. */ - virtual void load_fallbacks(std::istream& input, + virtual void load_fallbacks(std::istream& input, po::variables_map& variables) { const auto raw = requires_raw_input(); diff --git a/include/metaverse/explorer/commands/validate-tx.hpp b/include/metaverse/explorer/commands/validate-tx.hpp index 203f3be88..9f1294d58 100644 --- a/include/metaverse/explorer/commands/validate-tx.hpp +++ b/include/metaverse/explorer/commands/validate-tx.hpp @@ -68,7 +68,7 @@ namespace commands { /** * Class to implement the validate-tx command. */ -class BCX_API validate_tx +class BCX_API validate_tx : public command { public: @@ -124,12 +124,12 @@ class BCX_API validate_tx .add("TRANSACTION", 1); } - /** + /** * Load parameter fallbacks from file or input as appropriate. * @param[in] input The input stream for loading the parameters. * @param[in] The loaded variables. */ - virtual void load_fallbacks(std::istream& input, + virtual void load_fallbacks(std::istream& input, po::variables_map& variables) { const auto raw = requires_raw_input(); diff --git a/include/metaverse/explorer/config/address.hpp b/include/metaverse/explorer/config/address.hpp index 8ed209db8..5fde3e5e8 100644 --- a/include/metaverse/explorer/config/address.hpp +++ b/include/metaverse/explorer/config/address.hpp @@ -52,7 +52,7 @@ class BCX_API address * @param[in] base58 The value to initialize with. */ address(const std::string& base58); - + /** * Overload cast to internal type. * @return This object's value cast to internal type reference. diff --git a/include/metaverse/explorer/config/hd_key.hpp b/include/metaverse/explorer/config/hd_key.hpp index 1326a39bf..6bbf09b6a 100644 --- a/include/metaverse/explorer/config/hd_key.hpp +++ b/include/metaverse/explorer/config/hd_key.hpp @@ -46,7 +46,7 @@ class BCX_API hd_key hd_key() { } - + /** * Initialization constructor. * @param[in] base58 The value to initialize with. diff --git a/include/metaverse/explorer/config/header.hpp b/include/metaverse/explorer/config/header.hpp index c57c527cf..d3ad8066b 100644 --- a/include/metaverse/explorer/config/header.hpp +++ b/include/metaverse/explorer/config/header.hpp @@ -33,7 +33,7 @@ namespace explorer { namespace config { /** - * Serialization helper to convert between serialized and deserialized satoshi + * Serialization helper to convert between serialized and deserialized satoshi * header. */ class BCX_API header @@ -75,7 +75,7 @@ class BCX_API header * @param[out] argument The object to receive the read value. * @return The input stream reference. */ - friend std::istream& operator>>(std::istream& input, + friend std::istream& operator>>(std::istream& input, header& argument); /** diff --git a/include/metaverse/explorer/config/input.hpp b/include/metaverse/explorer/config/input.hpp index fec1138a8..a6b84eaeb 100644 --- a/include/metaverse/explorer/config/input.hpp +++ b/include/metaverse/explorer/config/input.hpp @@ -44,7 +44,7 @@ class BCX_API input * Default constructor. */ input(); - + /** * Initialization constructor. * @param[in] tuple The value to initialize with. diff --git a/include/metaverse/explorer/config/output.hpp b/include/metaverse/explorer/config/output.hpp index bab5c1aeb..5ee56bf12 100644 --- a/include/metaverse/explorer/config/output.hpp +++ b/include/metaverse/explorer/config/output.hpp @@ -33,7 +33,7 @@ namespace explorer { namespace config { /** - * Serialization helper to convert between a base58-string:number and + * Serialization helper to convert between a base58-string:number and * a vector of tx_output_type. */ class BCX_API output diff --git a/include/metaverse/explorer/config/transaction.hpp b/include/metaverse/explorer/config/transaction.hpp index ba6652d30..9b6ef0a80 100644 --- a/include/metaverse/explorer/config/transaction.hpp +++ b/include/metaverse/explorer/config/transaction.hpp @@ -34,7 +34,7 @@ namespace explorer { namespace config { /** - * Serialization helper to convert between serialized and deserialized satoshi + * Serialization helper to convert between serialized and deserialized satoshi * transaction. */ class BCX_API transaction diff --git a/include/metaverse/explorer/config/wrapper.hpp b/include/metaverse/explorer/config/wrapper.hpp index d8fb1eba9..6d47afdf1 100644 --- a/include/metaverse/explorer/config/wrapper.hpp +++ b/include/metaverse/explorer/config/wrapper.hpp @@ -45,7 +45,7 @@ class BCX_API wrapper /** * Initialization constructor. - * + * * @param[in] wrapped The value to initialize with. */ wrapper(const std::string& wrapped); diff --git a/include/metaverse/explorer/define.hpp b/include/metaverse/explorer/define.hpp index 23a937993..87ce8d70c 100644 --- a/include/metaverse/explorer/define.hpp +++ b/include/metaverse/explorer/define.hpp @@ -29,9 +29,9 @@ #include #include -// We use the generic helper definitions in libbitcoin to define BCX_API +// We use the generic helper definitions in libbitcoin to define BCX_API // and BCX_INTERNAL. BCX_API is used for the public API symbols. It either DLL -// imports or DLL exports (or does nothing for static build) BCX_INTERNAL is +// imports or DLL exports (or does nothing for static build) BCX_INTERNAL is // used for non-api symbols. #if defined BCX_STATIC @@ -54,12 +54,12 @@ * Delimiter for use in word splitting serialized input and output points. */ #define BX_TX_POINT_DELIMITER ":" - + /** * Default delimiter for use in word splitting and joining operations. */ #define BX_SENTENCE_DELIMITER " " - + /** * Environment variable prefix for integrated environment variables. */ diff --git a/include/metaverse/explorer/dispatch.hpp b/include/metaverse/explorer/dispatch.hpp index 810e59cd9..a4b85aea8 100644 --- a/include/metaverse/explorer/dispatch.hpp +++ b/include/metaverse/explorer/dispatch.hpp @@ -30,7 +30,7 @@ namespace libbitcoin { namespace explorer { - + /** * Dispatch the command with the raw arguments as provided on the command line. * @param[in] argc The number of elements in the argv array. @@ -66,7 +66,7 @@ BCX_API console_result dispatch_command(int argc, const char* argv[], * @return The appropriate console return code { -1, 0, 1 }. */ BCX_API console_result dispatch_command(int argc, const char* argv[], - Json::Value& jv_output, + Json::Value& jv_output, bc::server::server_node& node, uint8_t api_version = 1); } // namespace explorer diff --git a/include/metaverse/explorer/display.hpp b/include/metaverse/explorer/display.hpp index 49d2cf482..ae95c43be 100644 --- a/include/metaverse/explorer/display.hpp +++ b/include/metaverse/explorer/display.hpp @@ -42,7 +42,7 @@ BCX_API void display_command_names(std::ostream& stream); * @param[in] stream The stream to write into. * @param[in] url The server url. */ -BCX_API void display_connection_failure(std::ostream& stream, +BCX_API void display_connection_failure(std::ostream& stream, const bc::config::endpoint& url); /** @@ -52,7 +52,7 @@ BCX_API void display_connection_failure(std::ostream& stream, * @param[in] command The value that was attempted as a command. * @param[in] superseding The superseding command, defaults to empty. */ -BCX_API void display_invalid_command(std::ostream& stream, +BCX_API void display_invalid_command(std::ostream& stream, const std::string& command, const std::string& superseding=""); /** diff --git a/include/metaverse/explorer/extensions/account_info.hpp b/include/metaverse/explorer/extensions/account_info.hpp index 78157d353..20f34e373 100644 --- a/include/metaverse/explorer/extensions/account_info.hpp +++ b/include/metaverse/explorer/extensions/account_info.hpp @@ -39,8 +39,8 @@ namespace chain { class BC_API account_info { public: - account_info(libbitcoin::blockchain::block_chain_impl& blockchain, std::string& passphrase); - account_info(libbitcoin::blockchain::block_chain_impl& blockchain, std::string& passphrase, + account_info(libbitcoin::blockchain::block_chain_impl& blockchain, std::string& passphrase); + account_info(libbitcoin::blockchain::block_chain_impl& blockchain, std::string& passphrase, account& meta, std::vector& addr_vec, std::vector& asset_vec); bool from_data(const data_chunk& data); @@ -60,9 +60,9 @@ class BC_API account_info private: libbitcoin::blockchain::block_chain_impl& blockchain_; - account meta_; - std::vector addr_vec_; - std::vector asset_vec_; + account meta_; + std::vector addr_vec_; + std::vector asset_vec_; // encrypt/decrypt data_chunk data_; std::string passphrase_; diff --git a/include/metaverse/explorer/extensions/command_assistant.hpp b/include/metaverse/explorer/extensions/command_assistant.hpp index 0e4c80972..5c1278d06 100644 --- a/include/metaverse/explorer/extensions/command_assistant.hpp +++ b/include/metaverse/explorer/extensions/command_assistant.hpp @@ -1,5 +1,5 @@ /** - * Copyright (c) 2016-2018 mvs developers + * Copyright (c) 2016-2018 mvs developers * * This file is part of metaverse-explorer. * diff --git a/include/metaverse/explorer/extensions/commands/addnode.hpp b/include/metaverse/explorer/extensions/commands/addnode.hpp index 12e4b3fa1..b2a61f417 100644 --- a/include/metaverse/explorer/extensions/commands/addnode.hpp +++ b/include/metaverse/explorer/extensions/commands/addnode.hpp @@ -61,7 +61,7 @@ class addnode: public command_extension using namespace po; options_description& options = get_option_metadata(); options.add_options() - ( + ( BX_HELP_VARIABLE ",h", value()->zero_tokens(), "Get a description and instructions for this command." diff --git a/include/metaverse/explorer/extensions/commands/changepasswd.hpp b/include/metaverse/explorer/extensions/commands/changepasswd.hpp index 85c42248b..6126f315d 100644 --- a/include/metaverse/explorer/extensions/commands/changepasswd.hpp +++ b/include/metaverse/explorer/extensions/commands/changepasswd.hpp @@ -60,26 +60,26 @@ class changepasswd: public command_extension using namespace po; options_description& options = get_option_metadata(); options.add_options() - ( + ( BX_HELP_VARIABLE ",h", value()->zero_tokens(), "Get a description and instructions for this command." ) - ( + ( "ACCOUNTNAME", value(&auth_.name)->required(), BX_ACCOUNT_NAME - ) + ) ( "ACCOUNTAUTH", value(&auth_.auth)->required(), BX_ACCOUNT_AUTH - ) - ( - "password,p", - value(&option_.passwd)->required(), - "The new password." - ); + ) + ( + "password,p", + value(&option_.passwd)->required(), + "The new password." + ); return options; } diff --git a/include/metaverse/explorer/extensions/commands/decoderawtx.hpp b/include/metaverse/explorer/extensions/commands/decoderawtx.hpp index af573a0cb..10185ca49 100644 --- a/include/metaverse/explorer/extensions/commands/decoderawtx.hpp +++ b/include/metaverse/explorer/extensions/commands/decoderawtx.hpp @@ -59,7 +59,7 @@ class decoderawtx: public command_extension using namespace po; options_description& options = get_option_metadata(); options.add_options() - ( + ( BX_HELP_VARIABLE ",h", value()->zero_tokens(), "Get a description and instructions for this command." diff --git a/include/metaverse/explorer/extensions/commands/deleteaccount.hpp b/include/metaverse/explorer/extensions/commands/deleteaccount.hpp index 4b35311d9..4d1015192 100644 --- a/include/metaverse/explorer/extensions/commands/deleteaccount.hpp +++ b/include/metaverse/explorer/extensions/commands/deleteaccount.hpp @@ -62,26 +62,26 @@ class deleteaccount: public command_extension using namespace po; options_description& options = get_option_metadata(); options.add_options() - ( + ( BX_HELP_VARIABLE ",h", value()->zero_tokens(), "Get a description and instructions for this command." ) - ( + ( "ACCOUNTNAME", value(&auth_.name)->required(), BX_ACCOUNT_NAME - ) + ) ( "ACCOUNTAUTH", value(&auth_.auth)->required(), BX_ACCOUNT_AUTH - ) + ) ( "LASTWORD", value(&argument_.last_word)->required(), "The last word of your private-key phrase." - ); + ); return options; } diff --git a/include/metaverse/explorer/extensions/commands/deposit.hpp b/include/metaverse/explorer/extensions/commands/deposit.hpp index 9428c9872..2a4c3e70d 100644 --- a/include/metaverse/explorer/extensions/commands/deposit.hpp +++ b/include/metaverse/explorer/extensions/commands/deposit.hpp @@ -60,41 +60,41 @@ class deposit : public command_extension using namespace po; options_description& options = get_option_metadata(); options.add_options() - ( + ( BX_HELP_VARIABLE ",h", value()->zero_tokens(), "Get a description and instructions for this command." ) - ( + ( "ACCOUNTNAME", value(&auth_.name)->required(), BX_ACCOUNT_NAME - ) + ) ( "ACCOUNTAUTH", value(&auth_.auth)->required(), BX_ACCOUNT_AUTH - ) + ) ( "AMOUNT", value(&argument_.amount)->required(), "ETP integer bits." ) - ( - "address,a", - value(&argument_.address), - "The deposit target address." - ) - ( + ( + "address,a", + value(&argument_.address), + "The deposit target address." + ) + ( "deposit,d", value(&argument_.deposit)->default_value(7), "Deposits support [7, 30, 90, 182, 365] days. defaluts to 7 days" - ) - ( + ) + ( "fee,f", value(&argument_.fee)->default_value(10000), "Transaction fee. defaults to 10000 ETP bits" - ); + ); return options; } @@ -111,7 +111,7 @@ class deposit : public command_extension uint64_t amount; uint64_t fee; uint16_t deposit; - std::string address; + std::string address; } argument_; struct option diff --git a/include/metaverse/explorer/extensions/commands/didsend.hpp b/include/metaverse/explorer/extensions/commands/didsend.hpp index cc504e91d..9987561db 100644 --- a/include/metaverse/explorer/extensions/commands/didsend.hpp +++ b/include/metaverse/explorer/extensions/commands/didsend.hpp @@ -62,26 +62,26 @@ class didsend: public send_command using namespace po; options_description& options = get_option_metadata(); options.add_options() - ( + ( BX_HELP_VARIABLE ",h", value()->zero_tokens(), "Get a description and instructions for this command." ) - ( + ( "ACCOUNTNAME", value(&auth_.name)->required(), BX_ACCOUNT_NAME - ) + ) ( "ACCOUNTAUTH", value(&auth_.auth)->required(), BX_ACCOUNT_AUTH - ) + ) ( "TODID/TOADDRESS", value(&argument_.did)->required(), "Send to this did/address" - ) + ) ( "AMOUNT", value(&argument_.amount)->required(), @@ -92,11 +92,11 @@ class didsend: public send_command value(&argument_.memo), "Attached memo for this transaction." ) - ( + ( "fee,f", value(&argument_.fee)->default_value(10000), "Transaction fee. defaults to 10000 etp bits" - ); + ); return options; } @@ -111,7 +111,7 @@ class didsend: public send_command struct argument { argument():did(""), memo("") - {}; + {}; std::string did; uint64_t amount; uint64_t fee; diff --git a/include/metaverse/explorer/extensions/commands/didsendasset.hpp b/include/metaverse/explorer/extensions/commands/didsendasset.hpp index df33e1213..43f526dc6 100644 --- a/include/metaverse/explorer/extensions/commands/didsendasset.hpp +++ b/include/metaverse/explorer/extensions/commands/didsendasset.hpp @@ -45,9 +45,9 @@ class didsendasset: public command_extension return get_argument_metadata() .add("ACCOUNTNAME", 1) .add("ACCOUNTAUTH", 1) - .add("TODID/TOADDRESS", 1) - .add("ASSET", 1) - .add("AMOUNT", 1); + .add("TODID/TOADDRESS", 1) + .add("ASSET", 1) + .add("AMOUNT", 1); } void load_fallbacks (std::istream& input, @@ -66,46 +66,46 @@ class didsendasset: public command_extension using namespace po; options_description& options = get_option_metadata(); options.add_options() - ( + ( BX_HELP_VARIABLE ",h", value()->zero_tokens(), "Get a description and instructions for this command." ) - ( + ( "ACCOUNTNAME", value(&auth_.name)->required(), BX_ACCOUNT_NAME - ) - ( - "ACCOUNTAUTH", - value(&auth_.auth)->required(), - BX_ACCOUNT_AUTH - ) - ( - "TODID/TOADDRESS", - value(&argument_.did)->required(), - "Asset receiver did/address." - ) - ( - "ASSET", - value(&argument_.symbol)->required(), - "Asset MST symbol." - ) - ( - "AMOUNT", - value(&argument_.amount)->required(), - "Asset integer bits. see asset ." - ) + ) + ( + "ACCOUNTAUTH", + value(&auth_.auth)->required(), + BX_ACCOUNT_AUTH + ) + ( + "TODID/TOADDRESS", + value(&argument_.did)->required(), + "Asset receiver did/address." + ) + ( + "ASSET", + value(&argument_.symbol)->required(), + "Asset MST symbol." + ) + ( + "AMOUNT", + value(&argument_.amount)->required(), + "Asset integer bits. see asset ." + ) ( "model,m", value(&option_.attenuation_model_param), BX_MST_OFFERING_CURVE ) - ( + ( "fee,f", value(&argument_.fee)->default_value(10000), "Transaction fee. defaults to 10000 ETP bits" - ); + ); return options; } @@ -118,10 +118,10 @@ class didsendasset: public command_extension struct argument { - std::string did; - std::string symbol; - uint64_t amount; - uint64_t fee; + std::string did; + std::string symbol; + uint64_t amount; + uint64_t fee; } argument_; struct option diff --git a/include/metaverse/explorer/extensions/commands/didsendfrom.hpp b/include/metaverse/explorer/extensions/commands/didsendfrom.hpp index c1e47cbd2..9216475b3 100644 --- a/include/metaverse/explorer/extensions/commands/didsendfrom.hpp +++ b/include/metaverse/explorer/extensions/commands/didsendfrom.hpp @@ -66,46 +66,46 @@ class didsendfrom: public send_command using namespace po; options_description& options = get_option_metadata(); options.add_options() - ( + ( BX_HELP_VARIABLE ",h", value()->zero_tokens(), "Get a description and instructions for this command." ) - ( + ( "ACCOUNTNAME", value(&auth_.name)->required(), BX_ACCOUNT_NAME - ) + ) ( "ACCOUNTAUTH", value(&auth_.auth)->required(), BX_ACCOUNT_AUTH - ) - ( - "FROMDID/FROMADDRESS", - value(&argument_.fromdid)->required(), - "Send from this did/address" - ) - ( - "TODID/TOADDRESS", - value(&argument_.todid)->required(), - "Send to this did/address" - ) - ( - "AMOUNT", - value(&argument_.amount)->required(), - "ETP integer bits." - ) + ) + ( + "FROMDID/FROMADDRESS", + value(&argument_.fromdid)->required(), + "Send from this did/address" + ) + ( + "TODID/TOADDRESS", + value(&argument_.todid)->required(), + "Send to this did/address" + ) + ( + "AMOUNT", + value(&argument_.amount)->required(), + "ETP integer bits." + ) ( "memo,m", value(&argument_.memo), "The memo to descript transaction" ) - ( - "fee,f", - value(&argument_.fee)->default_value(10000), - "Transaction fee. defaults to 10000 ETP bits" - ); + ( + "fee,f", + value(&argument_.fee)->default_value(10000), + "Transaction fee. defaults to 10000 ETP bits" + ); return options; } @@ -122,10 +122,10 @@ class didsendfrom: public send_command argument():fromdid(""), todid(""), memo("") {}; - std::string fromdid; - std::string todid; - uint64_t amount; - uint64_t fee; + std::string fromdid; + std::string todid; + uint64_t amount; + uint64_t fee; std::string memo; } argument_; diff --git a/include/metaverse/explorer/extensions/commands/didsendmore.hpp b/include/metaverse/explorer/extensions/commands/didsendmore.hpp index ee1212f7f..4593ee791 100644 --- a/include/metaverse/explorer/extensions/commands/didsendmore.hpp +++ b/include/metaverse/explorer/extensions/commands/didsendmore.hpp @@ -61,36 +61,36 @@ class didsendmore: public send_command using namespace po; options_description& options = get_option_metadata(); options.add_options() - ( + ( BX_HELP_VARIABLE ",h", value()->zero_tokens(), "Send to more target. " ) - ( + ( "ACCOUNTNAME", value(&auth_.name)->required(), BX_ACCOUNT_NAME - ) + ) ( "ACCOUNTAUTH", value(&auth_.auth)->required(), BX_ACCOUNT_AUTH - ) + ) ( "receivers,r", value>(&argument_.receivers)->required(), "Send to [did/address:etp_bits]." - ) + ) ( "mychange,m", value(&argument_.mychange_address), "Mychange to this did/address" - ) - ( + ) + ( "fee,f", value(&argument_.fee)->default_value(10000), "Transaction fee. defaults to 10000 ETP bits" - ); + ); return options; diff --git a/include/metaverse/explorer/extensions/commands/dumpkeyfile.hpp b/include/metaverse/explorer/extensions/commands/dumpkeyfile.hpp index 39989c580..5aeb72190 100644 --- a/include/metaverse/explorer/extensions/commands/dumpkeyfile.hpp +++ b/include/metaverse/explorer/extensions/commands/dumpkeyfile.hpp @@ -63,21 +63,21 @@ class dumpkeyfile: public command_extension using namespace po; options_description& options = get_option_metadata(); options.add_options() - ( + ( BX_HELP_VARIABLE ",h", value()->zero_tokens(), "Get a description and instructions for this command." ) - ( + ( "ACCOUNTNAME", value(&auth_.name)->required(), BX_ACCOUNT_NAME - ) + ) ( "ACCOUNTAUTH", value(&auth_.auth)->required(), BX_ACCOUNT_AUTH - ) + ) ( "LASTWORD", value(&argument_.last_word)->required(), diff --git a/include/metaverse/explorer/extensions/commands/getaccount.hpp b/include/metaverse/explorer/extensions/commands/getaccount.hpp index bda9f3440..5f2c826b1 100644 --- a/include/metaverse/explorer/extensions/commands/getaccount.hpp +++ b/include/metaverse/explorer/extensions/commands/getaccount.hpp @@ -62,26 +62,26 @@ class getaccount: public command_extension using namespace po; options_description& options = get_option_metadata(); options.add_options() - ( + ( BX_HELP_VARIABLE ",h", value()->zero_tokens(), "Get a description and instructions for this command." ) - ( + ( "ACCOUNTNAME", value(&auth_.name)->required(), BX_ACCOUNT_NAME - ) + ) ( "ACCOUNTAUTH", value(&auth_.auth)->required(), BX_ACCOUNT_AUTH - ) + ) ( "LASTWORD", value(&argument_.last_word)->required(), "The last word of your backup words." - ); + ); return options; } diff --git a/include/metaverse/explorer/extensions/commands/getaddressetp.hpp b/include/metaverse/explorer/extensions/commands/getaddressetp.hpp index 2b1b3bb90..16cc057d9 100644 --- a/include/metaverse/explorer/extensions/commands/getaddressetp.hpp +++ b/include/metaverse/explorer/extensions/commands/getaddressetp.hpp @@ -58,7 +58,7 @@ class getaddressetp: public command_extension using namespace po; options_description& options = get_option_metadata(); options.add_options() - ( + ( BX_HELP_VARIABLE ",h", value()->zero_tokens(), "Get a description and instructions for this command." @@ -67,7 +67,7 @@ class getaddressetp: public command_extension "PAYMENT_ADDRESS", value(&argument_.address)->required(), "The payment address. If not specified the address is read from STDIN." - ); + ); return options; } diff --git a/include/metaverse/explorer/extensions/commands/getbalance.hpp b/include/metaverse/explorer/extensions/commands/getbalance.hpp index 4c2a25cc7..0426957fa 100644 --- a/include/metaverse/explorer/extensions/commands/getbalance.hpp +++ b/include/metaverse/explorer/extensions/commands/getbalance.hpp @@ -60,21 +60,21 @@ class getbalance: public command_extension using namespace po; options_description& options = get_option_metadata(); options.add_options() - ( + ( BX_HELP_VARIABLE ",h", value()->zero_tokens(), "Get a description and instructions for this command." ) - ( + ( "ACCOUNTNAME", value(&auth_.name)->required(), BX_ACCOUNT_NAME - ) + ) ( "ACCOUNTAUTH", value(&auth_.auth)->required(), BX_ACCOUNT_AUTH - ); + ); return options; } diff --git a/include/metaverse/explorer/extensions/commands/getblockheader.hpp b/include/metaverse/explorer/extensions/commands/getblockheader.hpp index 71921262c..e4d3bef2a 100644 --- a/include/metaverse/explorer/extensions/commands/getblockheader.hpp +++ b/include/metaverse/explorer/extensions/commands/getblockheader.hpp @@ -59,7 +59,7 @@ class getblockheader: public command_extension using namespace po; options_description& options = get_option_metadata(); options.add_options() - ( + ( BX_HELP_VARIABLE ",h", value()->zero_tokens(), "Get a description and instructions for this command." @@ -97,7 +97,7 @@ class getblockheader: public command_extension {} bool is_getbestblockhash{false}; - bc::config::hash256 hash; + bc::config::hash256 hash; uint32_t height; } option_; diff --git a/include/metaverse/explorer/extensions/commands/getdid.hpp b/include/metaverse/explorer/extensions/commands/getdid.hpp index e657d30bc..b463ce9d7 100644 --- a/include/metaverse/explorer/extensions/commands/getdid.hpp +++ b/include/metaverse/explorer/extensions/commands/getdid.hpp @@ -58,16 +58,16 @@ class getdid: public command_extension using namespace po; options_description& options = get_option_metadata(); options.add_options() - ( + ( BX_HELP_VARIABLE ",h", value()->zero_tokens(), "Get a description and instructions for this command." ) - ( - "DID/ADDRESS", - value(&option_.symbol), - "Did symbol or standard address; If no input parameters, then display whole network DIDs." - ); + ( + "DID/ADDRESS", + value(&option_.symbol), + "Did symbol or standard address; If no input parameters, then display whole network DIDs." + ); return options; } @@ -85,7 +85,7 @@ class getdid: public command_extension struct option { - std::string symbol; + std::string symbol; } option_; }; diff --git a/include/metaverse/explorer/extensions/commands/getheight.hpp b/include/metaverse/explorer/extensions/commands/getheight.hpp index b62430ed7..5f4509647 100644 --- a/include/metaverse/explorer/extensions/commands/getheight.hpp +++ b/include/metaverse/explorer/extensions/commands/getheight.hpp @@ -61,21 +61,21 @@ class getheight: public command_extension using namespace po; options_description& options = get_option_metadata(); options.add_options() - ( + ( BX_HELP_VARIABLE ",h", value()->zero_tokens(), "Get a description and instructions for this command." ) - ( + ( "ADMINNAME", value(&auth_.name), BX_ADMIN_NAME - ) + ) ( "ADMINAUTH", value(&auth_.auth), BX_ADMIN_AUTH - ); + ); return options; } diff --git a/include/metaverse/explorer/extensions/commands/getinfo.hpp b/include/metaverse/explorer/extensions/commands/getinfo.hpp index 01a517671..64dcdc089 100644 --- a/include/metaverse/explorer/extensions/commands/getinfo.hpp +++ b/include/metaverse/explorer/extensions/commands/getinfo.hpp @@ -60,21 +60,21 @@ class getinfo: public command_extension using namespace po; options_description& options = get_option_metadata(); options.add_options() - ( + ( BX_HELP_VARIABLE ",h", value()->zero_tokens(), "Get a description and instructions for this command." ) - ( + ( "ADMINNAME", value(&auth_.name), BX_ADMIN_NAME - ) + ) ( "ADMINAUTH", value(&auth_.auth), BX_ADMIN_AUTH - ); + ); return options; } diff --git a/include/metaverse/explorer/extensions/commands/getmemorypool.hpp b/include/metaverse/explorer/extensions/commands/getmemorypool.hpp index 1b41100cd..225b1404f 100644 --- a/include/metaverse/explorer/extensions/commands/getmemorypool.hpp +++ b/include/metaverse/explorer/extensions/commands/getmemorypool.hpp @@ -50,7 +50,7 @@ class getmemorypool: public command_extension using namespace po; options_description& options = get_option_metadata(); options.add_options() - ( + ( BX_HELP_VARIABLE ",h", value()->zero_tokens(), "Get a description and instructions for this command." @@ -60,16 +60,16 @@ class getmemorypool: public command_extension value(&option_.json)->default_value(true), "Json format or Raw format, default is Json(true)." ) - ( + ( "ADMINNAME", value(&auth_.name), BX_ADMIN_NAME - ) + ) ( "ADMINAUTH", value(&auth_.auth), BX_ADMIN_AUTH - ); + ); return options; diff --git a/include/metaverse/explorer/extensions/commands/getmininginfo.hpp b/include/metaverse/explorer/extensions/commands/getmininginfo.hpp index 37f0585da..09cf7fc71 100644 --- a/include/metaverse/explorer/extensions/commands/getmininginfo.hpp +++ b/include/metaverse/explorer/extensions/commands/getmininginfo.hpp @@ -60,21 +60,21 @@ class getmininginfo: public command_extension using namespace po; options_description& options = get_option_metadata(); options.add_options() - ( + ( BX_HELP_VARIABLE ",h", value()->zero_tokens(), "Get a description and instructions for this command." ) - ( + ( "ADMINNAME", value(&auth_.name), BX_ADMIN_NAME - ) + ) ( "ADMINAUTH", value(&auth_.auth), BX_ADMIN_AUTH - ); + ); return options; } @@ -83,8 +83,8 @@ class getmininginfo: public command_extension { } - console_result invoke (Json::Value& jv_output, - libbitcoin::server::server_node& node) override; + console_result invoke (Json::Value& jv_output, + libbitcoin::server::server_node& node) override; struct argument { diff --git a/include/metaverse/explorer/extensions/commands/getnewaccount.hpp b/include/metaverse/explorer/extensions/commands/getnewaccount.hpp index be9354394..2c7100152 100644 --- a/include/metaverse/explorer/extensions/commands/getnewaccount.hpp +++ b/include/metaverse/explorer/extensions/commands/getnewaccount.hpp @@ -60,7 +60,7 @@ class getnewaccount: public command_extension using namespace po; options_description& options = get_option_metadata(); options.add_options() - ( + ( BX_HELP_VARIABLE ",h", value()->zero_tokens(), "Get a description and instructions for this command." @@ -70,16 +70,16 @@ class getnewaccount: public command_extension value(&option_.language)->default_value("en"), "Options are 'en', 'es', 'ja', 'zh_Hans', 'zh_Hant' and 'any', defaults to 'en'." ) - ( + ( "ACCOUNTNAME", value(&auth_.name)->required(), BX_ACCOUNT_NAME - ) + ) ( "ACCOUNTAUTH", value(&auth_.auth)->required(), BX_ACCOUNT_AUTH - ); + ); return options; } diff --git a/include/metaverse/explorer/extensions/commands/getpeerinfo.hpp b/include/metaverse/explorer/extensions/commands/getpeerinfo.hpp index 710293872..e361332e4 100644 --- a/include/metaverse/explorer/extensions/commands/getpeerinfo.hpp +++ b/include/metaverse/explorer/extensions/commands/getpeerinfo.hpp @@ -60,21 +60,21 @@ class getpeerinfo: public command_extension using namespace po; options_description& options = get_option_metadata(); options.add_options() - ( + ( BX_HELP_VARIABLE ",h", value()->zero_tokens(), "Get a description and instructions for this command." ) - ( + ( "ADMINNAME", value(&auth_.name), BX_ADMIN_NAME - ) + ) ( "ADMINAUTH", value(&auth_.auth), BX_ADMIN_AUTH - ); + ); return options; } diff --git a/include/metaverse/explorer/extensions/commands/getpublickey.hpp b/include/metaverse/explorer/extensions/commands/getpublickey.hpp index 98de553fb..03fc440d3 100644 --- a/include/metaverse/explorer/extensions/commands/getpublickey.hpp +++ b/include/metaverse/explorer/extensions/commands/getpublickey.hpp @@ -60,26 +60,26 @@ class getpublickey: public command_extension using namespace po; options_description& options = get_option_metadata(); options.add_options() - ( + ( BX_HELP_VARIABLE ",h", value()->zero_tokens(), "Get a description and instructions for this command." ) - ( + ( "ACCOUNTNAME", value(&auth_.name)->required(), BX_ACCOUNT_NAME - ) - ( - "ACCOUNTAUTH", - value(&auth_.auth)->required(), - BX_ACCOUNT_AUTH - ) + ) + ( + "ACCOUNTAUTH", + value(&auth_.auth)->required(), + BX_ACCOUNT_AUTH + ) ( "ADDRESS", value(&argument_.address)->required(), "Address." - ); + ); return options; } @@ -93,7 +93,7 @@ class getpublickey: public command_extension struct argument { - std::string address; + std::string address; } argument_; struct option diff --git a/include/metaverse/explorer/extensions/commands/gettx.hpp b/include/metaverse/explorer/extensions/commands/gettx.hpp index 88704bfb8..fb76716fa 100644 --- a/include/metaverse/explorer/extensions/commands/gettx.hpp +++ b/include/metaverse/explorer/extensions/commands/gettx.hpp @@ -63,7 +63,7 @@ class gettx: public command_extension using namespace po; options_description& options = get_option_metadata(); options.add_options() - ( + ( BX_HELP_VARIABLE ",h", value()->zero_tokens(), "Get a description and instructions for this command." @@ -73,7 +73,7 @@ class gettx: public command_extension value(&option_.json)->default_value(true), "Json/Raw format, default is '--json=true'." ) - ( + ( "HASH", value(&argument_.hash)->required(), "The Base16 transaction hash of the transaction to get. If not specified the transaction hash is read from STDIN." @@ -86,8 +86,8 @@ class gettx: public command_extension { } - console_result invoke (Json::Value& jv_output, - libbitcoin::server::server_node& node) override; + console_result invoke (Json::Value& jv_output, + libbitcoin::server::server_node& node) override; struct argument { diff --git a/include/metaverse/explorer/extensions/commands/getwork.hpp b/include/metaverse/explorer/extensions/commands/getwork.hpp index 9ec012012..cebe00679 100644 --- a/include/metaverse/explorer/extensions/commands/getwork.hpp +++ b/include/metaverse/explorer/extensions/commands/getwork.hpp @@ -60,21 +60,21 @@ class getwork: public command_extension using namespace po; options_description& options = get_option_metadata(); options.add_options() - ( + ( BX_HELP_VARIABLE ",h", value()->zero_tokens(), "Get a description and instructions for this command." ) - ( + ( "ADMINNAME", value(&auth_.name), BX_ADMIN_NAME - ) + ) ( "ADMINAUTH", value(&auth_.auth), BX_ADMIN_AUTH - ); + ); return options; diff --git a/include/metaverse/explorer/extensions/commands/importaccount.hpp b/include/metaverse/explorer/extensions/commands/importaccount.hpp index 2b131ef95..1813d1954 100644 --- a/include/metaverse/explorer/extensions/commands/importaccount.hpp +++ b/include/metaverse/explorer/extensions/commands/importaccount.hpp @@ -56,37 +56,37 @@ class importaccount: public command_extension using namespace po; options_description& options = get_option_metadata(); options.add_options() - ( + ( BX_HELP_VARIABLE ",h", value()->zero_tokens(), "Get a description and instructions for this command." ) - ( - "WORD", - value>(&argument_.words)->required(), - "The set of words that that make up the mnemonic. If not specified the words are read from STDIN." - ) - ( - "language,l", - value(&option_.language), - "The language identifier of the dictionary of the mnemonic. Options are 'en', 'es', 'ja', 'zh_Hans', 'zh_Hant' and 'any', defaults to 'any'." - ) - ( - "accountname,n", - value(&auth_.name)->required(), - BX_ACCOUNT_NAME - ) - ( - "password,p", - value(&option_.passwd)->required(), - BX_ACCOUNT_AUTH - ) - ( - "hd_index,i", - value(&option_.hd_index), - "The HD index for the account." - ) - ; + ( + "WORD", + value>(&argument_.words)->required(), + "The set of words that that make up the mnemonic. If not specified the words are read from STDIN." + ) + ( + "language,l", + value(&option_.language), + "The language identifier of the dictionary of the mnemonic. Options are 'en', 'es', 'ja', 'zh_Hans', 'zh_Hant' and 'any', defaults to 'any'." + ) + ( + "accountname,n", + value(&auth_.name)->required(), + BX_ACCOUNT_NAME + ) + ( + "password,p", + value(&option_.passwd)->required(), + BX_ACCOUNT_AUTH + ) + ( + "hd_index,i", + value(&option_.hd_index), + "The HD index for the account." + ) + ; return options; } @@ -104,7 +104,7 @@ class importaccount: public command_extension : words() { } - std::vector words; + std::vector words; } argument_; struct option @@ -115,8 +115,8 @@ class importaccount: public command_extension } explorer::config::language language; - std::string passwd; - uint32_t hd_index; + std::string passwd; + uint32_t hd_index; } option_; }; diff --git a/include/metaverse/explorer/extensions/commands/importkeyfile.hpp b/include/metaverse/explorer/extensions/commands/importkeyfile.hpp index 0e3cc145c..afa97cab0 100644 --- a/include/metaverse/explorer/extensions/commands/importkeyfile.hpp +++ b/include/metaverse/explorer/extensions/commands/importkeyfile.hpp @@ -64,7 +64,7 @@ class importkeyfile: public command_extension using namespace po; options_description& options = get_option_metadata(); options.add_options() - ( + ( BX_HELP_VARIABLE ",h", value()->zero_tokens(), "Get a description and instructions for this command." diff --git a/include/metaverse/explorer/extensions/commands/listaddresses.hpp b/include/metaverse/explorer/extensions/commands/listaddresses.hpp index 645f4bc94..b6a281c10 100644 --- a/include/metaverse/explorer/extensions/commands/listaddresses.hpp +++ b/include/metaverse/explorer/extensions/commands/listaddresses.hpp @@ -60,21 +60,21 @@ class listaddresses: public command_extension using namespace po; options_description& options = get_option_metadata(); options.add_options() - ( + ( BX_HELP_VARIABLE ",h", value()->zero_tokens(), "Get a description and instructions for this command." ) - ( + ( "ACCOUNTNAME", value(&auth_.name)->required(), BX_ACCOUNT_NAME - ) + ) ( "ACCOUNTAUTH", value(&auth_.auth)->required(), BX_ACCOUNT_AUTH - ); + ); return options; } diff --git a/include/metaverse/explorer/extensions/commands/listbalances.hpp b/include/metaverse/explorer/extensions/commands/listbalances.hpp index 7870fdc95..193cf1d1e 100644 --- a/include/metaverse/explorer/extensions/commands/listbalances.hpp +++ b/include/metaverse/explorer/extensions/commands/listbalances.hpp @@ -60,7 +60,7 @@ class listbalances: public command_extension using namespace po; options_description& options = get_option_metadata(); options.add_options() - ( + ( BX_HELP_VARIABLE ",h", value()->zero_tokens(), "Get a description and instructions for this command." @@ -80,16 +80,16 @@ class listbalances: public command_extension value(&option_.lesser)->default_value(0), "Lesser than ETP bits." ) - ( + ( "ACCOUNTNAME", value(&auth_.name)->required(), BX_ACCOUNT_NAME - ) + ) ( "ACCOUNTAUTH", value(&auth_.auth)->required(), BX_ACCOUNT_AUTH - ); + ); return options; } diff --git a/include/metaverse/explorer/extensions/commands/listdids.hpp b/include/metaverse/explorer/extensions/commands/listdids.hpp index 394b89bc5..527344397 100644 --- a/include/metaverse/explorer/extensions/commands/listdids.hpp +++ b/include/metaverse/explorer/extensions/commands/listdids.hpp @@ -60,21 +60,21 @@ class listdids: public command_extension using namespace po; options_description& options = get_option_metadata(); options.add_options() - ( + ( BX_HELP_VARIABLE ",h", value()->zero_tokens(), "Get a description and instructions for this command." ) - ( + ( "ACCOUNTNAME", value(&auth_.name), BX_ACCOUNT_NAME - ) + ) ( "ACCOUNTAUTH", value(&auth_.auth), BX_ACCOUNT_AUTH - ); + ); return options; } diff --git a/include/metaverse/explorer/extensions/commands/listtxs.hpp b/include/metaverse/explorer/extensions/commands/listtxs.hpp index f71a2f6f3..8b720d863 100644 --- a/include/metaverse/explorer/extensions/commands/listtxs.hpp +++ b/include/metaverse/explorer/extensions/commands/listtxs.hpp @@ -60,27 +60,27 @@ class listtxs: public command_extension using namespace po; options_description& options = get_option_metadata(); options.add_options() - ( + ( BX_HELP_VARIABLE ",h", value()->zero_tokens(), "Get a description and instructions for this command." ) - ( + ( "ACCOUNTNAME", value(&auth_.name)->required(), BX_ACCOUNT_NAME - ) - ( - "ACCOUNTAUTH", - value(&auth_.auth)->required(), - BX_ACCOUNT_AUTH - ) + ) + ( + "ACCOUNTAUTH", + value(&auth_.auth)->required(), + BX_ACCOUNT_AUTH + ) ( "address,a", value(&argument_.address), "Address." - ) - ( + ) + ( "height,e", value>(&option_.height), "Get tx according height eg: -e start-height:end-height will return tx between [start-height, end-height)" @@ -115,19 +115,19 @@ class listtxs: public command_extension struct argument { - argument():address(""), symbol(""), limit(100), index(0) - {}; - std::string address; - std::string symbol; + argument():address(""), symbol(""), limit(100), index(0) + {}; + std::string address; + std::string symbol; uint64_t limit; uint64_t index; } argument_; struct option { - option():height(0, 0) - {}; - libbitcoin::explorer::commands::colon_delimited2_item height; + option():height(0, 0) + {}; + libbitcoin::explorer::commands::colon_delimited2_item height; } option_; }; diff --git a/include/metaverse/explorer/extensions/commands/registerdid.hpp b/include/metaverse/explorer/extensions/commands/registerdid.hpp index 74424dbc1..1678856f0 100644 --- a/include/metaverse/explorer/extensions/commands/registerdid.hpp +++ b/include/metaverse/explorer/extensions/commands/registerdid.hpp @@ -64,36 +64,36 @@ class registerdid: public command_extension using namespace po; options_description& options = get_option_metadata(); options.add_options() - ( + ( BX_HELP_VARIABLE ",h", value()->zero_tokens(), "Get a description and instructions for this command." ) - ( + ( "ACCOUNTNAME", value(&auth_.name)->required(), BX_ACCOUNT_NAME - ) + ) ( "ACCOUNTAUTH", value(&auth_.auth)->required(), BX_ACCOUNT_AUTH - ) - ( - "ADDRESS", - value(&argument_.address)->required(), - "The address will be bound to, can change to other addresses later." - ) - ( - "SYMBOL", - value(&argument_.symbol)->required(), - "The symbol of global unique MVS Digital Identity Destination/Index, supports alphabets/numbers/(“@”, “.”, “_”, “-“), case-sensitive, maximum length is 64." - ) - ( - "fee,f", - value(&argument_.fee)->default_value(100000000), - "The fee of tx. defaults to 1 etp." - ); + ) + ( + "ADDRESS", + value(&argument_.address)->required(), + "The address will be bound to, can change to other addresses later." + ) + ( + "SYMBOL", + value(&argument_.symbol)->required(), + "The symbol of global unique MVS Digital Identity Destination/Index, supports alphabets/numbers/(“@”, “.”, “_”, “-“), case-sensitive, maximum length is 64." + ) + ( + "fee,f", + value(&argument_.fee)->default_value(100000000), + "The fee of tx. defaults to 1 etp." + ); return options; } @@ -107,9 +107,9 @@ class registerdid: public command_extension struct argument { - std::string address; - std::string symbol; - uint64_t fee; + std::string address; + std::string symbol; + uint64_t fee; } argument_; struct option diff --git a/include/metaverse/explorer/extensions/commands/send.hpp b/include/metaverse/explorer/extensions/commands/send.hpp index 9b6a2d991..d97a733a3 100644 --- a/include/metaverse/explorer/extensions/commands/send.hpp +++ b/include/metaverse/explorer/extensions/commands/send.hpp @@ -62,26 +62,26 @@ class send: public send_command using namespace po; options_description& options = get_option_metadata(); options.add_options() - ( + ( BX_HELP_VARIABLE ",h", value()->zero_tokens(), "Get a description and instructions for this command." ) - ( + ( "ACCOUNTNAME", value(&auth_.name)->required(), BX_ACCOUNT_NAME - ) + ) ( "ACCOUNTAUTH", value(&auth_.auth)->required(), BX_ACCOUNT_AUTH - ) + ) ( "TOADDRESS", value(&argument_.address)->required(), "Send to this address" - ) + ) ( "AMOUNT", value(&argument_.amount)->required(), @@ -92,11 +92,11 @@ class send: public send_command value(&argument_.memo), "Attached memo for this transaction." ) - ( + ( "fee,f", value(&argument_.fee)->default_value(10000), "Transaction fee. defaults to 10000 etp bits" - ); + ); return options; } @@ -111,7 +111,7 @@ class send: public send_command struct argument { argument():address(""), memo("") - {}; + {}; std::string address; uint64_t amount; uint64_t fee; diff --git a/include/metaverse/explorer/extensions/commands/sendasset.hpp b/include/metaverse/explorer/extensions/commands/sendasset.hpp index 8b3a28254..765778b62 100644 --- a/include/metaverse/explorer/extensions/commands/sendasset.hpp +++ b/include/metaverse/explorer/extensions/commands/sendasset.hpp @@ -45,9 +45,9 @@ class sendasset: public command_extension return get_argument_metadata() .add("ACCOUNTNAME", 1) .add("ACCOUNTAUTH", 1) - .add("ADDRESS", 1) - .add("SYMBOL", 1) - .add("AMOUNT", 1); + .add("ADDRESS", 1) + .add("SYMBOL", 1) + .add("AMOUNT", 1); } void load_fallbacks (std::istream& input, @@ -66,46 +66,46 @@ class sendasset: public command_extension using namespace po; options_description& options = get_option_metadata(); options.add_options() - ( + ( BX_HELP_VARIABLE ",h", value()->zero_tokens(), "Get a description and instructions for this command." ) - ( + ( "ACCOUNTNAME", value(&auth_.name)->required(), BX_ACCOUNT_NAME - ) - ( - "ACCOUNTAUTH", - value(&auth_.auth)->required(), - BX_ACCOUNT_AUTH - ) - ( - "ADDRESS", - value(&argument_.address)->required(), - "Asset receiver." - ) - ( - "SYMBOL", - value(&argument_.symbol)->required(), - "Asset symbol/name." - ) - ( - "AMOUNT", - value(&argument_.amount)->required(), - "Asset integer bits. see asset ." - ) + ) + ( + "ACCOUNTAUTH", + value(&auth_.auth)->required(), + BX_ACCOUNT_AUTH + ) + ( + "ADDRESS", + value(&argument_.address)->required(), + "Asset receiver." + ) + ( + "SYMBOL", + value(&argument_.symbol)->required(), + "Asset symbol/name." + ) + ( + "AMOUNT", + value(&argument_.amount)->required(), + "Asset integer bits. see asset ." + ) ( "model,m", value(&option_.attenuation_model_param), BX_MST_OFFERING_CURVE ) - ( + ( "fee,f", value(&argument_.fee)->default_value(10000), "Transaction fee. defaults to 10000 ETP bits" - ); + ); return options; } @@ -118,10 +118,10 @@ class sendasset: public command_extension struct argument { - std::string address; - std::string symbol; - uint64_t amount; - uint64_t fee; + std::string address; + std::string symbol; + uint64_t amount; + uint64_t fee; } argument_; struct option diff --git a/include/metaverse/explorer/extensions/commands/sendassetfrom.hpp b/include/metaverse/explorer/extensions/commands/sendassetfrom.hpp index 0ce6c6e1c..faa55b2f5 100644 --- a/include/metaverse/explorer/extensions/commands/sendassetfrom.hpp +++ b/include/metaverse/explorer/extensions/commands/sendassetfrom.hpp @@ -68,51 +68,51 @@ class sendassetfrom: public command_extension using namespace po; options_description& options = get_option_metadata(); options.add_options() - ( + ( BX_HELP_VARIABLE ",h", value()->zero_tokens(), "Get a description and instructions for this command." ) - ( + ( "ACCOUNTNAME", value(&auth_.name)->required(), BX_ACCOUNT_NAME - ) + ) ( "ACCOUNTAUTH", value(&auth_.auth)->required(), BX_ACCOUNT_AUTH - ) - ( - "FROMADDRESS", - value(&argument_.from)->required(), - "From address" - ) - ( - "TOADDRESS", - value(&argument_.to)->required(), - "Target address" - ) - ( - "SYMBOL", - value(&argument_.symbol)->required(), - "Asset symbol" - ) - ( - "AMOUNT", - value(&argument_.amount)->required(), - "Asset integer bits. see asset ." - ) + ) + ( + "FROMADDRESS", + value(&argument_.from)->required(), + "From address" + ) + ( + "TOADDRESS", + value(&argument_.to)->required(), + "Target address" + ) + ( + "SYMBOL", + value(&argument_.symbol)->required(), + "Asset symbol" + ) + ( + "AMOUNT", + value(&argument_.amount)->required(), + "Asset integer bits. see asset ." + ) ( "model,m", value(&option_.attenuation_model_param), BX_MST_OFFERING_CURVE ) - ( - "fee,f", - value(&argument_.fee)->default_value(10000), - "Transaction fee. defaults to 10000 ETP bits" - ); + ( + "fee,f", + value(&argument_.fee)->default_value(10000), + "Transaction fee. defaults to 10000 ETP bits" + ); return options; } @@ -126,11 +126,11 @@ class sendassetfrom: public command_extension struct argument { - std::string from; - std::string to; - std::string symbol; - uint64_t amount; - uint64_t fee; + std::string from; + std::string to; + std::string symbol; + uint64_t amount; + uint64_t fee; } argument_; struct option diff --git a/include/metaverse/explorer/extensions/commands/sendfrom.hpp b/include/metaverse/explorer/extensions/commands/sendfrom.hpp index fa578fdcb..6db9716ae 100644 --- a/include/metaverse/explorer/extensions/commands/sendfrom.hpp +++ b/include/metaverse/explorer/extensions/commands/sendfrom.hpp @@ -66,46 +66,46 @@ class sendfrom: public send_command using namespace po; options_description& options = get_option_metadata(); options.add_options() - ( + ( BX_HELP_VARIABLE ",h", value()->zero_tokens(), "Get a description and instructions for this command." ) - ( + ( "ACCOUNTNAME", value(&auth_.name)->required(), BX_ACCOUNT_NAME - ) + ) ( "ACCOUNTAUTH", value(&auth_.auth)->required(), BX_ACCOUNT_AUTH - ) - ( - "FROMADDRESS", - value(&argument_.from)->required(), - "Send from this address" - ) - ( - "TOADDRESS", - value(&argument_.to)->required(), - "Send to this address" - ) - ( - "AMOUNT", - value(&argument_.amount)->required(), - "ETP integer bits." - ) + ) + ( + "FROMADDRESS", + value(&argument_.from)->required(), + "Send from this address" + ) + ( + "TOADDRESS", + value(&argument_.to)->required(), + "Send to this address" + ) + ( + "AMOUNT", + value(&argument_.amount)->required(), + "ETP integer bits." + ) ( "memo,m", value(&argument_.memo), "The memo to descript transaction" ) - ( - "fee,f", - value(&argument_.fee)->default_value(10000), - "Transaction fee. defaults to 10000 ETP bits" - ); + ( + "fee,f", + value(&argument_.fee)->default_value(10000), + "Transaction fee. defaults to 10000 ETP bits" + ); return options; } @@ -122,10 +122,10 @@ class sendfrom: public send_command argument():from(""), to(""), memo("") {}; - std::string from; - std::string to; - uint64_t amount; - uint64_t fee; + std::string from; + std::string to; + uint64_t amount; + uint64_t fee; std::string memo; } argument_; diff --git a/include/metaverse/explorer/extensions/commands/sendmore.hpp b/include/metaverse/explorer/extensions/commands/sendmore.hpp index 1a93318a3..7096b3130 100644 --- a/include/metaverse/explorer/extensions/commands/sendmore.hpp +++ b/include/metaverse/explorer/extensions/commands/sendmore.hpp @@ -61,36 +61,36 @@ class sendmore: public send_command using namespace po; options_description& options = get_option_metadata(); options.add_options() - ( + ( BX_HELP_VARIABLE ",h", value()->zero_tokens(), "Send to more target. " ) - ( + ( "ACCOUNTNAME", value(&auth_.name)->required(), BX_ACCOUNT_NAME - ) + ) ( "ACCOUNTAUTH", value(&auth_.auth)->required(), BX_ACCOUNT_AUTH - ) + ) ( "receivers,r", value>(&argument_.receivers)->required(), "Send to [address:etp_bits]." - ) + ) ( "mychange,m", value(&argument_.mychange_address), "Mychange to this address" - ) - ( + ) + ( "fee,f", value(&argument_.fee)->default_value(10000), "Transaction fee. defaults to 10000 ETP bits" - ); + ); return options; diff --git a/include/metaverse/explorer/extensions/commands/sendwithmsg.hpp b/include/metaverse/explorer/extensions/commands/sendwithmsg.hpp index 5ba81d7a2..ae1a3058f 100644 --- a/include/metaverse/explorer/extensions/commands/sendwithmsg.hpp +++ b/include/metaverse/explorer/extensions/commands/sendwithmsg.hpp @@ -66,41 +66,41 @@ class sendwithmsg: public send_command using namespace po; options_description& options = get_option_metadata(); options.add_options() - ( + ( BX_HELP_VARIABLE ",h", value()->zero_tokens(), "Get a description and instructions for this command." ) - ( + ( "ACCOUNTNAME", value(&auth_.name)->required(), BX_ACCOUNT_NAME - ) + ) ( "ACCOUNTAUTH", value(&auth_.auth)->required(), BX_ACCOUNT_AUTH - ) + ) ( "TOADDRESS", value(&argument_.address)->required(), "Send to this address" - ) + ) ( "AMOUNT", value(&argument_.amount)->required(), "ETP integer bits." ) - ( - "MESSAGE", - value(&argument_.message)->required(), - "Message attached to the transaction" - ) - ( + ( + "MESSAGE", + value(&argument_.message)->required(), + "Message attached to the transaction" + ) + ( "fee,f", value(&argument_.fee)->default_value(10000), "Transaction fee. defaults to 10000 ETP bits" - ); + ); return options; } @@ -116,7 +116,7 @@ class sendwithmsg: public send_command { std::string address; uint64_t amount; - std::string message; + std::string message; uint64_t fee; } argument_; diff --git a/include/metaverse/explorer/extensions/commands/sendwithmsgfrom.hpp b/include/metaverse/explorer/extensions/commands/sendwithmsgfrom.hpp index 5e87381b1..b69cde48f 100644 --- a/include/metaverse/explorer/extensions/commands/sendwithmsgfrom.hpp +++ b/include/metaverse/explorer/extensions/commands/sendwithmsgfrom.hpp @@ -66,46 +66,46 @@ class sendwithmsgfrom: public send_command using namespace po; options_description& options = get_option_metadata(); options.add_options() - ( + ( BX_HELP_VARIABLE ",h", value()->zero_tokens(), "Get a description and instructions for this command." ) - ( + ( "ACCOUNTNAME", value(&auth_.name)->required(), BX_ACCOUNT_NAME - ) + ) ( "ACCOUNTAUTH", value(&auth_.auth)->required(), BX_ACCOUNT_AUTH - ) - ( - "FROMADDRESS", - value(&argument_.from)->required(), - "Send from this address" - ) - ( - "TOADDRESS", - value(&argument_.to)->required(), - "Send to this address" - ) - ( - "AMOUNT", - value(&argument_.amount)->required(), - "ETP integer bits." - ) - ( - "MESSAGE", - value(&argument_.message)->required(), - "Message attached to the transaction" - ) - ( - "fee,f", - value(&argument_.fee)->default_value(10000), - "Transaction fee. defaults to 10000 ETP bits" - ); + ) + ( + "FROMADDRESS", + value(&argument_.from)->required(), + "Send from this address" + ) + ( + "TOADDRESS", + value(&argument_.to)->required(), + "Send to this address" + ) + ( + "AMOUNT", + value(&argument_.amount)->required(), + "ETP integer bits." + ) + ( + "MESSAGE", + value(&argument_.message)->required(), + "Message attached to the transaction" + ) + ( + "fee,f", + value(&argument_.fee)->default_value(10000), + "Transaction fee. defaults to 10000 ETP bits" + ); return options; } @@ -119,11 +119,11 @@ class sendwithmsgfrom: public send_command struct argument { - std::string from; - std::string to; - uint64_t amount; - std::string message; - uint64_t fee; + std::string from; + std::string to; + uint64_t amount; + std::string message; + uint64_t fee; } argument_; struct option diff --git a/include/metaverse/explorer/extensions/commands/setminingaccount.hpp b/include/metaverse/explorer/extensions/commands/setminingaccount.hpp index f1cb7c27e..f1ec23dd0 100644 --- a/include/metaverse/explorer/extensions/commands/setminingaccount.hpp +++ b/include/metaverse/explorer/extensions/commands/setminingaccount.hpp @@ -62,26 +62,26 @@ class setminingaccount: public command_extension using namespace po; options_description& options = get_option_metadata(); options.add_options() - ( + ( BX_HELP_VARIABLE ",h", value()->zero_tokens(), "Get a description and instructions for this command." ) - ( + ( "ACCOUNTNAME", value(&auth_.name)->required(), BX_ACCOUNT_NAME - ) + ) ( "ACCOUNTAUTH", value(&auth_.auth)->required(), BX_ACCOUNT_AUTH - ) + ) ( "PAYMENT_ADDRESS", value(&argument_.payment_address)->required(), "the payment address of this account." - ); + ); return options; } diff --git a/include/metaverse/explorer/extensions/commands/shutdown.hpp b/include/metaverse/explorer/extensions/commands/shutdown.hpp index 004a09d4a..e27cc1a56 100644 --- a/include/metaverse/explorer/extensions/commands/shutdown.hpp +++ b/include/metaverse/explorer/extensions/commands/shutdown.hpp @@ -58,21 +58,21 @@ class shutdown: public command_extension using namespace po; options_description& options = get_option_metadata(); options.add_options() - ( + ( BX_HELP_VARIABLE ",h", value()->zero_tokens(), "Get a description and instructions for this command." ) - ( + ( "ADMINNAME", value(&auth_.name), "admin name." - ) + ) ( "ADMINAUTH", value(&auth_.auth), "admin password/authorization." - ); + ); return options; } diff --git a/include/metaverse/explorer/extensions/commands/stopmining.hpp b/include/metaverse/explorer/extensions/commands/stopmining.hpp index db1243b43..de281de21 100644 --- a/include/metaverse/explorer/extensions/commands/stopmining.hpp +++ b/include/metaverse/explorer/extensions/commands/stopmining.hpp @@ -60,21 +60,21 @@ class stopmining: public command_extension using namespace po; options_description& options = get_option_metadata(); options.add_options() - ( + ( BX_HELP_VARIABLE ",h", value()->zero_tokens(), "Get a description and instructions for this command." ) - ( + ( "ADMINNAME", value(&auth_.name), BX_ADMIN_NAME - ) + ) ( "ADMINAUTH", value(&auth_.auth), BX_ADMIN_AUTH - ); + ); return options; } diff --git a/include/metaverse/explorer/extensions/commands/submitwork.hpp b/include/metaverse/explorer/extensions/commands/submitwork.hpp index e2fd07866..2f64ab29a 100644 --- a/include/metaverse/explorer/extensions/commands/submitwork.hpp +++ b/include/metaverse/explorer/extensions/commands/submitwork.hpp @@ -62,7 +62,7 @@ class submitwork: public command_extension using namespace po; options_description& options = get_option_metadata(); options.add_options() - ( + ( BX_HELP_VARIABLE ",h", value()->zero_tokens(), "Get a description and instructions for this command." diff --git a/include/metaverse/explorer/extensions/commands/validateaddress.hpp b/include/metaverse/explorer/extensions/commands/validateaddress.hpp index 41b47d220..b0c076c0e 100644 --- a/include/metaverse/explorer/extensions/commands/validateaddress.hpp +++ b/include/metaverse/explorer/extensions/commands/validateaddress.hpp @@ -57,7 +57,7 @@ class validateaddress: public command_extension using namespace po; options_description& options = get_option_metadata(); options.add_options() - ( + ( BX_HELP_VARIABLE ",h", value()->zero_tokens(), "Get a description and instructions for this command." diff --git a/include/metaverse/explorer/extensions/node_method_wrapper.hpp b/include/metaverse/explorer/extensions/node_method_wrapper.hpp index c2500601c..4507bd0ca 100644 --- a/include/metaverse/explorer/extensions/node_method_wrapper.hpp +++ b/include/metaverse/explorer/extensions/node_method_wrapper.hpp @@ -1,5 +1,5 @@ /** - * Copyright (c) 2016-2018 mvs developers + * Copyright (c) 2016-2018 mvs developers * * This file is part of metaverse-explorer. * diff --git a/include/metaverse/explorer/impl/utility.ipp b/include/metaverse/explorer/impl/utility.ipp index 9a9d47f1a..b96c4b662 100644 --- a/include/metaverse/explorer/impl/utility.ipp +++ b/include/metaverse/explorer/impl/utility.ipp @@ -24,7 +24,7 @@ #ifdef _MSC_VER // Suppressing msvc warnings from boost that are heard to deal with // because boost/algorithm carelessly defines _SCL_SECURE_NO_WARNINGS -// without sampling it first. +// without sampling it first. #pragma warning(push) #pragma warning(disable : 4996) #endif @@ -71,7 +71,7 @@ template void deserialize(std::vector& collection, const std::string& text, bool trim) { - // This had problems with the inclusion of the ideographic (CJK) space + // This had problems with the inclusion of the ideographic (CJK) space // (0xe3,0x80, 0x80). Need to infuse the local in bc::split(). const auto tokens = split(text, " \n\r\t"); for (const auto& token: tokens) @@ -107,7 +107,7 @@ void load_path(Value& parameter, const std::string& name, // Get the argument value as a string. const auto path = boost::any_cast(variable->second.value()); - + // The path is the stdio sentinal, so clear parameter and don't read file. if (path == BX_STDIO_PATH_SENTINEL) { @@ -142,7 +142,7 @@ data_chunk serialize_satoshi_item(const Item& item) template void write_file(std::ostream& output, const std::string& path, const Instance& instance, bool terminate) -{ +{ if (path.empty() || path == BX_STDIO_PATH_SENTINEL) { output << instance; diff --git a/include/metaverse/explorer/utility.hpp b/include/metaverse/explorer/utility.hpp index c5cb40159..1c0a4a812 100644 --- a/include/metaverse/explorer/utility.hpp +++ b/include/metaverse/explorer/utility.hpp @@ -142,7 +142,7 @@ template data_chunk serialize_satoshi_item(const Item& item); /** - * Write a value to a file in the specified path and otherwise to the + * Write a value to a file in the specified path and otherwise to the * specified stream. Not unit testable due to embedded file i/o. * @param Instance The type of the instance to write. * @param[out] output The fallback out stream. diff --git a/include/metaverse/mgbubble/HttpServ.hpp b/include/metaverse/mgbubble/HttpServ.hpp index 722003587..707f89576 100644 --- a/include/metaverse/mgbubble/HttpServ.hpp +++ b/include/metaverse/mgbubble/HttpServ.hpp @@ -11,7 +11,7 @@ namespace libbitcoin{ namespace server{ - class server_node; + class server_node; } } @@ -66,7 +66,7 @@ class HttpServ : public MgServer MethodDelete = 1 << 3, // Method value mask. MethodMask = MethodGet | MethodPost | MethodPut | MethodDelete, - + // Subsequent bits represent matching components. MatchMethod = 1 << 4, MatchUri = 1 << 5, diff --git a/include/metaverse/mgbubble/MongooseCli.hpp b/include/metaverse/mgbubble/MongooseCli.hpp index 22d8f852b..e9e330de0 100644 --- a/include/metaverse/mgbubble/MongooseCli.hpp +++ b/include/metaverse/mgbubble/MongooseCli.hpp @@ -37,33 +37,33 @@ class MgrCli { MgrCli(MgrCli&&) = delete; MgrCli& operator=(MgrCli&&) = delete; - inline time_t poll(int milli) { return mg_mgr_poll(&mgr_, milli); } + inline time_t poll(int milli) { return mg_mgr_poll(&mgr_, milli); } protected: MgrCli() noexcept { mg_mgr_init(&mgr_, this); } ~MgrCli() noexcept { mg_mgr_free(&mgr_); } - static void ev_handler(mg_connection* nc, int ev, void *ev_data) { + static void ev_handler(mg_connection* nc, int ev, void *ev_data) { auto* hm = static_cast(ev_data); auto* self = static_cast(nc->user_data);//this - switch (ev) { - case MG_EV_CONNECT: - if (* (int *) ev_data != 0) { - fprintf(stderr, "connect[%s] failed: %s\n", + switch (ev) { + case MG_EV_CONNECT: + if (* (int *) ev_data != 0) { + fprintf(stderr, "connect[%s] failed: %s\n", self->get_url().c_str(), strerror(* (int *) ev_data)); self->exit(); - } - break; - case MG_EV_HTTP_REPLY: + } + break; + case MG_EV_HTTP_REPLY: nc->flags |= MG_F_CLOSE_IMMEDIATELY; self->reply(hm); self->exit(); - break; - default: - break; - } - } + break; + default: + break; + } + } mg_mgr mgr_; }; @@ -71,7 +71,7 @@ class MgrCli { class HttpReq : public MgrCli { public: - explicit HttpReq(const std::string& url, int milli, reply_handler&& oreply) + explicit HttpReq(const std::string& url, int milli, reply_handler&& oreply) :url_(url), reply(oreply){ memset(&opts_, 0x00, sizeof(opts_)); opts_.user_data = reinterpret_cast(this); @@ -79,7 +79,7 @@ class HttpReq : public MgrCli if (milli > 0) milli_ = milli; } - ~HttpReq() noexcept {} + ~HttpReq() noexcept {} //void got_reply(http_message* msg) { reply(msg); } diff --git a/include/metaverse/mgbubble/WsPushServ.hpp b/include/metaverse/mgbubble/WsPushServ.hpp index 452b7eb7c..c192bd884 100644 --- a/include/metaverse/mgbubble/WsPushServ.hpp +++ b/include/metaverse/mgbubble/WsPushServ.hpp @@ -36,7 +36,7 @@ namespace mgbubble { class WsEvent : public std::enable_shared_from_this { public: - explicit WsEvent(const std::function&& handler) + explicit WsEvent(const std::function&& handler) :callback_(std::move(handler)) {} @@ -51,7 +51,7 @@ class WsEvent : public std::enable_shared_from_this { self_.reset(); } - virtual void operator()(uint64_t id) + virtual void operator()(uint64_t id) { callback_(id); self_.reset(); diff --git a/include/metaverse/mgbubble/compat/string_view.h b/include/metaverse/mgbubble/compat/string_view.h index 3091624b6..15daa36cb 100644 --- a/include/metaverse/mgbubble/compat/string_view.h +++ b/include/metaverse/mgbubble/compat/string_view.h @@ -23,7 +23,7 @@ #ifdef _WIN32 #include #include -#define string_view boost::string_view +#define string_view boost::string_view #else diff --git a/include/metaverse/mgbubble/utility/Queue.hpp b/include/metaverse/mgbubble/utility/Queue.hpp index 0dfb7ec2b..f7ab1bb04 100644 --- a/include/metaverse/mgbubble/utility/Queue.hpp +++ b/include/metaverse/mgbubble/utility/Queue.hpp @@ -7,62 +7,62 @@ template class Queue { public: - Queue() = default; - Queue(Queue&&) = default; + Queue() = default; + Queue(Queue&&) = default; - void push(T&& item){ - std::unique_lock lock(lock_); - queue_.push_back(item); - cond_.notify_one(); - } + void push(T&& item){ + std::unique_lock lock(lock_); + queue_.push_back(item); + cond_.notify_one(); + } - void push(T& item){ - std::unique_lock lock(lock_); - queue_.push_back(item); - cond_.notify_one(); - } + void push(T& item){ + std::unique_lock lock(lock_); + queue_.push_back(item); + cond_.notify_one(); + } - bool empty(){ - std::unique_lock lock(lock_); - return queue_.empty(); - } + bool empty(){ + std::unique_lock lock(lock_); + return queue_.empty(); + } - int count(){ - std::unique_lock lock(lock_); - return queue_.size(); - } + int count(){ + std::unique_lock lock(lock_); + return queue_.size(); + } - void clear(){ - std::unique_lock lock(lock_); - std::deque tmp; - queue_.swap(tmp); - } + void clear(){ + std::unique_lock lock(lock_); + std::deque tmp; + queue_.swap(tmp); + } - bool pop(T& front){ - std::unique_lock lock(lock_); - if (!queue_.empty()){ - front = queue_.front(); - queue_.pop_front(); - return true; - } - return false; - } + bool pop(T& front){ + std::unique_lock lock(lock_); + if (!queue_.empty()){ + front = queue_.front(); + queue_.pop_front(); + return true; + } + return false; + } - bool pop_wait(T& front){ - std::unique_lock lock(lock_); - if (queue_.empty()){ - cond_.wait(lock); - } - if (!queue_.empty()){ - front = queue_.front(); - queue_.pop_front(); - return true; - } - return false; - } + bool pop_wait(T& front){ + std::unique_lock lock(lock_); + if (queue_.empty()){ + cond_.wait(lock); + } + if (!queue_.empty()){ + front = queue_.front(); + queue_.pop_front(); + return true; + } + return false; + } private: - mutable std::mutex lock_; - std::condition_variable cond_; - std::deque queue_; + mutable std::mutex lock_; + std::condition_variable cond_; + std::deque queue_; }; diff --git a/include/metaverse/network.hpp b/include/metaverse/network.hpp index 46757863c..fce1a7543 100644 --- a/include/metaverse/network.hpp +++ b/include/metaverse/network.hpp @@ -8,7 +8,7 @@ #define MVS_NETWORK_HPP /** - * API Users: Include only this header. Direct use of other headers is fragile + * API Users: Include only this header. Direct use of other headers is fragile * and unsupported as header organization is subject to change. * * Maintainers: Do not include this header internal to this library. diff --git a/include/metaverse/network/connections.hpp b/include/metaverse/network/connections.hpp index 594d6cac3..2ddf6fad0 100644 --- a/include/metaverse/network/connections.hpp +++ b/include/metaverse/network/connections.hpp @@ -87,8 +87,8 @@ class BCT_API connections { for (const auto channel: safe_copy()) { - auto handler_copy = handler; - channel->subscribe(std::move(handler_copy));//by jianglh + auto handler_copy = handler; + channel->subscribe(std::move(handler_copy));//by jianglh // channel->subscribe( // std::forward>(handler)); } diff --git a/include/metaverse/network/define.hpp b/include/metaverse/network/define.hpp index 30df270b8..7e7f0b8fa 100644 --- a/include/metaverse/network/define.hpp +++ b/include/metaverse/network/define.hpp @@ -23,9 +23,9 @@ #include -// We use the generic helper definitions in libbitcoin to define BCT_API +// We use the generic helper definitions in libbitcoin to define BCT_API // and BCT_INTERNAL. BCT_API is used for the public API symbols. It either DLL -// imports or DLL exports (or does nothing for static build) BCT_INTERNAL is +// imports or DLL exports (or does nothing for static build) BCT_INTERNAL is // used for non-api symbols. #if defined BCT_STATIC @@ -42,7 +42,7 @@ // Log name. #define LOG_NETWORK "network" -// Avoid namespace conflict between boost::placeholders and std::placeholders. +// Avoid namespace conflict between boost::placeholders and std::placeholders. #define BOOST_BIND_NO_PLACEHOLDERS // Include boost only here, so placeholders exclusion works. diff --git a/include/metaverse/network/hosts.hpp b/include/metaverse/network/hosts.hpp index 4ef43869b..271932790 100644 --- a/include/metaverse/network/hosts.hpp +++ b/include/metaverse/network/hosts.hpp @@ -42,10 +42,10 @@ namespace network { /// Duplicate addresses and those with zero-valued ports are disacarded. struct address_compare{ - bool operator()(const libbitcoin::message::network_address& lhs, const libbitcoin::message::network_address& rhs) const - { - return lhs.ip < rhs.ip ? true : (lhs.ip > rhs.ip ? false : lhs.port < rhs.port); - } + bool operator()(const libbitcoin::message::network_address& lhs, const libbitcoin::message::network_address& rhs) const + { + return lhs.ip < rhs.ip ? true : (lhs.ip > rhs.ip ? false : lhs.port < rhs.port); + } }; class BCT_API hosts diff --git a/include/metaverse/network/message_subscriber.hpp b/include/metaverse/network/message_subscriber.hpp index 9476e68f8..f46c68a72 100644 --- a/include/metaverse/network/message_subscriber.hpp +++ b/include/metaverse/network/message_subscriber.hpp @@ -93,7 +93,7 @@ class BCT_API message_subscriber /// This class is not copyable. message_subscriber(const message_subscriber&) = delete; void operator=(const message_subscriber&) = delete; - + /** * Subscribe to receive a notification when a message of type is received. * The handler is unregistered when the call is made. @@ -105,7 +105,7 @@ class BCT_API message_subscriber { subscribe(Message(), std::forward(handler)); } - + /** * Load a stream into a message instance and notify subscribers. * @param[in] stream The stream from which to load the message. diff --git a/include/metaverse/network/pending_channels.hpp b/include/metaverse/network/pending_channels.hpp index 78a67a6ce..1e83f4465 100644 --- a/include/metaverse/network/pending_channels.hpp +++ b/include/metaverse/network/pending_channels.hpp @@ -37,7 +37,7 @@ class BCT_API pending_channels public: typedef std::function truth_handler; typedef std::function result_handler; - + pending_channels(); ~pending_channels(); diff --git a/include/metaverse/network/pending_sockets.hpp b/include/metaverse/network/pending_sockets.hpp index 20e67709a..fce37c796 100644 --- a/include/metaverse/network/pending_sockets.hpp +++ b/include/metaverse/network/pending_sockets.hpp @@ -32,7 +32,7 @@ namespace network { /// Class to manage a pending socket pool, thread and lock safe. class BCT_API pending_sockets { -public: +public: pending_sockets(); ~pending_sockets(); diff --git a/include/metaverse/network/protocols/protocol_version.hpp b/include/metaverse/network/protocols/protocol_version.hpp index 8e7c8bbea..5215d86f9 100644 --- a/include/metaverse/network/protocols/protocol_version.hpp +++ b/include/metaverse/network/protocols/protocol_version.hpp @@ -47,7 +47,7 @@ class BCT_API protocol_version * @param[in] channel The channel on which to start the protocol. */ protocol_version(p2p& network, channel::ptr channel); - + /** * Start the protocol. * @param[in] handler Invoked upon stop or receipt of version and verack. diff --git a/include/metaverse/network/sessions/session_manual.hpp b/include/metaverse/network/sessions/session_manual.hpp index b3fb5cd38..00209efd0 100644 --- a/include/metaverse/network/sessions/session_manual.hpp +++ b/include/metaverse/network/sessions/session_manual.hpp @@ -34,7 +34,7 @@ namespace libbitcoin { namespace network { - + class p2p; /// Manual connections session, thread safe. @@ -63,7 +63,7 @@ class BCT_API session_manual virtual void attach_protocols(channel::ptr channel); void delay_new_connection(const std::string& hostname, uint16_t port - , channel_handler handler, uint32_t retries); + , channel_handler handler, uint32_t retries); private: void handle_started(const code& ec, result_handler handler); diff --git a/include/metaverse/node.hpp b/include/metaverse/node.hpp index 10490ae09..f82500057 100644 --- a/include/metaverse/node.hpp +++ b/include/metaverse/node.hpp @@ -8,7 +8,7 @@ #define MVS_NODE_HPP /** - * API Users: Include only this header. Direct use of other headers is fragile + * API Users: Include only this header. Direct use of other headers is fragile * and unsupported as header organization is subject to change. * * Maintainers: Do not include this header internal to this library. diff --git a/include/metaverse/node/configuration.hpp b/include/metaverse/node/configuration.hpp index f37ee6dfa..e5a49b746 100644 --- a/include/metaverse/node/configuration.hpp +++ b/include/metaverse/node/configuration.hpp @@ -45,7 +45,7 @@ namespace node { // This must match the case of the env var. #define BN_ENVIRONMENT_VARIABLE_PREFIX "BN_" - + /// Full node configuration, thread safe. class BCN_API configuration { diff --git a/include/metaverse/node/define.hpp b/include/metaverse/node/define.hpp index ef6eb0aed..8eeebfc0f 100644 --- a/include/metaverse/node/define.hpp +++ b/include/metaverse/node/define.hpp @@ -23,9 +23,9 @@ #include -// We use the generic helper definitions in libbitcoin to define BCN_API +// We use the generic helper definitions in libbitcoin to define BCN_API // and BCN_INTERNAL. BCN_API is used for the public API symbols. It either DLL -// imports or DLL exports (or does nothing for static build) BCN_INTERNAL is +// imports or DLL exports (or does nothing for static build) BCN_INTERNAL is // used for non-api symbols. #if defined BCN_STATIC diff --git a/include/metaverse/node/parser.hpp b/include/metaverse/node/parser.hpp index a5f926762..9f86e3339 100644 --- a/include/metaverse/node/parser.hpp +++ b/include/metaverse/node/parser.hpp @@ -55,7 +55,7 @@ class BCN_API parser /// The populated configuration settings values. configuration configured; -}; +}; } // namespace node } // namespace libbitcoin diff --git a/include/metaverse/node/protocols/protocol_block_out.hpp b/include/metaverse/node/protocols/protocol_block_out.hpp index 3dc1cf8f0..2d9ce0c5f 100644 --- a/include/metaverse/node/protocols/protocol_block_out.hpp +++ b/include/metaverse/node/protocols/protocol_block_out.hpp @@ -71,7 +71,7 @@ class BCN_API protocol_block_out bool handle_receive_send_headers(const code& ec, send_headers_ptr message); void handle_fetch_locator_hashes(const code& ec, const hash_list& hashes); - void handle_fetch_locator_headers(const code& ec, + void handle_fetch_locator_headers(const code& ec, const header_list& headers); void handle_stop(const code&); diff --git a/include/metaverse/node/protocols/protocol_block_sync.hpp b/include/metaverse/node/protocols/protocol_block_sync.hpp index da70e9438..20bc441e2 100644 --- a/include/metaverse/node/protocols/protocol_block_sync.hpp +++ b/include/metaverse/node/protocols/protocol_block_sync.hpp @@ -30,7 +30,7 @@ namespace libbitcoin { namespace node { - + /// Blocks sync protocol, thread safe. class BCN_API protocol_block_sync : public network::protocol_timer, public track diff --git a/include/metaverse/node/protocols/protocol_header_sync.hpp b/include/metaverse/node/protocols/protocol_header_sync.hpp index 4c9f772e9..3e3791f1e 100644 --- a/include/metaverse/node/protocols/protocol_header_sync.hpp +++ b/include/metaverse/node/protocols/protocol_header_sync.hpp @@ -32,7 +32,7 @@ namespace libbitcoin { namespace node { - + /// Headers sync protocol, thread safe. class BCN_API protocol_header_sync : public network::protocol_timer, public track diff --git a/include/metaverse/node/protocols/protocol_miner.hpp b/include/metaverse/node/protocols/protocol_miner.hpp index cbe8bacce..119876ddb 100644 --- a/include/metaverse/node/protocols/protocol_miner.hpp +++ b/include/metaverse/node/protocols/protocol_miner.hpp @@ -35,22 +35,22 @@ namespace node { class BCN_API protocol_miner: - public network::protocol_events, track + public network::protocol_events, track { public: - using ptr = std::shared_ptr; - using indexes = chain::point::indexes; - using transaction_ptr = message::transaction_message::ptr; - protocol_miner(network::p2p& network, network::channel::ptr channel - , blockchain::block_chain& blockchain - /*, blockchain::transaction_pool& pool*/); - virtual void start(); + using ptr = std::shared_ptr; + using indexes = chain::point::indexes; + using transaction_ptr = message::transaction_message::ptr; + protocol_miner(network::p2p& network, network::channel::ptr channel + , blockchain::block_chain& blockchain + /*, blockchain::transaction_pool& pool*/); + virtual void start(); private: - void handle_stop(const code& ec); -// bool handle_accept_transaction(const code&, const indexes&, transaction_ptr); + void handle_stop(const code& ec); +// bool handle_accept_transaction(const code&, const indexes&, transaction_ptr); private: - blockchain::block_chain& blockchain_; -// blockchain::transaction_pool& pool_; + blockchain::block_chain& blockchain_; +// blockchain::transaction_pool& pool_; }; }// namespace node diff --git a/include/metaverse/node/sessions/session_header_sync.hpp b/include/metaverse/node/sessions/session_header_sync.hpp index d5c1e0c25..600f92226 100644 --- a/include/metaverse/node/sessions/session_header_sync.hpp +++ b/include/metaverse/node/sessions/session_header_sync.hpp @@ -32,7 +32,7 @@ namespace libbitcoin { namespace node { - + /// Class to manage initial header download connection, thread safe. class BCN_API session_header_sync : public network::session_batch, track diff --git a/include/metaverse/node/utility/reservations.hpp b/include/metaverse/node/utility/reservations.hpp index 43d637ded..926bfc577 100644 --- a/include/metaverse/node/utility/reservations.hpp +++ b/include/metaverse/node/utility/reservations.hpp @@ -74,8 +74,8 @@ class BCN_API reservations void set_max_request(size_t value); std::size_t size() { - shared_lock lock(mutex_); - return table_.size(); + shared_lock lock(mutex_); + return table_.size(); } private: diff --git a/include/metaverse/protocol.hpp b/include/metaverse/protocol.hpp index 1ebdb53e9..d8eac1918 100644 --- a/include/metaverse/protocol.hpp +++ b/include/metaverse/protocol.hpp @@ -8,7 +8,7 @@ #define MVS_PROTOCOL_HPP /** - * API Users: Include only this header. Direct use of other headers is fragile + * API Users: Include only this header. Direct use of other headers is fragile * and unsupported as header organization is subject to change. * * Maintainers: Do not include this header internal to this library. diff --git a/include/metaverse/protocol/define.hpp b/include/metaverse/protocol/define.hpp index d7fd5ca37..f4d5136b6 100644 --- a/include/metaverse/protocol/define.hpp +++ b/include/metaverse/protocol/define.hpp @@ -23,9 +23,9 @@ #include -// We use the generic helper definitions in libbitcoin to define BCP_API +// We use the generic helper definitions in libbitcoin to define BCP_API // and BCP_INTERNAL. BCP_API is used for the public API symbols. It either DLL -// imports or DLL exports (or does nothing for static build) BCP_INTERNAL is +// imports or DLL exports (or does nothing for static build) BCP_INTERNAL is // used for non-api symbols. #if defined BCP_STATIC diff --git a/include/metaverse/protocol/zmq/authenticator.hpp b/include/metaverse/protocol/zmq/authenticator.hpp index 7694ea73c..909be1314 100644 --- a/include/metaverse/protocol/zmq/authenticator.hpp +++ b/include/metaverse/protocol/zmq/authenticator.hpp @@ -6,7 +6,7 @@ * metaverse-protocol is free software: you can redistribute it and/or * modify it under the terms of the GNU Affero General Public License with * additional permissions to the one published by the Free Software - * Foundation, either version 3 of the License, or (at your option) + * Foundation, either version 3 of the License, or (at your option) * any later version. For more information see LICENSE. * * This program is distributed in the hope that it will be useful, diff --git a/include/metaverse/protocol/zmq/certificate.hpp b/include/metaverse/protocol/zmq/certificate.hpp index 7dea95221..db60cc024 100644 --- a/include/metaverse/protocol/zmq/certificate.hpp +++ b/include/metaverse/protocol/zmq/certificate.hpp @@ -6,7 +6,7 @@ * metaverse-protocol is free software: you can redistribute it and/or * modify it under the terms of the GNU Affero General Public License with * additional permissions to the one published by the Free Software - * Foundation, either version 3 of the License, or (at your option) + * Foundation, either version 3 of the License, or (at your option) * any later version. For more information see LICENSE. * * This program is distributed in the hope that it will be useful, diff --git a/include/metaverse/protocol/zmq/context.hpp b/include/metaverse/protocol/zmq/context.hpp index c76c63e06..89630f682 100644 --- a/include/metaverse/protocol/zmq/context.hpp +++ b/include/metaverse/protocol/zmq/context.hpp @@ -6,7 +6,7 @@ * metaverse-protocol is free software: you can redistribute it and/or * modify it under the terms of the GNU Affero General Public License with * additional permissions to the one published by the Free Software - * Foundation, either version 3 of the License, or (at your option) + * Foundation, either version 3 of the License, or (at your option) * any later version. For more information see LICENSE. * * This program is distributed in the hope that it will be useful, diff --git a/include/metaverse/protocol/zmq/frame.hpp b/include/metaverse/protocol/zmq/frame.hpp index 37837b942..f12502d98 100644 --- a/include/metaverse/protocol/zmq/frame.hpp +++ b/include/metaverse/protocol/zmq/frame.hpp @@ -6,7 +6,7 @@ * metaverse-protocol is free software: you can redistribute it and/or * modify it under the terms of the GNU Affero General Public License with * additional permissions to the one published by the Free Software - * Foundation, either version 3 of the License, or (at your option) + * Foundation, either version 3 of the License, or (at your option) * any later version. For more information see LICENSE. * * This program is distributed in the hope that it will be useful, diff --git a/include/metaverse/protocol/zmq/identifiers.hpp b/include/metaverse/protocol/zmq/identifiers.hpp index bc0638cfd..a9cd7970e 100644 --- a/include/metaverse/protocol/zmq/identifiers.hpp +++ b/include/metaverse/protocol/zmq/identifiers.hpp @@ -6,7 +6,7 @@ * metaverse-protocol is free software: you can redistribute it and/or * modify it under the terms of the GNU Affero General Public License with * additional permissions to the one published by the Free Software - * Foundation, either version 3 of the License, or (at your option) + * Foundation, either version 3 of the License, or (at your option) * any later version. For more information see LICENSE. * * This program is distributed in the hope that it will be useful, diff --git a/include/metaverse/protocol/zmq/message.hpp b/include/metaverse/protocol/zmq/message.hpp index be0a00e9c..cc1d4049d 100644 --- a/include/metaverse/protocol/zmq/message.hpp +++ b/include/metaverse/protocol/zmq/message.hpp @@ -6,7 +6,7 @@ * metaverse-protocol is free software: you can redistribute it and/or * modify it under the terms of the GNU Affero General Public License with * additional permissions to the one published by the Free Software - * Foundation, either version 3 of the License, or (at your option) + * Foundation, either version 3 of the License, or (at your option) * any later version. For more information see LICENSE. * * This program is distributed in the hope that it will be useful, diff --git a/include/metaverse/protocol/zmq/poller.hpp b/include/metaverse/protocol/zmq/poller.hpp index 69b561b1e..86c36cd1a 100644 --- a/include/metaverse/protocol/zmq/poller.hpp +++ b/include/metaverse/protocol/zmq/poller.hpp @@ -6,7 +6,7 @@ * metaverse-protocol is free software: you can redistribute it and/or * modify it under the terms of the GNU Affero General Public License with * additional permissions to the one published by the Free Software - * Foundation, either version 3 of the License, or (at your option) + * Foundation, either version 3 of the License, or (at your option) * any later version. For more information see LICENSE. * * This program is distributed in the hope that it will be useful, diff --git a/include/metaverse/protocol/zmq/socket.hpp b/include/metaverse/protocol/zmq/socket.hpp index d25ff6487..6bd751aa5 100644 --- a/include/metaverse/protocol/zmq/socket.hpp +++ b/include/metaverse/protocol/zmq/socket.hpp @@ -6,7 +6,7 @@ * metaverse-protocol is free software: you can redistribute it and/or * modify it under the terms of the GNU Affero General Public License with * additional permissions to the one published by the Free Software - * Foundation, either version 3 of the License, or (at your option) + * Foundation, either version 3 of the License, or (at your option) * any later version. For more information see LICENSE. * * This program is distributed in the hope that it will be useful, diff --git a/include/metaverse/protocol/zmq/worker.hpp b/include/metaverse/protocol/zmq/worker.hpp index 6b53b8871..7843f3d0e 100644 --- a/include/metaverse/protocol/zmq/worker.hpp +++ b/include/metaverse/protocol/zmq/worker.hpp @@ -6,7 +6,7 @@ * metaverse-protocol is free software: you can redistribute it and/or * modify it under the terms of the GNU Affero General Public License with * additional permissions to the one published by the Free Software - * Foundation, either version 3 of the License, or (at your option) + * Foundation, either version 3 of the License, or (at your option) * any later version. For more information see LICENSE. * * This program is distributed in the hope that it will be useful, diff --git a/include/metaverse/protocol/zmq/zeromq.hpp b/include/metaverse/protocol/zmq/zeromq.hpp index aca48fb49..3aa8311d8 100644 --- a/include/metaverse/protocol/zmq/zeromq.hpp +++ b/include/metaverse/protocol/zmq/zeromq.hpp @@ -6,7 +6,7 @@ * metaverse-protocol is free software: you can redistribute it and/or * modify it under the terms of the GNU Affero General Public License with * additional permissions to the one published by the Free Software - * Foundation, either version 3 of the License, or (at your option) + * Foundation, either version 3 of the License, or (at your option) * any later version. For more information see LICENSE. * * This program is distributed in the hope that it will be useful, diff --git a/include/metaverse/server.hpp b/include/metaverse/server.hpp index 267fa00c9..36e5a000b 100644 --- a/include/metaverse/server.hpp +++ b/include/metaverse/server.hpp @@ -8,7 +8,7 @@ #define MVS_SERVER_HPP /** - * API Users: Include only this header. Direct use of other headers is fragile + * API Users: Include only this header. Direct use of other headers is fragile * and unsupported as header organization is subject to change. * * Maintainers: Do not include this header internal to this library. diff --git a/include/metaverse/server/define.hpp b/include/metaverse/server/define.hpp index 12148a926..ef46251a4 100644 --- a/include/metaverse/server/define.hpp +++ b/include/metaverse/server/define.hpp @@ -23,9 +23,9 @@ #include -// We use the generic helper definitions in libbitcoin to define BCS_API +// We use the generic helper definitions in libbitcoin to define BCS_API // and BCS_INTERNAL. BCS_API is used for the public API symbols. It either DLL -// imports or DLL exports (or does nothing for static build) BCS_INTERNAL is +// imports or DLL exports (or does nothing for static build) BCS_INTERNAL is // used for non-api symbols. #if defined BCS_STATIC @@ -42,7 +42,7 @@ // Log name. #define LOG_SERVER "server" -// Avoid namespace conflict between boost::placeholders and std::placeholders. +// Avoid namespace conflict between boost::placeholders and std::placeholders. #define BOOST_BIND_NO_PLACEHOLDERS // Include boost only here, so placeholders exclusion works. diff --git a/include/metaverse/server/interface/blockchain.hpp b/include/metaverse/server/interface/blockchain.hpp index 0f65c5c36..c729a60d7 100644 --- a/include/metaverse/server/interface/blockchain.hpp +++ b/include/metaverse/server/interface/blockchain.hpp @@ -29,7 +29,7 @@ namespace libbitcoin { namespace server { - + /// Blockchain interface. /// These queries results do NOT include transaction pool information. /// Class and method names are published and mapped to the zeromq interface. @@ -103,7 +103,7 @@ class BCS_API blockchain static void transaction_index_fetched(const code& ec, size_t block_height, size_t index, const message& request, send_handler handler); - static void spend_fetched(const code& ec, + static void spend_fetched(const code& ec, const chain::input_point& inpoint, const message& request, send_handler handler); diff --git a/include/metaverse/server/interface/protocol.hpp b/include/metaverse/server/interface/protocol.hpp index 88fb8c5af..33a1b4c95 100644 --- a/include/metaverse/server/interface/protocol.hpp +++ b/include/metaverse/server/interface/protocol.hpp @@ -28,7 +28,7 @@ namespace libbitcoin { namespace server { - + /// Protocol interface. /// Class and method names are published and mapped to the zeromq interface. class BCS_API protocol diff --git a/include/metaverse/server/server_node.hpp b/include/metaverse/server/server_node.hpp index 56cc616e4..c4824e0b4 100644 --- a/include/metaverse/server/server_node.hpp +++ b/include/metaverse/server/server_node.hpp @@ -117,7 +117,7 @@ class BCS_API server_node bool start_block_services(); bool start_transaction_services(); bool start_query_workers(bool secure); - + bool open_ui(); std::atomic under_blockchain_sync_; diff --git a/include/metaverse/server/utility/coredump.hpp b/include/metaverse/server/utility/coredump.hpp index 8453e52d2..aa113d333 100644 --- a/include/metaverse/server/utility/coredump.hpp +++ b/include/metaverse/server/utility/coredump.hpp @@ -57,7 +57,7 @@ LONG WINAPI exp_filter(struct _EXCEPTION_POINTERS *pExp) void start_unhandled_exception_filter() { #ifdef _MSC_VER - ::SetUnhandledExceptionFilter(exp_filter); + ::SetUnhandledExceptionFilter(exp_filter); #endif } diff --git a/src/lib/bitcoin/chain/attachment/asset/asset_transfer.cpp b/src/lib/bitcoin/chain/attachment/asset/asset_transfer.cpp index 7995c63b2..0f6d939dc 100644 --- a/src/lib/bitcoin/chain/attachment/asset/asset_transfer.cpp +++ b/src/lib/bitcoin/chain/attachment/asset/asset_transfer.cpp @@ -36,7 +36,7 @@ bool asset_balances::operator< (const asset_balances& other) const return cmp_tuple(symbol, address, unspent_asset, locked_asset) < cmp_tuple(other.symbol, other.address, other.unspent_asset, other.locked_asset); } - + asset_transfer::asset_transfer() { reset(); diff --git a/src/lib/bitcoin/chain/attachment/asset/blockchain_asset.cpp b/src/lib/bitcoin/chain/attachment/asset/blockchain_asset.cpp index 2ce250c8d..1d07baec7 100644 --- a/src/lib/bitcoin/chain/attachment/asset/blockchain_asset.cpp +++ b/src/lib/bitcoin/chain/attachment/asset/blockchain_asset.cpp @@ -31,10 +31,10 @@ namespace chain { blockchain_asset::blockchain_asset() { - reset(); + reset(); } blockchain_asset::blockchain_asset(uint32_t version, const output_point& tx_point, - uint64_t height, const asset_detail& asset): + uint64_t height, const asset_detail& asset): version_(version), tx_point_(tx_point), height_(height), asset_(asset) { } @@ -65,11 +65,11 @@ bool blockchain_asset::is_valid() const } void blockchain_asset::reset() -{ +{ version_ = 0; tx_point_ = output_point(); - height_ = 0; - asset_ = asset_detail(); + height_ = 0; + asset_ = asset_detail(); } bool blockchain_asset::from_data(const data_chunk& data) @@ -89,11 +89,11 @@ bool blockchain_asset::from_data(reader& source) reset(); version_ = source.read_4_bytes_little_endian(); - tx_point_.from_data(source); + tx_point_.from_data(source); height_ = source.read_8_bytes_little_endian(); - asset_.from_data(source); + asset_.from_data(source); - return true; + return true; } data_chunk blockchain_asset::to_data() const @@ -115,9 +115,9 @@ void blockchain_asset::to_data(std::ostream& stream) const void blockchain_asset::to_data(writer& sink) const { sink.write_4_bytes_little_endian(version_); - tx_point_.to_data(sink); + tx_point_.to_data(sink); sink.write_8_bytes_little_endian(height_); - asset_.to_data(sink); + asset_.to_data(sink); } uint64_t blockchain_asset::serialized_size() const @@ -131,47 +131,47 @@ std::string blockchain_asset::to_string() const std::ostringstream ss; ss << "\t version = " << version_ << "\n" - << "\t tx_point = " << tx_point_.to_string() << "\n" - << "\t height = " << height_ << "\n" - << "\t asset = " << asset_.to_string() << "\n"; + << "\t tx_point = " << tx_point_.to_string() << "\n" + << "\t height = " << height_ << "\n" + << "\t asset = " << asset_.to_string() << "\n"; return ss.str(); } #endif const uint32_t& blockchain_asset::get_version() const -{ +{ return version_; } void blockchain_asset::set_version(const uint32_t& version_) -{ +{ this->version_ = version_; } const output_point& blockchain_asset::get_tx_point() const -{ +{ return tx_point_; } void blockchain_asset::set_tx_point(const output_point& tx_point_) -{ +{ this->tx_point_ = tx_point_; } const uint64_t& blockchain_asset::get_height() const -{ +{ return height_; } void blockchain_asset::set_height(const uint64_t& height_) -{ +{ this->height_ = height_; } const asset_detail& blockchain_asset::get_asset() const -{ +{ return asset_; } void blockchain_asset::set_asset(const asset_detail& asset_) -{ +{ this->asset_ = asset_; } diff --git a/src/lib/bitcoin/chain/attachment/did/blockchain_did.cpp b/src/lib/bitcoin/chain/attachment/did/blockchain_did.cpp index 23e6b41e9..a1c565c92 100644 --- a/src/lib/bitcoin/chain/attachment/did/blockchain_did.cpp +++ b/src/lib/bitcoin/chain/attachment/did/blockchain_did.cpp @@ -31,10 +31,10 @@ namespace chain { blockchain_did::blockchain_did() { - reset(); + reset(); } blockchain_did::blockchain_did(uint32_t version, const output_point& tx_point, - uint64_t height, uint32_t status, const did_detail& did): + uint64_t height, uint32_t status, const did_detail& did): version_(version), tx_point_(tx_point), height_(height), status_(status), did_(did) { } @@ -65,12 +65,12 @@ bool blockchain_did::is_valid() const } void blockchain_did::reset() -{ +{ version_ = 0; tx_point_ = output_point(); - height_ = 0; + height_ = 0; status_ = address_invalid; - did_ = did_detail(); + did_ = did_detail(); } bool blockchain_did::from_data(const data_chunk& data) @@ -90,12 +90,12 @@ bool blockchain_did::from_data(reader& source) reset(); version_ = source.read_4_bytes_little_endian(); - tx_point_.from_data(source); + tx_point_.from_data(source); height_ = source.read_8_bytes_little_endian(); status_ = source.read_4_bytes_little_endian(); - did_.from_data(source); + did_.from_data(source); - return true; + return true; } data_chunk blockchain_did::to_data() const @@ -117,10 +117,10 @@ void blockchain_did::to_data(std::ostream& stream) const void blockchain_did::to_data(writer& sink) const { sink.write_4_bytes_little_endian(version_); - tx_point_.to_data(sink); + tx_point_.to_data(sink); sink.write_8_bytes_little_endian(height_); sink.write_4_bytes_little_endian(status_); - did_.to_data(sink); + did_.to_data(sink); } uint64_t blockchain_did::serialized_size() const @@ -134,48 +134,48 @@ std::string blockchain_did::to_string() const std::ostringstream ss; ss << "\t version = " << version_ << "\n" - << "\t tx_point = " << tx_point_.to_string() << "\n" - << "\t height = " << height_ << "\n" - << "\t status = " << get_status_string().c_str() << "\n" - << "\t did = " << did_.to_string() << "\n"; + << "\t tx_point = " << tx_point_.to_string() << "\n" + << "\t height = " << height_ << "\n" + << "\t status = " << get_status_string().c_str() << "\n" + << "\t did = " << did_.to_string() << "\n"; return ss.str(); } #endif const uint32_t& blockchain_did::get_version() const -{ +{ return version_; } void blockchain_did::set_version(const uint32_t& version_) -{ +{ this->version_ = version_; } const output_point& blockchain_did::get_tx_point() const -{ +{ return tx_point_; } void blockchain_did::set_tx_point(const output_point& tx_point_) -{ +{ this->tx_point_ = tx_point_; } const uint64_t& blockchain_did::get_height() const -{ +{ return height_; } void blockchain_did::set_height(const uint64_t& height_) -{ +{ this->height_ = height_; } const did_detail& blockchain_did::get_did() const -{ +{ return did_; } void blockchain_did::set_did(const did_detail& did_) -{ +{ this->did_ = did_; } diff --git a/src/lib/bitcoin/chain/attachment/did/did.cpp b/src/lib/bitcoin/chain/attachment/did/did.cpp index f4504bc85..a4a0d38a7 100644 --- a/src/lib/bitcoin/chain/attachment/did/did.cpp +++ b/src/lib/bitcoin/chain/attachment/did/did.cpp @@ -32,10 +32,10 @@ namespace chain { did::did() { - reset(); + reset(); } did::did(uint32_t status, const did_detail& detail): - status(status), data(detail) + status(status), data(detail) { } @@ -74,7 +74,7 @@ bool did::is_valid() const bool did::is_valid_type() const { return ((DID_DETAIL_TYPE == status) - || (DID_TRANSFERABLE_TYPE == status)); + || (DID_TRANSFERABLE_TYPE == status)); } bool did::from_data(const data_chunk& data) @@ -95,15 +95,15 @@ bool did::from_data(reader& source) status = source.read_4_bytes_little_endian(); auto result = static_cast(source); - + if (result && is_valid_type()) { result = data.from_data(source); } - else { - result = false; - reset(); - } - + else { + result = false; + reset(); + } + return result; } @@ -131,7 +131,7 @@ void did::to_data(writer& sink) const uint64_t did::serialized_size() const { - return 4 + data.serialized_size(); + return 4 + data.serialized_size(); } std::string did::to_string() const @@ -144,20 +144,20 @@ std::string did::to_string() const uint32_t did::get_status() const { - return status; + return status; } void did::set_status(uint32_t status) { - this->status = status; + this->status = status; } void did::set_data(const did_detail& detail) { - this->data = detail; + this->data = detail; } const did_detail& did::get_data() const { - return this->data; + return this->data; } } // namspace chain diff --git a/src/lib/bitcoin/chain/attachment/etp/etp.cpp b/src/lib/bitcoin/chain/attachment/etp/etp.cpp index d165969ac..11fccc4d3 100644 --- a/src/lib/bitcoin/chain/attachment/etp/etp.cpp +++ b/src/lib/bitcoin/chain/attachment/etp/etp.cpp @@ -30,10 +30,10 @@ namespace chain { etp::etp() { - value = 0; + value = 0; } etp::etp(uint64_t value): - value(value) + value(value) { } @@ -61,7 +61,7 @@ etp etp::factory_from_data(reader& source) void etp::reset() { - value= 0; + value= 0; } bool etp::is_valid() const { @@ -82,14 +82,14 @@ bool etp::from_data(std::istream& stream) bool etp::from_data(reader& source) { - /* + /* reset(); value = source.read_8_bytes_little_endian(); auto result = static_cast(source); - + return result; - */ - return true; + */ + return true; } data_chunk etp::to_data() const @@ -110,31 +110,31 @@ void etp::to_data(std::ostream& stream) const void etp::to_data(writer& sink) const { - //sink.write_8_bytes_little_endian(value); // not use etp now + //sink.write_8_bytes_little_endian(value); // not use etp now } uint64_t etp::serialized_size() const { //uint64_t size = 8; - //return size; - return 0; // not insert ept into transaction + //return size; + return 0; // not insert ept into transaction } std::string etp::to_string() const { std::ostringstream ss; - ss << "\t value = " << value << "\n"; + ss << "\t value = " << value << "\n"; return ss.str(); } uint64_t etp::get_value() const { - return value; + return value; } void etp::set_value(uint64_t value) { - this->value = value; + this->value = value; } } // namspace chain diff --git a/src/lib/bitcoin/chain/attachment/etp/etp_award.cpp b/src/lib/bitcoin/chain/attachment/etp/etp_award.cpp index 6d87fc7cf..8c6cc94e0 100644 --- a/src/lib/bitcoin/chain/attachment/etp/etp_award.cpp +++ b/src/lib/bitcoin/chain/attachment/etp/etp_award.cpp @@ -30,10 +30,10 @@ namespace chain { etp_award::etp_award() { - height = 0; + height = 0; } etp_award::etp_award(uint64_t height): - height(height) + height(height) { } @@ -61,7 +61,7 @@ etp_award etp_award::factory_from_data(reader& source) void etp_award::reset() { - height= 0; + height= 0; } bool etp_award::is_valid() const { @@ -85,7 +85,7 @@ bool etp_award::from_data(reader& source) reset(); height = source.read_8_bytes_little_endian(); auto result = static_cast(source); - + return result; } @@ -107,30 +107,30 @@ void etp_award::to_data(std::ostream& stream) const void etp_award::to_data(writer& sink) const { - sink.write_8_bytes_little_endian(height); + sink.write_8_bytes_little_endian(height); } uint64_t etp_award::serialized_size() const { //uint64_t size = 8; - return 8; + return 8; } std::string etp_award::to_string() const { std::ostringstream ss; - ss << "\t height = " << height << "\n"; + ss << "\t height = " << height << "\n"; return ss.str(); } uint64_t etp_award::get_height() const { - return height; + return height; } void etp_award::set_height(uint64_t height) { - this->height = height; + this->height = height; } } // namspace chain diff --git a/src/lib/bitcoin/chain/transaction.cpp b/src/lib/bitcoin/chain/transaction.cpp index 723e3259b..fc816fdc3 100644 --- a/src/lib/bitcoin/chain/transaction.cpp +++ b/src/lib/bitcoin/chain/transaction.cpp @@ -417,34 +417,34 @@ bool transaction::has_did_register() const bool transaction::has_did_transfer() const { - for (auto& elem: outputs) { - if(elem.is_did_transfer()) - return true; - } - return false; + for (auto& elem: outputs) { + if(elem.is_did_transfer()) + return true; + } + return false; } std::string transaction::get_did_transfer_old_address() const { std::string newdidstr = ""; - for (auto& elem: outputs) { - if(elem.is_did_transfer()) { + for (auto& elem: outputs) { + if(elem.is_did_transfer()) { newdidstr = elem.get_script_address(); } - } + } if (newdidstr.empty()){ return newdidstr; } for (auto& elem: inputs) { - if(elem.get_script_address()!=newdidstr) { + if(elem.get_script_address()!=newdidstr) { newdidstr = elem.get_script_address(); return newdidstr; } - } + } return newdidstr; diff --git a/src/lib/bitcoin/config/base2.cpp b/src/lib/bitcoin/config/base2.cpp index cefc22e59..0a2bbd3ad 100644 --- a/src/lib/bitcoin/config/base2.cpp +++ b/src/lib/bitcoin/config/base2.cpp @@ -56,7 +56,7 @@ size_t base2::size() const base2::operator const binary&() const { - return value_; + return value_; } std::istream& operator>>(std::istream& input, base2& argument) diff --git a/src/lib/bitcoin/config/checkpoint.cpp b/src/lib/bitcoin/config/checkpoint.cpp index c60d79b8d..176071249 100644 --- a/src/lib/bitcoin/config/checkpoint.cpp +++ b/src/lib/bitcoin/config/checkpoint.cpp @@ -33,7 +33,7 @@ namespace libbitcoin { namespace config { - + using namespace boost; using namespace boost::program_options; diff --git a/src/lib/bitcoin/config/parameter.cpp b/src/lib/bitcoin/config/parameter.cpp index 20b90f153..4c37b6d1b 100644 --- a/src/lib/bitcoin/config/parameter.cpp +++ b/src/lib/bitcoin/config/parameter.cpp @@ -66,14 +66,14 @@ char parameter::short_name(const po::option_description& option) const // This is a substitute that allows us to use boost 1.49 for libbitcoin. const auto name = split(option.format_name()).front(); - auto is_short_name = name[0] == option_prefix_char && + auto is_short_name = name[0] == option_prefix_char && name[1] != option_prefix_char; return is_short_name ? name[1] : no_short_name; } // 100% component coverage -unsigned parameter::arguments_limit(int position, +unsigned parameter::arguments_limit(int position, const po::option_description& option, const argument_list& arguments) const { if (position == parameter::not_positional) diff --git a/src/lib/bitcoin/config/printer.cpp b/src/lib/bitcoin/config/printer.cpp index 23b3012b6..a2ecd8e02 100644 --- a/src/lib/bitcoin/config/printer.cpp +++ b/src/lib/bitcoin/config/printer.cpp @@ -134,7 +134,7 @@ static std::string format_row_name(const parameter& value) // wants to be upper case but must match in case with the env var option. if (value.get_position() != parameter::not_positional) - return (format(BC_PRINTER_TABLE_ARGUMENT_FORMAT) % + return (format(BC_PRINTER_TABLE_ARGUMENT_FORMAT) % boost::to_upper_copy(value.get_long_name())).str(); else if (value.get_short_name() == parameter::no_short_name) return (format(BC_PRINTER_TABLE_OPTION_LONG_FORMAT) % @@ -277,7 +277,7 @@ std::string printer::format_settings_table() std::string printer::format_usage() { - // USAGE: bx COMMAND [-hvt] -n VALUE [-m VALUE] [-w VALUE]... REQUIRED + // USAGE: bx COMMAND [-hvt] -n VALUE [-m VALUE] [-w VALUE]... REQUIRED // [OPTIONAL] [MULTIPLE]... auto usage = format(BC_PRINTER_USAGE_FORMAT) % get_application() % get_command() % format_usage_parameters(); @@ -306,7 +306,7 @@ std::string printer::format_usage_parameters() std::vector multiple_arguments; const auto& parameters = get_parameters(); - + for (const auto& parameter: parameters) { // A required argument may only be preceeded by required arguments. @@ -364,7 +364,7 @@ std::string printer::format_usage_parameters() for (const auto& required_option: required_options) usage << format(BC_PRINTER_USAGE_OPTION_REQUIRED_FORMAT) % required_option % BC_PRINTER_VALUE_TEXT; - + for (const auto& toggle_long_option: toggle_long_options) usage << format(BC_PRINTER_USAGE_OPTION_TOGGLE_LONG_FORMAT) % toggle_long_option; @@ -424,7 +424,7 @@ void printer::generate_argument_names() int max_previous_argument = 0; // We must enumerate all arguments to get the full set of names and counts. - for (unsigned int position = 0; position < max_total_arguments && + for (unsigned int position = 0; position < max_total_arguments && max_previous_argument <= max_arguments; ++position) { argument_name = arguments.name_for_position(position); diff --git a/src/lib/bitcoin/formats/base_58.cpp b/src/lib/bitcoin/formats/base_58.cpp index c6660d66a..1a7acb3b0 100644 --- a/src/lib/bitcoin/formats/base_58.cpp +++ b/src/lib/bitcoin/formats/base_58.cpp @@ -105,7 +105,7 @@ std::string encode_base58(data_slice unencoded) // Translate the result into a string. std::string encoded; - const size_t estimated_size = leading_zeros + + const size_t estimated_size = leading_zeros + (indexes.end() - first_nonzero); encoded.reserve(estimated_size); encoded.assign(leading_zeros, '1'); diff --git a/src/lib/bitcoin/formats/base_64.cpp b/src/lib/bitcoin/formats/base_64.cpp index 1b799113f..a11bc3351 100644 --- a/src/lib/bitcoin/formats/base_64.cpp +++ b/src/lib/bitcoin/formats/base_64.cpp @@ -31,7 +31,7 @@ namespace libbitcoin { const static char pad = '='; -const static char table[] = +const static char table[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; std::string encode_base64(data_slice unencoded) diff --git a/src/lib/bitcoin/formats/base_85.cpp b/src/lib/bitcoin/formats/base_85.cpp index 95d108a84..8646f6293 100644 --- a/src/lib/bitcoin/formats/base_85.cpp +++ b/src/lib/bitcoin/formats/base_85.cpp @@ -23,28 +23,28 @@ // -------------------------------------------------------------------------- // Reference implementation for rfc.zeromq.org/spec:32/Z85 // -// This implementation provides a Z85 codec as an easy-to-reuse C class +// This implementation provides a Z85 codec as an easy-to-reuse C class // designed to be easy to port into other languages. // -------------------------------------------------------------------------- // Copyright (c) 2010-2013 iMatix Corporation and Contributors -// -// Permission is hereby granted, free of charge, to any person obtaining a +// +// Permission is hereby granted, free of charge, to any person obtaining a // copy of this software and associated documentation files (the "Software"), -// to deal in the Software without restriction, including without limitation -// the rights to use, copy, modify, merge, publish, distribute, sublicense, -// and/or sell copies of the Software, and to permit persons to whom the +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the // Software is furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in +// +// The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. // -------------------------------------------------------------------------- @@ -57,7 +57,7 @@ #include namespace libbitcoin { - + // Maps binary to base 85. static char encoder[85 + 1] = { diff --git a/src/lib/bitcoin/math/elliptic_curve.cpp b/src/lib/bitcoin/math/elliptic_curve.cpp index 11079c733..00b110f04 100644 --- a/src/lib/bitcoin/math/elliptic_curve.cpp +++ b/src/lib/bitcoin/math/elliptic_curve.cpp @@ -30,7 +30,7 @@ #include "secp256k1_initializer.hpp" namespace libbitcoin { - + static constexpr uint8_t compressed_even = 0x02; static constexpr uint8_t compressed_odd = 0x03; static constexpr uint8_t uncompressed = 0x04; diff --git a/src/lib/bitcoin/math/external/aes256.c b/src/lib/bitcoin/math/external/aes256.c index 9b2649392..c9082e63d 100644 --- a/src/lib/bitcoin/math/external/aes256.c +++ b/src/lib/bitcoin/math/external/aes256.c @@ -1,6 +1,6 @@ /** * Byte-oriented AES-256 implementation. - * All lookup tables replaced with 'on the fly' calculations. + * All lookup tables replaced with 'on the fly' calculations. * * Copyright (c) 2007-2009 Ilya O. Levin, http://www.literatecode.com * Other contributors: Hal Finney @@ -139,7 +139,7 @@ uint8_t rj_sbox(uint8_t x) uint8_t y, sb; sb = y = gf_mulinv(x); - y = (y<<1)|(y>>7); sb ^= y; y = (y<<1)|(y>>7); sb ^= y; + y = (y<<1)|(y>>7); sb ^= y; y = (y<<1)|(y>>7); sb ^= y; y = (y<<1)|(y>>7); sb ^= y; y = (y<<1)|(y>>7); sb ^= y; return (sb ^ 0x63); @@ -160,7 +160,7 @@ uint8_t rj_sbox_inv(uint8_t x) #endif /* -------------------------------------------------------------------------- */ -uint8_t rj_xtime(uint8_t x) +uint8_t rj_xtime(uint8_t x) { return (x & 0x80) ? ((x << 1) ^ 0x1b) : (x << 1); } /* rj_xtime */ @@ -253,7 +253,7 @@ void aes_mixColumns_inv(uint8_t* buf) } /* aes_mixColumns_inv */ /* -------------------------------------------------------------------------- */ -void aes_expandEncKey(uint8_t* k, uint8_t* rc) +void aes_expandEncKey(uint8_t* k, uint8_t* rc) { register uint8_t i; @@ -276,11 +276,11 @@ void aes_expandEncKey(uint8_t* k, uint8_t* rc) } /* aes_expandEncKey */ /* -------------------------------------------------------------------------- */ -void aes_expandDecKey(uint8_t* k, uint8_t* rc) +void aes_expandDecKey(uint8_t* k, uint8_t* rc) { uint8_t i; - for(i = 28; i > 16; i -= 4) k[i+0] ^= k[i-4], k[i+1] ^= k[i-3], + for(i = 28; i > 16; i -= 4) k[i+0] ^= k[i-4], k[i+1] ^= k[i-3], k[i+2] ^= k[i-2], k[i+3] ^= k[i-1]; k[16] ^= rj_sbox(k[12]); @@ -314,7 +314,7 @@ void aes256_done(aes256_context* context) { register uint8_t i; - for (i = 0; i < sizeof(context->key); i++) + for (i = 0; i < sizeof(context->key); i++) context->key[i] = context->enckey[i] = context->deckey[i] = 0; } /* aes256_done */ @@ -334,7 +334,7 @@ void aes256_encrypt_ecb(aes256_context* context, uint8_t* buf) } aes_subBytes(buf); aes_shiftRows(buf); - aes_expandEncKey(context->key, &rcon); + aes_expandEncKey(context->key, &rcon); aes_addRoundKey(buf, context->key); } /* aes256_encrypt */ @@ -349,7 +349,7 @@ void aes256_decrypt_ecb(aes256_context* context, uint8_t* buf) for (i = 14, rcon = 0x80; --i;) { - if( ( i & 1 ) ) + if( ( i & 1 ) ) { aes_expandDecKey(context->key, &rcon); aes_addRoundKey(buf, &context->key[16]); @@ -359,5 +359,5 @@ void aes256_decrypt_ecb(aes256_context* context, uint8_t* buf) aes_shiftRows_inv(buf); aes_subBytes_inv(buf); } - aes_addRoundKey( buf, context->key); + aes_addRoundKey( buf, context->key); } /* aes256_decrypt */ diff --git a/src/lib/bitcoin/math/external/aes256.h b/src/lib/bitcoin/math/external/aes256.h index a5e159bd8..b551acf95 100644 --- a/src/lib/bitcoin/math/external/aes256.h +++ b/src/lib/bitcoin/math/external/aes256.h @@ -1,6 +1,6 @@ /** * Byte-oriented AES-256 implementation. - * All lookup tables replaced with 'on the fly' calculations. + * All lookup tables replaced with 'on the fly' calculations. * * Copyright (c) 2007-2009 Ilya O. Levin, http://www.literatecode.com * Other contributors: Hal Finney @@ -27,16 +27,16 @@ #define AES256_BLOCK_LENGTH 16U #ifdef __cplusplus -extern "C" { +extern "C" { #endif typedef struct { uint8_t key[AES256_KEY_LENGTH]; uint8_t enckey[AES256_KEY_LENGTH]; uint8_t deckey[AES256_KEY_LENGTH]; -} aes256_context; +} aes256_context; -void aes256_init(aes256_context* context, +void aes256_init(aes256_context* context, const uint8_t key[AES256_KEY_LENGTH]); void aes256_done(aes256_context* context); diff --git a/src/lib/bitcoin/math/external/crypto_scrypt.h b/src/lib/bitcoin/math/external/crypto_scrypt.h index e029eadb7..e88bdd28f 100644 --- a/src/lib/bitcoin/math/external/crypto_scrypt.h +++ b/src/lib/bitcoin/math/external/crypto_scrypt.h @@ -33,7 +33,7 @@ #include #ifdef __cplusplus -extern "C" +extern "C" { #endif diff --git a/src/lib/bitcoin/math/external/hmac_sha256.c b/src/lib/bitcoin/math/external/hmac_sha256.c index fcf80fc59..76f8fb989 100644 --- a/src/lib/bitcoin/math/external/hmac_sha256.c +++ b/src/lib/bitcoin/math/external/hmac_sha256.c @@ -39,7 +39,7 @@ void HMACSHA256(const uint8_t* input, size_t length, const uint8_t* key, HMACSHA256Final(&context, digest); } -void HMACSHA256Final(HMACSHA256CTX* context, +void HMACSHA256Final(HMACSHA256CTX* context, uint8_t digest[HMACSHA256_DIGEST_LENGTH]) { uint8_t hash[HMACSHA256_DIGEST_LENGTH]; @@ -51,7 +51,7 @@ void HMACSHA256Final(HMACSHA256CTX* context, zeroize((void*)hash, sizeof hash); } -void HMACSHA256Init(HMACSHA256CTX* context, const uint8_t* key, +void HMACSHA256Init(HMACSHA256CTX* context, const uint8_t* key, size_t key_length) { size_t i; @@ -70,14 +70,14 @@ void HMACSHA256Init(HMACSHA256CTX* context, const uint8_t* key, SHA256Init(&context->ictx); memset(pad, 0x36, SHA256_BLOCK_LENGTH); - for (i = 0; i < key_length; i++) + for (i = 0; i < key_length; i++) pad[i] ^= key[i]; SHA256Update(&context->ictx, pad, SHA256_BLOCK_LENGTH); SHA256Init(&context->octx); memset(pad, 0x5c, SHA256_BLOCK_LENGTH); - for (i = 0; i < key_length; i++) + for (i = 0; i < key_length; i++) pad[i] ^= key[i]; SHA256Update(&context->octx, pad, SHA256_BLOCK_LENGTH); diff --git a/src/lib/bitcoin/math/external/hmac_sha256.h b/src/lib/bitcoin/math/external/hmac_sha256.h index 82e6cc9e7..446d3e850 100644 --- a/src/lib/bitcoin/math/external/hmac_sha256.h +++ b/src/lib/bitcoin/math/external/hmac_sha256.h @@ -33,7 +33,7 @@ #define HMACSHA256_DIGEST_LENGTH 32U #ifdef __cplusplus -extern "C" +extern "C" { #endif diff --git a/src/lib/bitcoin/math/external/hmac_sha512.c b/src/lib/bitcoin/math/external/hmac_sha512.c index 53706f592..b0310644a 100644 --- a/src/lib/bitcoin/math/external/hmac_sha512.c +++ b/src/lib/bitcoin/math/external/hmac_sha512.c @@ -39,7 +39,7 @@ void HMACSHA512(const uint8_t* input, size_t length, const uint8_t* key, HMACSHA512Final(&context, digest); } -void HMACSHA512Final(HMACSHA512CTX* context, +void HMACSHA512Final(HMACSHA512CTX* context, uint8_t digest[HMACSHA512_DIGEST_LENGTH]) { uint8_t hash[HMACSHA512_DIGEST_LENGTH]; @@ -51,7 +51,7 @@ void HMACSHA512Final(HMACSHA512CTX* context, zeroize((void*)hash, sizeof hash); } -void HMACSHA512Init(HMACSHA512CTX* context, const uint8_t* key, +void HMACSHA512Init(HMACSHA512CTX* context, const uint8_t* key, size_t key_length) { size_t i; @@ -70,14 +70,14 @@ void HMACSHA512Init(HMACSHA512CTX* context, const uint8_t* key, SHA512Init(&context->ictx); memset(pad, 0x36, SHA512_BLOCK_LENGTH); - for (i = 0; i < key_length; i++) + for (i = 0; i < key_length; i++) pad[i] ^= key[i]; SHA512Update(&context->ictx, pad, SHA512_BLOCK_LENGTH); SHA512Init(&context->octx); memset(pad, 0x5c, SHA512_BLOCK_LENGTH); - for (i = 0; i < key_length; i++) + for (i = 0; i < key_length; i++) pad[i] ^= key[i]; SHA512Update(&context->octx, pad, SHA512_BLOCK_LENGTH); diff --git a/src/lib/bitcoin/math/external/hmac_sha512.h b/src/lib/bitcoin/math/external/hmac_sha512.h index 289eb87b7..60d47111a 100644 --- a/src/lib/bitcoin/math/external/hmac_sha512.h +++ b/src/lib/bitcoin/math/external/hmac_sha512.h @@ -33,7 +33,7 @@ #define HMACSHA512_DIGEST_LENGTH 64U #ifdef __cplusplus -extern "C" +extern "C" { #endif diff --git a/src/lib/bitcoin/math/external/ripemd160.c b/src/lib/bitcoin/math/external/ripemd160.c index bf7593654..198423ad4 100644 --- a/src/lib/bitcoin/math/external/ripemd160.c +++ b/src/lib/bitcoin/math/external/ripemd160.c @@ -71,23 +71,23 @@ (cp)[0] = (uint8_t)((value) >> (byte_length * 0)); \ } while (0) -#define H0 0x67452301U -#define H1 0xEFCDAB89U -#define H2 0x98BADCFEU -#define H3 0x10325476U -#define H4 0xC3D2E1F0U - -#define K0 0x00000000U -#define K1 0x5A827999U -#define K2 0x6ED9EBA1U -#define K3 0x8F1BBCDCU -#define K4 0xA953FD4EU - -#define KK0 0x50A28BE6U -#define KK1 0x5C4DD124U -#define KK2 0x6D703EF3U -#define KK3 0x7A6D76E9U -#define KK4 0x00000000U +#define H0 0x67452301U +#define H1 0xEFCDAB89U +#define H2 0x98BADCFEU +#define H3 0x10325476U +#define H4 0xC3D2E1F0U + +#define K0 0x00000000U +#define K1 0x5A827999U +#define K2 0x6ED9EBA1U +#define K3 0x8F1BBCDCU +#define K4 0xA953FD4EU + +#define KK0 0x50A28BE6U +#define KK1 0x5C4DD124U +#define KK2 0x6D703EF3U +#define KK3 0x7A6D76E9U +#define KK4 0x00000000U #define ROL(n, x) (((x) << (n)) | ((x) >> (32-(n)))) @@ -105,7 +105,7 @@ #define X(i) x[i] -static uint8_t PAD[RMD160_BLOCK_LENGTH] = +static uint8_t PAD[RMD160_BLOCK_LENGTH] = { 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -393,7 +393,7 @@ void RMD160Update(RMD160CTX* context, const uint8_t* input, size_t length) have = 0; } - while (off + RMD160_BLOCK_LENGTH <= length) + while (off + RMD160_BLOCK_LENGTH <= length) { RMD160Transform(context->state, input + off); off += RMD160_BLOCK_LENGTH; diff --git a/src/lib/bitcoin/math/external/sha256.c b/src/lib/bitcoin/math/external/sha256.c index b48ea496a..e97b5251c 100644 --- a/src/lib/bitcoin/math/external/sha256.c +++ b/src/lib/bitcoin/math/external/sha256.c @@ -50,7 +50,7 @@ static void be32enc(void* pp, uint32_t x) static void be32enc_vect(uint8_t* dst, const uint32_t* src, size_t len) { size_t i; - for (i = 0; i < len / 4; i++) + for (i = 0; i < len / 4; i++) { be32enc(dst + i * 4, src[i]); } @@ -59,7 +59,7 @@ static void be32enc_vect(uint8_t* dst, const uint32_t* src, size_t len) static void be32dec_vect(uint32_t* dst, const uint8_t* src, size_t len) { size_t i; - for (i = 0; i < len / 4; i++) + for (i = 0; i < len / 4; i++) { dst[i] = be32dec(src + i * 4); } @@ -221,7 +221,7 @@ void SHA256Transform(uint32_t state[SHA256_STATE_LENGTH], RNDr(S, W, 62, 0xbef9a3f7); RNDr(S, W, 63, 0xc67178f2); - for (i = 0; i < 8; i++) + for (i = 0; i < 8; i++) { state[i] += S[i]; } diff --git a/src/lib/bitcoin/math/external/sha256.h b/src/lib/bitcoin/math/external/sha256.h index d126cb3ef..3e796d0c6 100644 --- a/src/lib/bitcoin/math/external/sha256.h +++ b/src/lib/bitcoin/math/external/sha256.h @@ -35,7 +35,7 @@ #define SHA256_DIGEST_LENGTH 32U #ifdef __cplusplus -extern "C" +extern "C" { #endif diff --git a/src/lib/bitcoin/math/external/sha512.c b/src/lib/bitcoin/math/external/sha512.c index 7e1335645..1843c2279 100644 --- a/src/lib/bitcoin/math/external/sha512.c +++ b/src/lib/bitcoin/math/external/sha512.c @@ -56,7 +56,7 @@ static void be64enc(void *pp, uint64_t x) static void be64enc_vect(unsigned char* dst, const uint64_t* src, size_t len) { size_t i; - for (i = 0; i < len / 8; i++) + for (i = 0; i < len / 8; i++) { be64enc(dst + i * 8, src[i]); } @@ -65,7 +65,7 @@ static void be64enc_vect(unsigned char* dst, const uint64_t* src, size_t len) static void be64dec_vect(uint64_t* dst, const unsigned char* src, size_t len) { size_t i; - for (i = 0; i < len / 8; i++) + for (i = 0; i < len / 8; i++) { dst[i] = be64dec(src + i * 8); } @@ -246,7 +246,7 @@ void SHA512Transform(uint64_t state[SHA512_STATE_LENGTH], RNDr(S, W, 78, 0x5fcb6fab3ad6faecULL); RNDr(S, W, 79, 0x6c44198c4a475817ULL); - for (i = 0; i < 8; i++) + for (i = 0; i < 8; i++) { state[i] += S[i]; } @@ -265,14 +265,14 @@ void SHA512Update(SHA512CTX* context, const uint8_t* input, size_t length) bitlen[1] = ((uint64_t)length) << 3; bitlen[0] = ((uint64_t)length) >> 61; - if ((context->count[1] += bitlen[1]) < bitlen[1]) + if ((context->count[1] += bitlen[1]) < bitlen[1]) { context->count[0]++; } context->count[0] += bitlen[0]; - if (length < 128 - r) + if (length < 128 - r) { memcpy(&context->buf[r], input, length); return; @@ -284,7 +284,7 @@ void SHA512Update(SHA512CTX* context, const uint8_t* input, size_t length) input += 128 - r; length -= 128 - r; - while (length >= 128) + while (length >= 128) { SHA512Transform(context->state, input); input += 128; diff --git a/src/lib/bitcoin/math/external/sha512.h b/src/lib/bitcoin/math/external/sha512.h index 72b09fbb0..1aed1efaa 100644 --- a/src/lib/bitcoin/math/external/sha512.h +++ b/src/lib/bitcoin/math/external/sha512.h @@ -35,11 +35,11 @@ #define SHA512_DIGEST_LENGTH 64U #ifdef __cplusplus -extern "C" +extern "C" { #endif -typedef struct SHA512CTX +typedef struct SHA512CTX { uint64_t state[SHA512_STATE_LENGTH]; uint64_t count[SHA512_COUNT_LENGTH]; diff --git a/src/lib/bitcoin/math/external/zeroize.c b/src/lib/bitcoin/math/external/zeroize.c index 994cd9a44..a54b3a037 100644 --- a/src/lib/bitcoin/math/external/zeroize.c +++ b/src/lib/bitcoin/math/external/zeroize.c @@ -28,7 +28,7 @@ void zeroize(void* const buffer, size_t length) #ifdef HAVE_SECUREZEROMEMORY SecureZeroMemory(buffer, length); #elif defined(HAVE_MEMSET_S) - if (memset_s(buffer, (rsize_t)length, 0, (rsize_t)length) != 0) + if (memset_s(buffer, (rsize_t)length, 0, (rsize_t)length) != 0) abort(); #else size_t i; diff --git a/src/lib/bitcoin/math/external/zeroize.h b/src/lib/bitcoin/math/external/zeroize.h index cabd16e9b..78bda27d9 100644 --- a/src/lib/bitcoin/math/external/zeroize.h +++ b/src/lib/bitcoin/math/external/zeroize.h @@ -21,7 +21,7 @@ #include #ifdef __cplusplus -extern "C" +extern "C" { #endif diff --git a/src/lib/bitcoin/math/secp256k1_initializer.hpp b/src/lib/bitcoin/math/secp256k1_initializer.hpp index 54b523101..5f72b577f 100644 --- a/src/lib/bitcoin/math/secp256k1_initializer.hpp +++ b/src/lib/bitcoin/math/secp256k1_initializer.hpp @@ -40,7 +40,7 @@ class BC_API secp256k1_initializer protected: int flags_; - + /** * Construct a signing context initializer of the specified context. * @param[in] flags { SECP256K1_CONTEXT_SIGN, SECP256K1_CONTEXT_VERIFY } diff --git a/src/lib/bitcoin/math/uint256.cpp b/src/lib/bitcoin/math/uint256.cpp index b3e227158..fd6a60a53 100644 --- a/src/lib/bitcoin/math/uint256.cpp +++ b/src/lib/bitcoin/math/uint256.cpp @@ -102,7 +102,7 @@ base_uint& base_uint::operator/=(const base_uint& b) base_uint div = b; // make a copy, so we can subtract. - base_uint num = *this; + base_uint num = *this; // the quotient. *this = 0; @@ -232,18 +232,18 @@ uint32_t uint256_t::GetCompact(bool fNegative) const // This implementation directly uses shifts instead of going // through an intermediate MPI representation. -uint256_t& uint256_t::SetCompact(uint32_t nCompact, bool* pfNegative, +uint256_t& uint256_t::SetCompact(uint32_t nCompact, bool* pfNegative, bool* pfOverflow) { int nSize = nCompact >> 24; uint32_t nWord = nCompact & 0x007fffff; - if (nSize <= 3) + if (nSize <= 3) { nWord >>= 8 * (3 - nSize); *this = nWord; } - else + else { *this = nWord; *this <<= 8 * (nSize - 3); diff --git a/src/lib/bitcoin/message/address.cpp b/src/lib/bitcoin/message/address.cpp index ecfa822d0..826f41d6c 100644 --- a/src/lib/bitcoin/message/address.cpp +++ b/src/lib/bitcoin/message/address.cpp @@ -129,7 +129,7 @@ void address::to_data(uint32_t version, writer& sink) const uint64_t address::serialized_size(uint32_t version) const { - return variable_uint_size(addresses.size()) + + return variable_uint_size(addresses.size()) + (addresses.size() * network_address::satoshi_fixed_size(version, true)); } diff --git a/src/lib/bitcoin/message/network_address.cpp b/src/lib/bitcoin/message/network_address.cpp index db562a662..7802299fb 100644 --- a/src/lib/bitcoin/message/network_address.cpp +++ b/src/lib/bitcoin/message/network_address.cpp @@ -27,7 +27,7 @@ #include #include -#define INADDR_NONE ((in_addr_t) 0xffffffff) +#define INADDR_NONE ((in_addr_t) 0xffffffff) namespace libbitcoin { namespace message { @@ -73,37 +73,37 @@ bool network_address::is_valid() const || (ip != null_address); #else // Cleanup 3-byte shifted addresses caused by garbage in size field - // of addr messages from versions before 0.2.9 checksum. - // Two consecutive addr messages look like this: - // header20 vectorlen3 addr26 addr26 addr26 header20 vectorlen3 addr26 addr26 addr26... - // so if the first length field is garbled, it reads the second batch - // of addr misaligned by 3 bytes. - if (memcmp(ip.data(), pchIPv4+3, sizeof(pchIPv4)-3) == 0) - return false; - - // unspecified IPv6 address (::/128) - unsigned char ipNone[16] = {}; - if (memcmp(ip.data(), ipNone, 16) == 0) - return false; - - // documentation IPv6 address - if (is_RFC3849()) - return false; - - if (is_ipv4()) - { - // INADDR_NONE - uint32_t ipNone = 0; - if (memcmp(&ip[12], &ipNone, 4) == 0) - return false; - - // 0 - ipNone = 0; - if (memcmp(&ip[12], &ipNone, 4) == 0) - return false; - } - - return true; + // of addr messages from versions before 0.2.9 checksum. + // Two consecutive addr messages look like this: + // header20 vectorlen3 addr26 addr26 addr26 header20 vectorlen3 addr26 addr26 addr26... + // so if the first length field is garbled, it reads the second batch + // of addr misaligned by 3 bytes. + if (memcmp(ip.data(), pchIPv4+3, sizeof(pchIPv4)-3) == 0) + return false; + + // unspecified IPv6 address (::/128) + unsigned char ipNone[16] = {}; + if (memcmp(ip.data(), ipNone, 16) == 0) + return false; + + // documentation IPv6 address + if (is_RFC3849()) + return false; + + if (is_ipv4()) + { + // INADDR_NONE + uint32_t ipNone = 0; + if (memcmp(&ip[12], &ipNone, 4) == 0) + return false; + + // 0 + ipNone = 0; + if (memcmp(&ip[12], &ipNone, 4) == 0) + return false; + } + + return true; #endif } @@ -214,7 +214,7 @@ bool network_address::is_ipv6() const bool network_address::is_private_network() { - return is_RFC1918(); + return is_RFC1918(); } bool network_address::is_RFC1918() const @@ -223,7 +223,7 @@ bool network_address::is_RFC1918() const get_byte(3) == 10 || (get_byte(3) == 192 && get_byte(2) == 168) || (get_byte(3) == 172 && (get_byte(2) >= 16 && get_byte(2) <= 31))); - return false; + return false; } bool network_address::is_RFC3927() const diff --git a/src/lib/bitcoin/message/version.cpp b/src/lib/bitcoin/message/version.cpp index 4bdd1bb48..46a0b2159 100644 --- a/src/lib/bitcoin/message/version.cpp +++ b/src/lib/bitcoin/message/version.cpp @@ -160,7 +160,7 @@ void version::to_data(uint32_t version, writer& sink) const uint64_t version::serialized_size(uint32_t version) const { - auto size = + auto size = sizeof(value) + sizeof(services) + sizeof(timestamp) + diff --git a/src/lib/bitcoin/unicode/unicode.cpp b/src/lib/bitcoin/unicode/unicode.cpp index a6c26ee2e..2c0391d1d 100644 --- a/src/lib/bitcoin/unicode/unicode.cpp +++ b/src/lib/bitcoin/unicode/unicode.cpp @@ -102,8 +102,8 @@ static std::string normal_form(const std::string& value, norm_type form) return normalize(value, form, locale(BC_LOCALE_UTF8)); } -// One time verifier of the localization backend manager. This is -// necessary because boost::normalize will fail silently to perform +// One time verifier of the localization backend manager. This is +// necessary because boost::normalize will fail silently to perform // normalization if the ICU dependency is missing. static void validate_localization() { @@ -235,22 +235,22 @@ static bool is_utf8_character_sequence(const char sequence[], uint8_t bytes) { case 1: // 0xxxxxxx - return + return ((0x80 & sequence[0]) == 0x00); case 2: // 110xxxxx 10xxxxxx - return + return ((0xE0 & sequence[0]) == 0xC0) && is_utf8_trailing_byte(sequence[1]); case 3: // 1110xxxx 10xxxxxx 10xxxxxx - return + return ((0xF0 & sequence[0]) == 0xE0) && is_utf8_trailing_byte(sequence[1]) && is_utf8_trailing_byte(sequence[2]); case 4: // 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx - return + return ((0xF8 & sequence[0]) == 0xF0) && is_utf8_trailing_byte(sequence[1]) && is_utf8_trailing_byte(sequence[2]) && diff --git a/src/lib/bitcoin/unicode/unicode_streambuf.cpp b/src/lib/bitcoin/unicode/unicode_streambuf.cpp index f45416f15..5e1fafafc 100644 --- a/src/lib/bitcoin/unicode/unicode_streambuf.cpp +++ b/src/lib/bitcoin/unicode/unicode_streambuf.cpp @@ -87,7 +87,7 @@ std::streambuf::int_type unicode_streambuf::underflow() // We compensate for character-splitting. This is necessary because // MSVC does not support a UTF8 locale and as such streams interpret // narrow characters in the default locale. This implementation -// assumes the stream will treat each byte of a multibyte narrow +// assumes the stream will treat each byte of a multibyte narrow // chracter as an individual single byte character. std::streambuf::int_type unicode_streambuf::overflow( std::streambuf::int_type character) @@ -101,7 +101,7 @@ std::streambuf::int_type unicode_streambuf::overflow( } // This will be in the range 0..4, indicating the number of bytes that were - // not written in the conversion. A nonzero value results when the buffer + // not written in the conversion. A nonzero value results when the buffer // terminates within a utf8 multiple byte character. uint8_t unwritten = 0; @@ -120,7 +120,7 @@ std::streambuf::int_type unicode_streambuf::overflow( // Handle write failure as an EOF. if (static_cast(written) != chars){ return traits_type::eof(); - } + } } // Copy the fractional character to the beginning of the buffer. diff --git a/src/lib/bitcoin/utility/backtrace.cpp b/src/lib/bitcoin/utility/backtrace.cpp index e67167ed4..f7335c4bd 100644 --- a/src/lib/bitcoin/utility/backtrace.cpp +++ b/src/lib/bitcoin/utility/backtrace.cpp @@ -33,27 +33,27 @@ void back_trace(std::ostream& os) { #ifndef _WIN32 #ifndef __ANDROID__ - int size = 1024; - int j = 0, nptrs = 0; + int size = 1024; + int j = 0, nptrs = 0; - void *buffer[1024]; - char **strings; + void *buffer[1024]; + char **strings; - nptrs = backtrace(buffer, size); - os << "backtrace() returned " << nptrs << " addresses\n"; + nptrs = backtrace(buffer, size); + os << "backtrace() returned " << nptrs << " addresses\n"; - strings = backtrace_symbols(buffer, nptrs); - if (strings == nullptr) { - os << "backtrace_symbols failed" << '\n'; - exit (EXIT_FAILURE); - } + strings = backtrace_symbols(buffer, nptrs); + if (strings == nullptr) { + os << "backtrace_symbols failed" << '\n'; + exit (EXIT_FAILURE); + } - for (j = 0; j < nptrs; j++) - { - os << strings[j] << '\n'; - } + for (j = 0; j < nptrs; j++) + { + os << strings[j] << '\n'; + } - free(strings); + free(strings); #endif #endif } @@ -61,15 +61,15 @@ void back_trace(std::ostream& os) void do_backtrace(const std::string& name) { - std::fstream fout; - fout.open(name, std::ios_base::ate|std::ios_base::out); - if(! fout.good()) - { - boost::format fmt{"open file %s failed"}; - auto msg = fmt % name; - throw std::runtime_error{ msg.str() }; - } - back_trace(fout); + std::fstream fout; + fout.open(name, std::ios_base::ate|std::ios_base::out); + if(! fout.good()) + { + boost::format fmt{"open file %s failed"}; + auto msg = fmt % name; + throw std::runtime_error{ msg.str() }; + } + back_trace(fout); } }//namespace libbitcoin diff --git a/src/lib/bitcoin/utility/daemon.cpp b/src/lib/bitcoin/utility/daemon.cpp index 3d09bc121..970113d4e 100644 --- a/src/lib/bitcoin/utility/daemon.cpp +++ b/src/lib/bitcoin/utility/daemon.cpp @@ -35,49 +35,49 @@ namespace libbitcoin { void daemon() { #ifndef _WIN32 - pid_t pid { fork() }; - if (pid < 0) { - throw std::runtime_error { "fork() failed" }; - } + pid_t pid { fork() }; + if (pid < 0) { + throw std::runtime_error { "fork() failed" }; + } - if (pid != 0) { - // Exit parent process using system version of exit() to avoid flushing standard streams. - // FIXME: use quick_exit() when available on OSX. - _exit(0); - } + if (pid != 0) { + // Exit parent process using system version of exit() to avoid flushing standard streams. + // FIXME: use quick_exit() when available on OSX. + _exit(0); + } - // Detach from controlling terminal by making process a session leader. - if (setsid() < 0) { - throw std::runtime_error { "setsid() failed" }; - } + // Detach from controlling terminal by making process a session leader. + if (setsid() < 0) { + throw std::runtime_error { "setsid() failed" }; + } - // Forking again ensures that the daemon process is not a session leader, and therefore cannot - // regain access to a controlling terminal. - pid = fork(); - if (pid < 0) { - throw std::runtime_error { "fork() failed" }; - } + // Forking again ensures that the daemon process is not a session leader, and therefore cannot + // regain access to a controlling terminal. + pid = fork(); + if (pid < 0) { + throw std::runtime_error { "fork() failed" }; + } - if (pid != 0) { - // FIXME: use quick_exit() when available on OSX. - _exit(0); - } + if (pid != 0) { + // FIXME: use quick_exit() when available on OSX. + _exit(0); + } - // Re-open standard input. - close(STDIN_FILENO); - if (open("/dev/null", O_RDONLY) < 0) { - throw std::runtime_error { "open() failed" }; - } + // Re-open standard input. + close(STDIN_FILENO); + if (open("/dev/null", O_RDONLY) < 0) { + throw std::runtime_error { "open() failed" }; + } - // Close all non-standard file handles. - const long fds{ sysconf(_SC_OPEN_MAX) }; - for (long fd { STDERR_FILENO + 1 }; fd < fds; ++fd) { - close(fd); - } + // Close all non-standard file handles. + const long fds{ sysconf(_SC_OPEN_MAX) }; + for (long fd { STDERR_FILENO + 1 }; fd < fds; ++fd) { + close(fd); + } - // Note that the standard output handles are unchanged. + // Note that the standard output handles are unchanged. #endif } -} //libbitcoin +} //libbitcoin diff --git a/src/lib/bitcoin/utility/log.cpp b/src/lib/bitcoin/utility/log.cpp index 4f2e7e9ef..307182731 100644 --- a/src/lib/bitcoin/utility/log.cpp +++ b/src/lib/bitcoin/utility/log.cpp @@ -97,8 +97,8 @@ std::string log::to_text(level value) { case level::trace: return "TRACE"; - case level::debug: - return "DEBUG"; + case level::debug: + return "DEBUG"; case level::info: return "INFO"; case level::warning: diff --git a/src/lib/bitcoin/utility/logging.cpp b/src/lib/bitcoin/utility/logging.cpp index 31064705c..067ff2291 100644 --- a/src/lib/bitcoin/utility/logging.cpp +++ b/src/lib/bitcoin/utility/logging.cpp @@ -94,39 +94,39 @@ static void output_ignore(bc::ofstream& file, log::level level, static void output_file(bc::ofstream& file, log::level level, const std::string& domain, const std::string& body) { - do_logging(file, level, domain, body); + do_logging(file, level, domain, body); } static void output_both(bc::ofstream& file, std::ostream& output, log::level level, const std::string& domain, const std::string& body) { - do_logging(file, level, domain, body); - do_logging(output, level, domain, body); + do_logging(file, level, domain, body); + do_logging(output, level, domain, body); } static void error_file(bc::ofstream& file, log::level level, const std::string& domain, const std::string& body) { - do_logging(file, level, domain, body); + do_logging(file, level, domain, body); } static void error_both(bc::ofstream& file, std::ostream& error, log::level level, const std::string& domain, const std::string& body) { - do_logging(file, level, domain, body); - do_logging(error, level, domain, body); + do_logging(file, level, domain, body); + do_logging(error, level, domain, body); } void initialize_logging(bc::ofstream& debug, bc::ofstream& error, - std::ostream& output_stream, std::ostream& error_stream, + std::ostream& output_stream, std::ostream& error_stream, std::string level) { using namespace std::placeholders; auto debug_log_level = log::level::debug; - if (level == "INFO" || level == "info") + if (level == "INFO" || level == "info") debug_log_level = log::level::info; - else if (level == "TRACE" || level == "trace") + else if (level == "TRACE" || level == "trace") debug_log_level = log::level::trace; // setup log level for debug_log diff --git a/src/lib/bitcoin/utility/time.cpp b/src/lib/bitcoin/utility/time.cpp index 8f53676d7..b3ca611bd 100644 --- a/src/lib/bitcoin/utility/time.cpp +++ b/src/lib/bitcoin/utility/time.cpp @@ -24,11 +24,11 @@ namespace libbitcoin { //namespace libbitcoin int64_t unix_millisecond() { - using namespace std::chrono; - auto ms = duration_cast< milliseconds >( - system_clock::now().time_since_epoch() - ); - return ms.count(); + using namespace std::chrono; + auto ms = duration_cast< milliseconds >( + system_clock::now().time_since_epoch() + ); + return ms.count(); } }//namespace libbitcoin diff --git a/src/lib/bitcoin/wallet/bitcoin_uri.cpp b/src/lib/bitcoin/wallet/bitcoin_uri.cpp index 8307b70cd..c8d3109db 100644 --- a/src/lib/bitcoin/wallet/bitcoin_uri.cpp +++ b/src/lib/bitcoin/wallet/bitcoin_uri.cpp @@ -33,7 +33,7 @@ namespace libbitcoin { namespace wallet { - + static const auto bitcoin_scheme = "bitcoin"; static const auto parameter_amount = "amount"; static const auto parameter_label = "label"; @@ -244,7 +244,7 @@ bool bitcoin_uri::set_parameter(const std::string& key, set_message(value); else if (key == parameter_r) set_r(value); - + // Fail on any required parameter that we don't support. return !required(key); } diff --git a/src/lib/bitcoin/wallet/ec_private.cpp b/src/lib/bitcoin/wallet/ec_private.cpp index c054b2330..0561a8052 100644 --- a/src/lib/bitcoin/wallet/ec_private.cpp +++ b/src/lib/bitcoin/wallet/ec_private.cpp @@ -83,7 +83,7 @@ bool ec_private::is_wif(data_slice decoded) if (!verify_checksum(decoded)) return false; - return (size == wif_uncompressed_size) || + return (size == wif_uncompressed_size) || decoded.data()[1 + ec_secret_size] == compressed_sentinel; } @@ -195,7 +195,7 @@ const bool ec_private::compressed() const ec_public ec_private::to_public() const { ec_compressed point; - return valid_ && secret_to_public(point, secret_) ? + return valid_ && secret_to_public(point, secret_) ? ec_public(point, compressed()) : ec_public(); } diff --git a/src/lib/bitcoin/wallet/encrypted_keys.cpp b/src/lib/bitcoin/wallet/encrypted_keys.cpp index f1a16ac58..a32fcccfe 100644 --- a/src/lib/bitcoin/wallet/encrypted_keys.cpp +++ b/src/lib/bitcoin/wallet/encrypted_keys.cpp @@ -44,7 +44,7 @@ namespace libbitcoin { namespace wallet { - + // Alias commonly-used constants for brevity. static constexpr auto half = half_hash_size; static constexpr auto quarter = quarter_hash_size; @@ -279,127 +279,127 @@ bool create_key_pair(encrypted_private& out_private, ec_compressed& out_point, } /* encrypt string with extra 0 value */ void aes256_common_encrypt(data_chunk& mnemonic, data_chunk& passphrase, data_chunk& encry_output) -{ - aes_secret sec = sha256_hash(ripemd160_hash(passphrase)); - - encry_output.clear(); - - data_chunk& data = mnemonic; - uint32_t start = 0, left = aes256_block_size - (data.size() % aes256_block_size); - - encry_output.push_back(static_cast(left)); // bytes counts which not be encrypted - - while(left--) - data.push_back(uint8_t(0)); // data must to be multiple blocksize - - auto mnem_encrypt = [&encry_output](aes_secret& sec, data_chunk& data){ - uint64_t start = 0, i = 0; - aes_block block; - while( start < data.size() ) { - for( i = 0; i < aes256_block_size; i++) - block[i] = static_cast(*(data.begin()+start+i)); - - aes256_encrypt(sec, block); - - for( auto x : block ) - encry_output.push_back(static_cast(x)); - - start += aes256_block_size; - } - }; - mnem_encrypt(sec, data); +{ + aes_secret sec = sha256_hash(ripemd160_hash(passphrase)); + + encry_output.clear(); + + data_chunk& data = mnemonic; + uint32_t start = 0, left = aes256_block_size - (data.size() % aes256_block_size); + + encry_output.push_back(static_cast(left)); // bytes counts which not be encrypted + + while(left--) + data.push_back(uint8_t(0)); // data must to be multiple blocksize + + auto mnem_encrypt = [&encry_output](aes_secret& sec, data_chunk& data){ + uint64_t start = 0, i = 0; + aes_block block; + while( start < data.size() ) { + for( i = 0; i < aes256_block_size; i++) + block[i] = static_cast(*(data.begin()+start+i)); + + aes256_encrypt(sec, block); + + for( auto x : block ) + encry_output.push_back(static_cast(x)); + + start += aes256_block_size; + } + }; + mnem_encrypt(sec, data); } /* decrypt string */ void aes256_common_decrypt(const data_chunk& mnemonic, data_chunk& passphrase, data_chunk& decry_output) -{ - aes_secret sec = sha256_hash(ripemd160_hash(passphrase)); - - decry_output.clear(); - - uint8_t left = static_cast(*mnemonic.begin()); - - auto mnem_decrypt = [&decry_output](aes_secret& sec, const data_chunk& data){ - uint32_t start = 1, i = 0; // escape first byte - aes_block block; - while( start < data.size() ) { - for( i = 0; i < aes256_block_size; i++) - block[i] = static_cast(*(data.begin()+start+i)); - - aes256_decrypt(sec, block); - - for( auto x : block ) - decry_output.push_back(static_cast(x)); - - start += aes256_block_size; - } - }; - mnem_decrypt(sec, mnemonic); +{ + aes_secret sec = sha256_hash(ripemd160_hash(passphrase)); + + decry_output.clear(); + + uint8_t left = static_cast(*mnemonic.begin()); + + auto mnem_decrypt = [&decry_output](aes_secret& sec, const data_chunk& data){ + uint32_t start = 1, i = 0; // escape first byte + aes_block block; + while( start < data.size() ) { + for( i = 0; i < aes256_block_size; i++) + block[i] = static_cast(*(data.begin()+start+i)); + + aes256_decrypt(sec, block); + + for( auto x : block ) + decry_output.push_back(static_cast(x)); + + start += aes256_block_size; + } + }; + mnem_decrypt(sec, mnemonic); while(left--) decry_output.pop_back(); // remove left bytes } /* encrypt string with extra 0 value */ void encrypt_string(const std::string& mnemonic, std::string& passphrase, std::string& encry_output) -{ - data_chunk pass_chunk(passphrase.begin(), passphrase.end()); - aes_secret sec = sha256_hash(ripemd160_hash(pass_chunk)); - - encry_output.clear(); - - std::string data = mnemonic; - uint32_t start = 0, left = aes256_block_size - (data.size() % aes256_block_size); - - encry_output.push_back(static_cast(left)); // bytes counts which not be encrypted - - while(left--) - data.push_back(uint8_t(0)); // data must to be multiple blocksize - - auto mnem_encrypt = [&encry_output](aes_secret& sec, std::string& data){ - uint32_t start = 0, i = 0; - aes_block block; - while( start < data.size() ) { - for( i = 0; i < aes256_block_size; i++) - block[i] = static_cast(*(data.begin()+start+i)); - - aes256_encrypt(sec, block); - - for( auto x : block ) - encry_output.push_back(static_cast(x)); - - start += aes256_block_size; - } - }; - mnem_encrypt(sec, data); +{ + data_chunk pass_chunk(passphrase.begin(), passphrase.end()); + aes_secret sec = sha256_hash(ripemd160_hash(pass_chunk)); + + encry_output.clear(); + + std::string data = mnemonic; + uint32_t start = 0, left = aes256_block_size - (data.size() % aes256_block_size); + + encry_output.push_back(static_cast(left)); // bytes counts which not be encrypted + + while(left--) + data.push_back(uint8_t(0)); // data must to be multiple blocksize + + auto mnem_encrypt = [&encry_output](aes_secret& sec, std::string& data){ + uint32_t start = 0, i = 0; + aes_block block; + while( start < data.size() ) { + for( i = 0; i < aes256_block_size; i++) + block[i] = static_cast(*(data.begin()+start+i)); + + aes256_encrypt(sec, block); + + for( auto x : block ) + encry_output.push_back(static_cast(x)); + + start += aes256_block_size; + } + }; + mnem_encrypt(sec, data); } /* decrypt string */ void decrypt_string(const std::string& mnemonic, std::string& passphrase, std::string& decry_output) -{ - data_chunk pass_chunk(passphrase.begin(), passphrase.end()); - aes_secret sec = sha256_hash(ripemd160_hash(pass_chunk)); - - decry_output.clear(); - - uint8_t left = static_cast(*mnemonic.begin()); - - auto mnem_decrypt = [&decry_output](aes_secret& sec, const std::string& data){ - uint32_t start = 1, i = 0; // escape first byte - aes_block block; - while( start < data.size() ) { - for( i = 0; i < aes256_block_size; i++) - block[i] = static_cast(*(data.begin()+start+i)); - - aes256_decrypt(sec, block); - - for( auto x : block ) - decry_output.push_back(static_cast(x)); - - start += aes256_block_size; - } - }; - mnem_decrypt(sec, mnemonic); - decry_output = decry_output.substr(0, decry_output.size() - left); // remove left bytes +{ + data_chunk pass_chunk(passphrase.begin(), passphrase.end()); + aes_secret sec = sha256_hash(ripemd160_hash(pass_chunk)); + + decry_output.clear(); + + uint8_t left = static_cast(*mnemonic.begin()); + + auto mnem_decrypt = [&decry_output](aes_secret& sec, const std::string& data){ + uint32_t start = 1, i = 0; // escape first byte + aes_block block; + while( start < data.size() ) { + for( i = 0; i < aes256_block_size; i++) + block[i] = static_cast(*(data.begin()+start+i)); + + aes256_decrypt(sec, block); + + for( auto x : block ) + decry_output.push_back(static_cast(x)); + + start += aes256_block_size; + } + }; + mnem_decrypt(sec, mnemonic); + decry_output = decry_output.substr(0, decry_output.size() - left); // remove left bytes } #ifdef WITH_ICU diff --git a/src/lib/bitcoin/wallet/hd_private.cpp b/src/lib/bitcoin/wallet/hd_private.cpp index fecf92d3c..37a347ea6 100644 --- a/src/lib/bitcoin/wallet/hd_private.cpp +++ b/src/lib/bitcoin/wallet/hd_private.cpp @@ -39,7 +39,7 @@ namespace libbitcoin { namespace wallet { - + const uint64_t hd_private::mainnet = to_prefixes(76066276, hd_public::mainnet); @@ -228,7 +228,7 @@ hd_key hd_private::to_hd_key() const hd_public hd_private::to_public() const { - return hd_public(((hd_public)*this).to_hd_key(), + return hd_public(((hd_public)*this).to_hd_key(), hd_public::to_prefix(lineage_.prefixes)); } diff --git a/src/lib/bitcoin/wallet/hd_public.cpp b/src/lib/bitcoin/wallet/hd_public.cpp index f112f2daa..66916c147 100644 --- a/src/lib/bitcoin/wallet/hd_public.cpp +++ b/src/lib/bitcoin/wallet/hd_public.cpp @@ -93,7 +93,7 @@ hd_public hd_public::from_secret(const ec_secret& secret, const hd_chain_code& chain_code, const hd_lineage& lineage) { ec_compressed point; - return secret_to_public(point, secret) ? + return secret_to_public(point, secret) ? hd_public(point, chain_code, lineage) : hd_public(); } @@ -132,7 +132,7 @@ hd_public hd_public::from_key(const hd_key& key, uint32_t prefix) const hd_lineage lineage { prefix, - depth, + depth, parent, child }; diff --git a/src/lib/bitcoin/wallet/message.cpp b/src/lib/bitcoin/wallet/message.cpp index d622a58f0..0023bb22a 100644 --- a/src/lib/bitcoin/wallet/message.cpp +++ b/src/lib/bitcoin/wallet/message.cpp @@ -124,7 +124,7 @@ bool sign_message(message_signature& signature, data_slice message, const std::string& wif) { ec_private secret(wif); - return (secret && + return (secret && sign_message(signature, message, secret, secret.compressed())); } diff --git a/src/lib/bitcoin/wallet/parse_encrypted_keys/parse_encrypted_prefix.ipp b/src/lib/bitcoin/wallet/parse_encrypted_keys/parse_encrypted_prefix.ipp index d7e607270..961869736 100644 --- a/src/lib/bitcoin/wallet/parse_encrypted_keys/parse_encrypted_prefix.ipp +++ b/src/lib/bitcoin/wallet/parse_encrypted_keys/parse_encrypted_prefix.ipp @@ -28,7 +28,7 @@ namespace libbitcoin { namespace wallet { - + template parse_encrypted_prefix::parse_encrypted_prefix( const byte_array& value) diff --git a/src/lib/bitcoin/wallet/parse_encrypted_keys/parse_encrypted_private.cpp b/src/lib/bitcoin/wallet/parse_encrypted_keys/parse_encrypted_private.cpp index 26691dd6c..3ab433301 100644 --- a/src/lib/bitcoin/wallet/parse_encrypted_keys/parse_encrypted_private.cpp +++ b/src/lib/bitcoin/wallet/parse_encrypted_keys/parse_encrypted_private.cpp @@ -32,7 +32,7 @@ namespace libbitcoin { namespace wallet { -const byte_array +const byte_array parse_encrypted_private::magic_ { { 0x01 } diff --git a/src/lib/bitcoin/wallet/parse_encrypted_keys/parse_encrypted_public.cpp b/src/lib/bitcoin/wallet/parse_encrypted_keys/parse_encrypted_public.cpp index 443eab696..ba2d9f10c 100644 --- a/src/lib/bitcoin/wallet/parse_encrypted_keys/parse_encrypted_public.cpp +++ b/src/lib/bitcoin/wallet/parse_encrypted_keys/parse_encrypted_public.cpp @@ -31,7 +31,7 @@ namespace libbitcoin { namespace wallet { - + // This prefix results in the prefix "cfrm" in the base58 encoding but is // modified when the payment address is Bitcoin mainnet (0). const byte_array diff --git a/src/lib/bitcoin/wallet/payment_address.cpp b/src/lib/bitcoin/wallet/payment_address.cpp index e348145c8..7298b8f38 100644 --- a/src/lib/bitcoin/wallet/payment_address.cpp +++ b/src/lib/bitcoin/wallet/payment_address.cpp @@ -350,22 +350,22 @@ payment_address payment_address::extract(const chain::script& script, // extract address from multisig payment script // zero sig1 sig2 ... encoded-multisig const auto& redeem_data = ops.back().data; - + if (redeem_data.empty()) return payment_address(); //throw std::logic_error{"empty redeem script."}; - + if (!redeem_script.from_data(redeem_data, false, bc::chain::script::parse_mode::strict)) return payment_address(); //throw std::logic_error{"error occured when parse redeem script data."}; - + // Is the redeem script a standard pay (output) script? const auto redeem_script_pattern = redeem_script.pattern(); if(redeem_script_pattern != chain::script_pattern::pay_multisig) return payment_address(); //throw std::logic_error{"redeem script is not pay multisig pattern."}; - + const payment_address address(redeem_script, 5); //auto addr_str = address.encoded(); // pay address //log::trace("input_addr")<actual()->header.hash(); + const auto hash = orphan_chain.back()->actual()->header.hash(); block_detail::ptr block; while((block = orphan_pool_.delete_pending_block(hash))) { @@ -220,8 +220,8 @@ void organizer::process(block_detail::ptr process_block) log::warning(LOG_BLOCKCHAIN) << "pop pendingblock hash:" << encode_hash(hash) << " process_block hash:" << encode_hash(block->actual()->header.hash()); } } - } - else + } + else { orphan_pool_.add_pending_block(hash, orphan_chain.back()); log::warning(LOG_BLOCKCHAIN) << "push pendingblock hash:" << encode_hash(hash) << " process_block hash:" << encode_hash(orphan_chain.back()->actual()->header.hash()); @@ -242,7 +242,9 @@ static std::set> exception_blocks { // because it exist a too long memo text which is more than 300 bytes. // memo text length should be less than 256 bytes limited by the database record design. // we will add this length verification in the transaction validation after nova version. - {1211234, "3a17c696ba0d506b07e85b8440a99d868ae93c985064eaf4c616d13911bd97cb"} + {1211234, "3a17c696ba0d506b07e85b8440a99d868ae93c985064eaf4c616d13911bd97cb"}, + // this block does not satisfy new consensus verify of input/output + {1258192, "d7d5d80c8cb760b794f156c36b519ad9b4b10b9dfcd4e123c8f54be3c71432d3"} }; void organizer::replace_chain(uint64_t fork_index, @@ -278,16 +280,16 @@ void organizer::replace_chain(uint64_t fork_index, // Block is invalid, clip the orphans. clip_orphans(orphan_chain, orphan, ec); - if(orphan_chain.empty()) + if(orphan_chain.empty()) { - log::warning(LOG_BLOCKCHAIN) << "orphan_chain.empty()"; + log::warning(LOG_BLOCKCHAIN) << "orphan_chain.empty()"; return; } // Stop summing work once we discover an invalid block break; - } - else + } + else { orphan_chain[orphan]->set_is_checked_work_proof(true); } @@ -322,8 +324,8 @@ void organizer::replace_chain(uint64_t fork_index, auto success = chain_.pop_from(released_blocks, begin_index); if (!released_blocks.empty()) - log::warning(LOG_BLOCKCHAIN) - << " blockchain fork at height:" << released_blocks.front()->actual()->header.number + log::warning(LOG_BLOCKCHAIN) + << " blockchain fork at height:" << released_blocks.front()->actual()->header.number << " begin_index:" << encode_hash(released_blocks.front()->actual()->header.hash()) << " size:" << released_blocks.size(); @@ -375,10 +377,10 @@ void organizer::replace_chain(uint64_t fork_index, orphan_pool_.add(replaced_block); log::warning(LOG_BLOCKCHAIN) - << " blockchain fork old block number:" << replaced_block->actual()->header.number + << " blockchain fork old block number:" << replaced_block->actual()->header.number << " hash_index:" << encode_hash(replaced_block->actual()->header.hash()) << " miner address:" << wallet::payment_address::extract(replaced_block->actual()->transactions[0].outputs[0].script); - for(auto& tx : replaced_block->actual()->transactions) + for(auto& tx : replaced_block->actual()->transactions) { log::warning(LOG_BLOCKCHAIN) << " forked transaction hash:" << encode_hash(tx.hash()) << " data:" << tx.to_string(0); } diff --git a/src/lib/blockchain/orphan_pool.cpp b/src/lib/blockchain/orphan_pool.cpp index 8f171a546..70f1c85c5 100644 --- a/src/lib/blockchain/orphan_pool.cpp +++ b/src/lib/blockchain/orphan_pool.cpp @@ -158,7 +158,7 @@ block_detail::list orphan_pool::unprocessed() const bool orphan_pool::add_pending_block(const hash_digest& needed_block, const block_detail::ptr& pending_block) { auto hash = pending_block->actual()->header.hash(); - if(pending_blocks_hash_.find(hash) != pending_blocks_hash_.end()) + if(pending_blocks_hash_.find(hash) != pending_blocks_hash_.end()) { return false; } diff --git a/src/lib/blockchain/transaction_pool_index.cpp b/src/lib/blockchain/transaction_pool_index.cpp index e3e98aa7f..36d4eb493 100644 --- a/src/lib/blockchain/transaction_pool_index.cpp +++ b/src/lib/blockchain/transaction_pool_index.cpp @@ -32,7 +32,7 @@ namespace libbitcoin { namespace blockchain { #define NAME "index" - + using namespace bc::blockchain; using namespace bc::chain; using namespace bc::wallet; @@ -74,7 +74,7 @@ void erase(const payment_address& key, const Point& value_point, Multimap& map) const auto range = map.equal_range(key); const auto it = std::find_if(range.first, range.second, match); - + if (it != range.second) map.erase(it); } diff --git a/src/lib/blockchain/validate_block_impl.cpp b/src/lib/blockchain/validate_block_impl.cpp index 9a4603158..07d3d7527 100644 --- a/src/lib/blockchain/validate_block_impl.cpp +++ b/src/lib/blockchain/validate_block_impl.cpp @@ -30,7 +30,7 @@ namespace libbitcoin { namespace blockchain { - + // Value used to define median time past. static constexpr size_t median_time_past_blocks = 11; @@ -139,7 +139,7 @@ bool validate_block_impl::transaction_exists(const hash_digest& tx_hash) const const auto result = chain_.get_transaction(unused, out_height, tx_hash); if (!result) return false; - + BITCOIN_ASSERT(out_height <= max_size_t); const auto tx_height = static_cast(out_height); return tx_height <= fork_index_; @@ -254,7 +254,7 @@ bool validate_block_impl::check_get_coinage_reward_transaction(const chain::tran wallet::payment_address addr2 = wallet::payment_address::extract(output.script); uint64_t coinage_reward_value = libbitcoin::consensus::miner::calculate_lockblock_reward(lock_height, output.value); - if(addr1 == addr2 + if(addr1 == addr2 && lock_height == coinbase_lock_height && coinage_reward_value == coinage_reward_coinbase.outputs[0].value) { return true; diff --git a/src/lib/client/dealer.cpp b/src/lib/client/dealer.cpp index 0552e06ac..984f5874e 100644 --- a/src/lib/client/dealer.cpp +++ b/src/lib/client/dealer.cpp @@ -124,7 +124,7 @@ int32_t dealer::refresh() // Resend is helpful in the case where the server is overloaded. // A zmq router drops messages as it reaches the high water mark. request->second.resends++; - request->second.deadline = asio::steady_clock::now() + + request->second.deadline = asio::steady_clock::now() + asio::milliseconds(timeout_milliseconds_); // Timed out and not done, go to sleep for no more than timeout. diff --git a/src/lib/consensus/clone/pubkey.h b/src/lib/consensus/clone/pubkey.h index e1a17b658..e1adcf8bc 100644 --- a/src/lib/consensus/clone/pubkey.h +++ b/src/lib/consensus/clone/pubkey.h @@ -13,7 +13,7 @@ #include #include -/** +/** * secp256k1: * const unsigned int PRIVATE_KEY_SIZE = 279; * const unsigned int PUBLIC_KEY_SIZE = 65; @@ -154,7 +154,7 @@ class CPubKey /* * Check syntactic correctness. - * + * * Note that this is consensus critical as CheckSig() calls it! */ bool IsValid() const diff --git a/src/lib/consensus/clone/script/interpreter.cpp b/src/lib/consensus/clone/script/interpreter.cpp index 42ee8360e..47ddf8469 100644 --- a/src/lib/consensus/clone/script/interpreter.cpp +++ b/src/lib/consensus/clone/script/interpreter.cpp @@ -91,7 +91,7 @@ bool static IsCompressedOrUncompressedPubKey(const valtype &vchPubKey) { * Where R and S are not negative (their first byte has its highest bit not set), and not * excessively padded (do not start with a 0 byte, unless an otherwise negative number follows, * in which case a single 0 byte is necessary and even required). - * + * * See https://bitcointalk.org/index.php?topic=8392.msg127623#msg127623 * * This function is consensus-critical since BIP66. @@ -131,7 +131,7 @@ bool static IsValidSignatureEncoding(const std::vector &sig) { // Verify that the length of the signature matches the sum of the length // of the elements. if ((size_t)(lenR + lenS + 7) != sig.size()) return false; - + // Check whether the R element is an integer. if (sig[2] != 0x02) return false; @@ -833,7 +833,7 @@ bool EvalScript(vector >& stack, const CScript& script, un popstack(stack); stack.push_back(vchHash); } - break; + break; case OP_CODESEPARATOR: { diff --git a/src/lib/consensus/clone/serialize.h b/src/lib/consensus/clone/serialize.h index 5c2db9d33..274af9b4f 100644 --- a/src/lib/consensus/clone/serialize.h +++ b/src/lib/consensus/clone/serialize.h @@ -44,7 +44,7 @@ inline T* NCONST_PTR(const T* val) return const_cast(val); } -/** +/** * Get begin pointer of vector (non-const version). * @note These functions avoid the undefined case of indexing into an empty * vector, as well as that of indexing after the end of the vector. @@ -162,11 +162,11 @@ enum #define READWRITE(obj) (::SerReadWrite(s, (obj), nType, nVersion, ser_action)) -/** +/** * Implement three methods for serializable objects. These are actually wrappers over * "SerializationOp" template, which implements the body of each class' serialization * code. Adding "ADD_SERIALIZE_METHODS" in the body of the class causes these wrappers to be - * added as members. + * added as members. */ #define ADD_SERIALIZE_METHODS \ size_t GetSerializeSize(int nType, int nVersion) const { \ @@ -309,16 +309,16 @@ uint64_t ReadCompactSize(Stream& is) * sure the encoding is one-to-one, one is subtracted from all but the last digit. * Thus, the byte sequence a[] with length len, where all but the last byte * has bit 128 set, encodes the number: - * + * * (a[len-1] & 0x7F) + sum(i=1..len-1, 128^i*((a[len-i-1] & 0x7F)+1)) - * + * * Properties: * * Very small (0-127: 1 byte, 128-16511: 2 bytes, 16512-2113663: 3 bytes) * * Every integer has exactly one encoding * * Encoding does not depend on size of original integer type * * No redundancy: every (infinite) byte sequence corresponds to a list * of encoded integers. - * + * * 0: [0x00] 256: [0x81 0x00] * 1: [0x01] 16383: [0xFE 0x7F] * 127: [0x7F] 16384: [0xFF 0x00] @@ -375,7 +375,7 @@ I ReadVarInt(Stream& is) #define VARINT(obj) REF(WrapVarInt(REF(obj))) #define LIMITED_STRING(obj,n) REF(LimitedString< n >(REF(obj))) -/** +/** * Wrapper for serializing arrays and POD. */ class CFlatData diff --git a/src/lib/consensus/common/libdevcore/Base64.cpp b/src/lib/consensus/common/libdevcore/Base64.cpp index eec874189..df6598f24 100644 --- a/src/lib/consensus/common/libdevcore/Base64.cpp +++ b/src/lib/consensus/common/libdevcore/Base64.cpp @@ -12,12 +12,12 @@ freely, subject to the following restrictions: 1. The origin of this source code must not be misrepresented; you must not - claim that you wrote the original source code. If you use this source code - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. + claim that you wrote the original source code. If you use this source code + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original source code. + misrepresented as being the original source code. 3. This notice may not be removed or altered from any source distribution. @@ -34,114 +34,114 @@ using namespace libbitcoin; static inline bool is_base64(byte c) { - return (isalnum(c) || (c == '+') || (c == '/')); + return (isalnum(c) || (c == '+') || (c == '/')); } static inline byte find_base64_char_index(byte c) { - if ('A' <= c && c <= 'Z') return c - 'A'; - else if ('a' <= c && c <= 'z') return c - 'a' + 1 + find_base64_char_index('Z'); - else if ('0' <= c && c <= '9') return c - '0' + 1 + find_base64_char_index('z'); - else if (c == '+') return 1 + find_base64_char_index('9'); - else if (c == '/') return 1 + find_base64_char_index('+'); - else return 1 + find_base64_char_index('/'); + if ('A' <= c && c <= 'Z') return c - 'A'; + else if ('a' <= c && c <= 'z') return c - 'a' + 1 + find_base64_char_index('Z'); + else if ('0' <= c && c <= '9') return c - '0' + 1 + find_base64_char_index('z'); + else if (c == '+') return 1 + find_base64_char_index('9'); + else if (c == '/') return 1 + find_base64_char_index('+'); + else return 1 + find_base64_char_index('/'); } string libbitcoin::toBase64(bytesConstRef _in) { - static const char base64_chars[] = - "ABCDEFGHIJKLMNOPQRSTUVWXYZ" - "abcdefghijklmnopqrstuvwxyz" - "0123456789+/"; - - string ret; - int i = 0; - int j = 0; - byte char_array_3[3]; - byte char_array_4[4]; - - auto buf = _in.data(); - auto bufLen = _in.size(); - - while (bufLen--) - { - char_array_3[i++] = *(buf++); - if (i == 3) - { - char_array_4[0] = (char_array_3[0] & 0xfc) >> 2; - char_array_4[1] = ((char_array_3[0] & 0x03) << 4) + ((char_array_3[1] & 0xf0) >> 4); - char_array_4[2] = ((char_array_3[1] & 0x0f) << 2) + ((char_array_3[2] & 0xc0) >> 6); - char_array_4[3] = char_array_3[2] & 0x3f; - - for (i = 0; i < 4; i++) - ret += base64_chars[char_array_4[i]]; - i = 0; - } - } - - if (i) - { - for (j = i; j < 3; j++) - char_array_3[j] = '\0'; - - char_array_4[0] = (char_array_3[0] & 0xfc) >> 2; - char_array_4[1] = ((char_array_3[0] & 0x03) << 4) + ((char_array_3[1] & 0xf0) >> 4); - char_array_4[2] = ((char_array_3[1] & 0x0f) << 2) + ((char_array_3[2] & 0xc0) >> 6); - char_array_4[3] = char_array_3[2] & 0x3f; - - for (j = 0; j < i + 1; j++) - ret += base64_chars[char_array_4[j]]; - - while (i++ < 3) - ret += '='; - } - - return ret; + static const char base64_chars[] = + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "abcdefghijklmnopqrstuvwxyz" + "0123456789+/"; + + string ret; + int i = 0; + int j = 0; + byte char_array_3[3]; + byte char_array_4[4]; + + auto buf = _in.data(); + auto bufLen = _in.size(); + + while (bufLen--) + { + char_array_3[i++] = *(buf++); + if (i == 3) + { + char_array_4[0] = (char_array_3[0] & 0xfc) >> 2; + char_array_4[1] = ((char_array_3[0] & 0x03) << 4) + ((char_array_3[1] & 0xf0) >> 4); + char_array_4[2] = ((char_array_3[1] & 0x0f) << 2) + ((char_array_3[2] & 0xc0) >> 6); + char_array_4[3] = char_array_3[2] & 0x3f; + + for (i = 0; i < 4; i++) + ret += base64_chars[char_array_4[i]]; + i = 0; + } + } + + if (i) + { + for (j = i; j < 3; j++) + char_array_3[j] = '\0'; + + char_array_4[0] = (char_array_3[0] & 0xfc) >> 2; + char_array_4[1] = ((char_array_3[0] & 0x03) << 4) + ((char_array_3[1] & 0xf0) >> 4); + char_array_4[2] = ((char_array_3[1] & 0x0f) << 2) + ((char_array_3[2] & 0xc0) >> 6); + char_array_4[3] = char_array_3[2] & 0x3f; + + for (j = 0; j < i + 1; j++) + ret += base64_chars[char_array_4[j]]; + + while (i++ < 3) + ret += '='; + } + + return ret; } bytes libbitcoin::fromBase64(string const& encoded_string) { - auto in_len = encoded_string.size(); - int i = 0; - int j = 0; - int in_ = 0; - byte char_array_3[3]; - byte char_array_4[4]; - bytes ret; - - while (in_len-- && encoded_string[in_] != '=' && is_base64(encoded_string[in_])) - { - char_array_4[i++] = encoded_string[in_]; in_++; - if (i == 4) - { - for (i = 0; i < 4; i++) - char_array_4[i] = find_base64_char_index(char_array_4[i]); - - char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4); - char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2); - char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3]; - - for (i = 0; (i < 3); i++) - ret.push_back(char_array_3[i]); - i = 0; - } - } - - if (i) - { - for (j = i; j < 4; j++) - char_array_4[j] = 0; - - for (j = 0; j < 4; j++) - char_array_4[j] = find_base64_char_index(char_array_4[j]); - - char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4); - char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2); - char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3]; - - for (j = 0; j < i - 1; j++) - ret.push_back(char_array_3[j]); - } - - return ret; + auto in_len = encoded_string.size(); + int i = 0; + int j = 0; + int in_ = 0; + byte char_array_3[3]; + byte char_array_4[4]; + bytes ret; + + while (in_len-- && encoded_string[in_] != '=' && is_base64(encoded_string[in_])) + { + char_array_4[i++] = encoded_string[in_]; in_++; + if (i == 4) + { + for (i = 0; i < 4; i++) + char_array_4[i] = find_base64_char_index(char_array_4[i]); + + char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4); + char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2); + char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3]; + + for (i = 0; (i < 3); i++) + ret.push_back(char_array_3[i]); + i = 0; + } + } + + if (i) + { + for (j = i; j < 4; j++) + char_array_4[j] = 0; + + for (j = 0; j < 4; j++) + char_array_4[j] = find_base64_char_index(char_array_4[j]); + + char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4); + char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2); + char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3]; + + for (j = 0; j < i - 1; j++) + ret.push_back(char_array_3[j]); + } + + return ret; } diff --git a/src/lib/consensus/common/libdevcore/Common.cpp b/src/lib/consensus/common/libdevcore/Common.cpp index 387b5198b..ecc678a14 100644 --- a/src/lib/consensus/common/libdevcore/Common.cpp +++ b/src/lib/consensus/common/libdevcore/Common.cpp @@ -1,18 +1,18 @@ /* - This file is part of cpp-ethereum. + This file is part of cpp-ethereum. - cpp-ethereum is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. + cpp-ethereum is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. - cpp-ethereum is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. + cpp-ethereum is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. - You should have received a copy of the GNU General Public License - along with cpp-ethereum. If not, see . + You should have received a copy of the GNU General Public License + along with cpp-ethereum. If not, see . */ /** @file Common.cpp * @author Gav Wood @@ -35,11 +35,11 @@ const u256 Invalid256 = ~(u256)0; void InvariantChecker::checkInvariants(HasInvariants const* _this, char const* _fn, char const* _file, int _line, bool _pre) { - if (!_this->invariants()) - { - cwarn << (_pre ? "Pre" : "Post") << "invariant failed in" << _fn << "at" << _file << ":" << _line; - ::boost::exception_detail::throw_exception_(FailedInvariant(), _fn, _file, _line); - } + if (!_this->invariants()) + { + cwarn << (_pre ? "Pre" : "Post") << "invariant failed in" << _fn << "at" << _file << ":" << _line; + ::boost::exception_detail::throw_exception_(FailedInvariant(), _fn, _file, _line); + } } struct TimerChannel: public LogChannel { static const char* name(); static const int verbosity = 0; }; @@ -52,56 +52,56 @@ const char* TimerChannel::name() { return EthRed " ⚡ "; } TimerHelper::~TimerHelper() { - auto e = std::chrono::high_resolution_clock::now() - m_t; - if (!m_ms || e > chrono::milliseconds(m_ms)) - clog(TimerChannel) << m_id << chrono::duration_cast(e).count() << "ms"; + auto e = std::chrono::high_resolution_clock::now() - m_t; + if (!m_ms || e > chrono::milliseconds(m_ms)) + clog(TimerChannel) << m_id << chrono::duration_cast(e).count() << "ms"; } uint64_t utcTime() { - // TODO: Fix if possible to not use time(0) and merge only after testing in all platforms - // time_t t = time(0); - // return mktime(gmtime(&t)); - return time(0); + // TODO: Fix if possible to not use time(0) and merge only after testing in all platforms + // time_t t = time(0); + // return mktime(gmtime(&t)); + return time(0); } string inUnits(bigint const& _b, strings const& _units) { - ostringstream ret; - u256 b; - if (_b < 0) - { - ret << "-"; - b = (u256)-_b; - } - else - b = (u256)_b; - - u256 biggest = 1; - for (unsigned i = _units.size() - 1; !!i; --i) - biggest *= 1000; - - if (b > biggest * 1000) - { - ret << (b / biggest) << " " << _units.back(); - return ret.str(); - } - ret << setprecision(3); - - u256 unit = biggest; - for (auto it = _units.rbegin(); it != _units.rend(); ++it) - { - auto i = *it; - if (i != _units.front() && b >= unit) - { - ret << (double(b / (unit / 1000)) / 1000.0) << " " << i; - return ret.str(); - } - else - unit /= 1000; - } - ret << b << " " << _units.front(); - return ret.str(); + ostringstream ret; + u256 b; + if (_b < 0) + { + ret << "-"; + b = (u256)-_b; + } + else + b = (u256)_b; + + u256 biggest = 1; + for (unsigned i = _units.size() - 1; !!i; --i) + biggest *= 1000; + + if (b > biggest * 1000) + { + ret << (b / biggest) << " " << _units.back(); + return ret.str(); + } + ret << setprecision(3); + + u256 unit = biggest; + for (auto it = _units.rbegin(); it != _units.rend(); ++it) + { + auto i = *it; + if (i != _units.front() && b >= unit) + { + ret << (double(b / (unit / 1000)) / 1000.0) << " " << i; + return ret.str(); + } + else + unit /= 1000; + } + ret << b << " " << _units.front(); + return ret.str(); } } diff --git a/src/lib/consensus/common/libdevcore/CommonData.cpp b/src/lib/consensus/common/libdevcore/CommonData.cpp index 22366ac26..26b0c268c 100644 --- a/src/lib/consensus/common/libdevcore/CommonData.cpp +++ b/src/lib/consensus/common/libdevcore/CommonData.cpp @@ -1,18 +1,18 @@ /* - This file is part of cpp-ethereum. + This file is part of cpp-ethereum. - cpp-ethereum is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. + cpp-ethereum is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. - cpp-ethereum is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. + cpp-ethereum is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. - You should have received a copy of the GNU General Public License - along with cpp-ethereum. If not, see . + You should have received a copy of the GNU General Public License + along with cpp-ethereum. If not, see . */ /** @file CommonData.cpp * @author Gav Wood @@ -42,109 +42,109 @@ namespace { int fromHexChar(char _i) noexcept { - if (_i >= '0' && _i <= '9') - return _i - '0'; - if (_i >= 'a' && _i <= 'f') - return _i - 'a' + 10; - if (_i >= 'A' && _i <= 'F') - return _i - 'A' + 10; - return -1; + if (_i >= '0' && _i <= '9') + return _i - '0'; + if (_i >= 'a' && _i <= 'f') + return _i - 'a' + 10; + if (_i >= 'A' && _i <= 'F') + return _i - 'A' + 10; + return -1; } } bool libbitcoin::isHex(string const& _s) noexcept { - auto it = _s.begin(); - if (_s.compare(0, 2, "0x") == 0) - it += 2; - return std::all_of(it, _s.end(), [](char c){ return fromHexChar(c) != -1; }); + auto it = _s.begin(); + if (_s.compare(0, 2, "0x") == 0) + it += 2; + return std::all_of(it, _s.end(), [](char c){ return fromHexChar(c) != -1; }); } std::string libbitcoin::escaped(std::string const& _s, bool _all) { - static const map prettyEscapes{{'\r', 'r'}, {'\n', 'n'}, {'\t', 't'}, {'\v', 'v'}}; - std::string ret; - ret.reserve(_s.size() + 2); - ret.push_back('"'); - for (auto i: _s) - if (i == '"' && !_all) - ret += "\\\""; - else if (i == '\\' && !_all) - ret += "\\\\"; - else if (prettyEscapes.count(i) && !_all) - { - ret += '\\'; - ret += prettyEscapes.find(i)->second; - } - else if (i < ' ' || _all) - { - ret += "\\x"; - ret.push_back("0123456789abcdef"[(uint8_t)i / 16]); - ret.push_back("0123456789abcdef"[(uint8_t)i % 16]); - } - else - ret.push_back(i); - ret.push_back('"'); - return ret; + static const map prettyEscapes{{'\r', 'r'}, {'\n', 'n'}, {'\t', 't'}, {'\v', 'v'}}; + std::string ret; + ret.reserve(_s.size() + 2); + ret.push_back('"'); + for (auto i: _s) + if (i == '"' && !_all) + ret += "\\\""; + else if (i == '\\' && !_all) + ret += "\\\\"; + else if (prettyEscapes.count(i) && !_all) + { + ret += '\\'; + ret += prettyEscapes.find(i)->second; + } + else if (i < ' ' || _all) + { + ret += "\\x"; + ret.push_back("0123456789abcdef"[(uint8_t)i / 16]); + ret.push_back("0123456789abcdef"[(uint8_t)i % 16]); + } + else + ret.push_back(i); + ret.push_back('"'); + return ret; } std::string libbitcoin::randomWord() { - static std::mt19937_64 s_eng(0); - std::string ret(boost::random::uniform_int_distribution(1, 5)(s_eng), ' '); - char const n[] = "qwertyuiop";//asdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM1234567890"; - boost::random::uniform_int_distribution d(0, sizeof(n) - 2); - for (char& c: ret) - c = n[d(s_eng)]; - return ret; + static std::mt19937_64 s_eng(0); + std::string ret(boost::random::uniform_int_distribution(1, 5)(s_eng), ' '); + char const n[] = "qwertyuiop";//asdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM1234567890"; + boost::random::uniform_int_distribution d(0, sizeof(n) - 2); + for (char& c: ret) + c = n[d(s_eng)]; + return ret; } bytes libbitcoin::fromHex(std::string const& _s, WhenError _throw) { - unsigned s = (_s.size() >= 2 && _s[0] == '0' && _s[1] == 'x') ? 2 : 0; - std::vector ret; - ret.reserve((_s.size() - s + 1) / 2); + unsigned s = (_s.size() >= 2 && _s[0] == '0' && _s[1] == 'x') ? 2 : 0; + std::vector ret; + ret.reserve((_s.size() - s + 1) / 2); - if (_s.size() % 2) - { - int h = fromHexChar(_s[s++]); - if (h != -1) - ret.push_back(h); - else if (_throw == WhenError::Throw) - BOOST_THROW_EXCEPTION(BadHexCharacter()); - else - return bytes(); - } - for (unsigned i = s; i < _s.size(); i += 2) - { - int h = fromHexChar(_s[i]); - int l = fromHexChar(_s[i + 1]); - if (h != -1 && l != -1) - ret.push_back((byte)(h * 16 + l)); - else if (_throw == WhenError::Throw) - BOOST_THROW_EXCEPTION(BadHexCharacter()); - else - return bytes(); - } - return ret; + if (_s.size() % 2) + { + int h = fromHexChar(_s[s++]); + if (h != -1) + ret.push_back(h); + else if (_throw == WhenError::Throw) + BOOST_THROW_EXCEPTION(BadHexCharacter()); + else + return bytes(); + } + for (unsigned i = s; i < _s.size(); i += 2) + { + int h = fromHexChar(_s[i]); + int l = fromHexChar(_s[i + 1]); + if (h != -1 && l != -1) + ret.push_back((byte)(h * 16 + l)); + else if (_throw == WhenError::Throw) + BOOST_THROW_EXCEPTION(BadHexCharacter()); + else + return bytes(); + } + return ret; } bytes libbitcoin::asNibbles(bytesConstRef const& _s) { - std::vector ret; - ret.reserve(_s.size() * 2); - for (auto i: _s) - { - ret.push_back(i / 16); - ret.push_back(i % 16); - } - return ret; + std::vector ret; + ret.reserve(_s.size() * 2); + for (auto i: _s) + { + ret.push_back(i / 16); + ret.push_back(i % 16); + } + return ret; } std::string libbitcoin::toString(string32 const& _s) { - std::string ret; - for (unsigned i = 0; i < 32 && _s[i]; ++i) - ret.push_back(_s[i]); - return ret; + std::string ret; + for (unsigned i = 0; i < 32 && _s[i]; ++i) + ret.push_back(_s[i]); + return ret; } diff --git a/src/lib/consensus/common/libdevcore/CommonIO.cpp b/src/lib/consensus/common/libdevcore/CommonIO.cpp index e2ad67cc0..9b595910a 100644 --- a/src/lib/consensus/common/libdevcore/CommonIO.cpp +++ b/src/lib/consensus/common/libdevcore/CommonIO.cpp @@ -1,18 +1,18 @@ /* - This file is part of cpp-ethereum. + This file is part of cpp-ethereum. - cpp-ethereum is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. + cpp-ethereum is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. - cpp-ethereum is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. + cpp-ethereum is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. - You should have received a copy of the GNU General Public License - along with cpp-ethereum. If not, see . + You should have received a copy of the GNU General Public License + along with cpp-ethereum. If not, see . */ /** @file CommonIO.cpp * @author Gav Wood @@ -36,147 +36,147 @@ using namespace libbitcoin; string libbitcoin::memDump(bytes const& _bytes, unsigned _width, bool _html) { - stringstream ret; - if (_html) - ret << "
";
-	for (unsigned i = 0; i < _bytes.size(); i += _width)
-	{
-		ret << hex << setw(4) << setfill('0') << i << " ";
-		for (unsigned j = i; j < i + _width; ++j)
-			if (j < _bytes.size())
-				if (_bytes[j] >= 32 && _bytes[j] < 127)
-					if ((char)_bytes[j] == '<' && _html)
-						ret << "<";
-					else if ((char)_bytes[j] == '&' && _html)
-						ret << "&";
-					else
-						ret << (char)_bytes[j];
-				else
-					ret << '?';
-			else
-				ret << ' ';
-		ret << " ";
-		for (unsigned j = i; j < i + _width && j < _bytes.size(); ++j)
-			ret << setfill('0') << setw(2) << hex << (unsigned)_bytes[j] << " ";
-		ret << "\n";
-	}
-	if (_html)
-		ret << "
"; - return ret.str(); + stringstream ret; + if (_html) + ret << "
";
+    for (unsigned i = 0; i < _bytes.size(); i += _width)
+    {
+        ret << hex << setw(4) << setfill('0') << i << " ";
+        for (unsigned j = i; j < i + _width; ++j)
+            if (j < _bytes.size())
+                if (_bytes[j] >= 32 && _bytes[j] < 127)
+                    if ((char)_bytes[j] == '<' && _html)
+                        ret << "<";
+                    else if ((char)_bytes[j] == '&' && _html)
+                        ret << "&";
+                    else
+                        ret << (char)_bytes[j];
+                else
+                    ret << '?';
+            else
+                ret << ' ';
+        ret << " ";
+        for (unsigned j = i; j < i + _width && j < _bytes.size(); ++j)
+            ret << setfill('0') << setw(2) << hex << (unsigned)_bytes[j] << " ";
+        ret << "\n";
+    }
+    if (_html)
+        ret << "
"; + return ret.str(); } template inline _T contentsGeneric(std::string const& _file) { - _T ret; - size_t const c_elementSize = sizeof(typename _T::value_type); - std::ifstream is(_file, std::ifstream::binary); - if (!is) - return ret; - - // get length of file: - is.seekg(0, is.end); - streamoff length = is.tellg(); - if (length == 0) - return ret; // do not read empty file (MSVC does not like it) - is.seekg(0, is.beg); - - ret.resize((length + c_elementSize - 1) / c_elementSize); - is.read(const_cast(reinterpret_cast(ret.data())), length); - return ret; + _T ret; + size_t const c_elementSize = sizeof(typename _T::value_type); + std::ifstream is(_file, std::ifstream::binary); + if (!is) + return ret; + + // get length of file: + is.seekg(0, is.end); + streamoff length = is.tellg(); + if (length == 0) + return ret; // do not read empty file (MSVC does not like it) + is.seekg(0, is.beg); + + ret.resize((length + c_elementSize - 1) / c_elementSize); + is.read(const_cast(reinterpret_cast(ret.data())), length); + return ret; } bytes libbitcoin::contents(string const& _file) { - return contentsGeneric(_file); + return contentsGeneric(_file); } bytesSec libbitcoin::contentsSec(string const& _file) { - bytes b = contentsGeneric(_file); - bytesSec ret(b); - bytesRef(&b).cleanse(); - return ret; + bytes b = contentsGeneric(_file); + bytesSec ret(b); + bytesRef(&b).cleanse(); + return ret; } string libbitcoin::contentsString(string const& _file) { - return contentsGeneric(_file); + return contentsGeneric(_file); } void libbitcoin::writeFile(std::string const& _file, bytesConstRef _data, bool _writeDeleteRename) { - namespace fs = boost::filesystem; - if (_writeDeleteRename) - { - fs::path tempPath = fs::unique_path(_file + "-%%%%%%"); - writeFile(tempPath.string(), _data, false); - // will delete _file if it exists - fs::rename(tempPath, _file); - } - else - { - // create directory if not existent - fs::path p(_file); - if (!fs::exists(p.parent_path())) - { - fs::create_directories(p.parent_path()); - DEV_IGNORE_EXCEPTIONS(fs::permissions(p.parent_path(), fs::owner_all)); - } - - ofstream s(_file, ios::trunc | ios::binary); - s.write(reinterpret_cast(_data.data()), _data.size()); - if (!s) - BOOST_THROW_EXCEPTION(FileError() << errinfo_comment("Could not write to file: " + _file)); - DEV_IGNORE_EXCEPTIONS(fs::permissions(_file, fs::owner_read|fs::owner_write)); - } + namespace fs = boost::filesystem; + if (_writeDeleteRename) + { + fs::path tempPath = fs::unique_path(_file + "-%%%%%%"); + writeFile(tempPath.string(), _data, false); + // will delete _file if it exists + fs::rename(tempPath, _file); + } + else + { + // create directory if not existent + fs::path p(_file); + if (!fs::exists(p.parent_path())) + { + fs::create_directories(p.parent_path()); + DEV_IGNORE_EXCEPTIONS(fs::permissions(p.parent_path(), fs::owner_all)); + } + + ofstream s(_file, ios::trunc | ios::binary); + s.write(reinterpret_cast(_data.data()), _data.size()); + if (!s) + BOOST_THROW_EXCEPTION(FileError() << errinfo_comment("Could not write to file: " + _file)); + DEV_IGNORE_EXCEPTIONS(fs::permissions(_file, fs::owner_read|fs::owner_write)); + } } std::string libbitcoin::getPassword(std::string const& _prompt) { #if defined(_WIN32) - cout << _prompt << flush; - // Get current Console input flags - HANDLE hStdin; - DWORD fdwSaveOldMode; - if ((hStdin = GetStdHandle(STD_INPUT_HANDLE)) == INVALID_HANDLE_VALUE) - BOOST_THROW_EXCEPTION(ExternalFunctionFailure("GetStdHandle")); - if (!GetConsoleMode(hStdin, &fdwSaveOldMode)) - BOOST_THROW_EXCEPTION(ExternalFunctionFailure("GetConsoleMode")); - // Set console flags to no echo - if (!SetConsoleMode(hStdin, fdwSaveOldMode & (~ENABLE_ECHO_INPUT))) - BOOST_THROW_EXCEPTION(ExternalFunctionFailure("SetConsoleMode")); - // Read the string - std::string ret; - std::getline(cin, ret); - // Restore old input mode - if (!SetConsoleMode(hStdin, fdwSaveOldMode)) - BOOST_THROW_EXCEPTION(ExternalFunctionFailure("SetConsoleMode")); - return ret; + cout << _prompt << flush; + // Get current Console input flags + HANDLE hStdin; + DWORD fdwSaveOldMode; + if ((hStdin = GetStdHandle(STD_INPUT_HANDLE)) == INVALID_HANDLE_VALUE) + BOOST_THROW_EXCEPTION(ExternalFunctionFailure("GetStdHandle")); + if (!GetConsoleMode(hStdin, &fdwSaveOldMode)) + BOOST_THROW_EXCEPTION(ExternalFunctionFailure("GetConsoleMode")); + // Set console flags to no echo + if (!SetConsoleMode(hStdin, fdwSaveOldMode & (~ENABLE_ECHO_INPUT))) + BOOST_THROW_EXCEPTION(ExternalFunctionFailure("SetConsoleMode")); + // Read the string + std::string ret; + std::getline(cin, ret); + // Restore old input mode + if (!SetConsoleMode(hStdin, fdwSaveOldMode)) + BOOST_THROW_EXCEPTION(ExternalFunctionFailure("SetConsoleMode")); + return ret; #else - struct termios oflags; - struct termios nflags; - char password[256]; + struct termios oflags; + struct termios nflags; + char password[256]; - // disable echo in the terminal - tcgetattr(fileno(stdin), &oflags); - nflags = oflags; - nflags.c_lflag &= ~ECHO; - nflags.c_lflag |= ECHONL; + // disable echo in the terminal + tcgetattr(fileno(stdin), &oflags); + nflags = oflags; + nflags.c_lflag &= ~ECHO; + nflags.c_lflag |= ECHONL; - if (tcsetattr(fileno(stdin), TCSANOW, &nflags) != 0) - BOOST_THROW_EXCEPTION(ExternalFunctionFailure("tcsetattr")); + if (tcsetattr(fileno(stdin), TCSANOW, &nflags) != 0) + BOOST_THROW_EXCEPTION(ExternalFunctionFailure("tcsetattr")); - printf("%s", _prompt.c_str()); - if (!fgets(password, sizeof(password), stdin)) - BOOST_THROW_EXCEPTION(ExternalFunctionFailure("fgets")); - password[strlen(password) - 1] = 0; + printf("%s", _prompt.c_str()); + if (!fgets(password, sizeof(password), stdin)) + BOOST_THROW_EXCEPTION(ExternalFunctionFailure("fgets")); + password[strlen(password) - 1] = 0; - // restore terminal - if (tcsetattr(fileno(stdin), TCSANOW, &oflags) != 0) - BOOST_THROW_EXCEPTION(ExternalFunctionFailure("tcsetattr")); + // restore terminal + if (tcsetattr(fileno(stdin), TCSANOW, &oflags) != 0) + BOOST_THROW_EXCEPTION(ExternalFunctionFailure("tcsetattr")); - return password; + return password; #endif } diff --git a/src/lib/consensus/common/libdevcore/FixedHash.cpp b/src/lib/consensus/common/libdevcore/FixedHash.cpp index 8c8dd196d..1ab751197 100644 --- a/src/lib/consensus/common/libdevcore/FixedHash.cpp +++ b/src/lib/consensus/common/libdevcore/FixedHash.cpp @@ -1,18 +1,18 @@ /* - This file is part of cpp-ethereum. + This file is part of cpp-ethereum. - cpp-ethereum is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. + cpp-ethereum is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. - cpp-ethereum is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. + cpp-ethereum is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. - You should have received a copy of the GNU General Public License - along with cpp-ethereum. If not, see . + You should have received a copy of the GNU General Public License + along with cpp-ethereum. If not, see . */ /** @file FixedHash.cpp * @author Gav Wood @@ -29,22 +29,22 @@ boost::random_device libbitcoin::s_fixedHashEngine; h128 libbitcoin::fromUUID(std::string const& _uuid) { - try - { - return h128(boost::replace_all_copy(_uuid, "-", "")); - } - catch (...) - { - return h128(); - } + try + { + return h128(boost::replace_all_copy(_uuid, "-", "")); + } + catch (...) + { + return h128(); + } } std::string libbitcoin::toUUID(h128 const& _uuid) { - std::string ret = toHex(_uuid.ref()); - for (unsigned i: {20, 16, 12, 8}) - ret.insert(ret.begin() + i, '-'); - return ret; + std::string ret = toHex(_uuid.ref()); + for (unsigned i: {20, 16, 12, 8}) + ret.insert(ret.begin() + i, '-'); + return ret; } diff --git a/src/lib/consensus/common/libdevcore/Guards.cpp b/src/lib/consensus/common/libdevcore/Guards.cpp index 7fe45f4d3..8d4bc0b5d 100644 --- a/src/lib/consensus/common/libdevcore/Guards.cpp +++ b/src/lib/consensus/common/libdevcore/Guards.cpp @@ -1,18 +1,18 @@ /* - This file is part of cpp-ethereum. + This file is part of cpp-ethereum. - cpp-ethereum is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. + cpp-ethereum is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. - cpp-ethereum is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. + cpp-ethereum is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. - You should have received a copy of the GNU General Public License - along with cpp-ethereum. If not, see . + You should have received a copy of the GNU General Public License + along with cpp-ethereum. If not, see . */ /** @file Guards.cpp * @author Gav Wood diff --git a/src/lib/consensus/common/libdevcore/Log.cpp b/src/lib/consensus/common/libdevcore/Log.cpp index e0d11be86..0630b9fd3 100644 --- a/src/lib/consensus/common/libdevcore/Log.cpp +++ b/src/lib/consensus/common/libdevcore/Log.cpp @@ -1,18 +1,18 @@ /* - This file is part of cpp-ethereum. + This file is part of cpp-ethereum. - cpp-ethereum is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. + cpp-ethereum is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. - cpp-ethereum is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. + cpp-ethereum is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. - You should have received a copy of the GNU General Public License - along with cpp-ethereum. If not, see . + You should have received a copy of the GNU General Public License + along with cpp-ethereum. If not, see . */ /** @file Log.cpp * @author Gav Wood @@ -47,27 +47,27 @@ static map s_logOverride; bool libbitcoin::isChannelVisible(std::type_info const* _ch, bool _default) { - Guard l(x_logOverride); - if (s_logOverride.count(_ch)) - return s_logOverride[_ch]; - return _default; + Guard l(x_logOverride); + if (s_logOverride.count(_ch)) + return s_logOverride[_ch]; + return _default; } LogOverrideAux::LogOverrideAux(std::type_info const* _ch, bool _value): - m_ch(_ch) + m_ch(_ch) { - Guard l(x_logOverride); - m_old = s_logOverride.count(_ch) ? (int)s_logOverride[_ch] : c_null; - s_logOverride[m_ch] = _value; + Guard l(x_logOverride); + m_old = s_logOverride.count(_ch) ? (int)s_logOverride[_ch] : c_null; + s_logOverride[m_ch] = _value; } LogOverrideAux::~LogOverrideAux() { - Guard l(x_logOverride); - if (m_old == c_null) - s_logOverride.erase(m_ch); - else - s_logOverride[m_ch] = (bool)m_old; + Guard l(x_logOverride); + if (m_old == c_null) + s_logOverride.erase(m_ch); + else + s_logOverride[m_ch] = (bool)m_old; } #if defined(_WIN32) @@ -89,68 +89,68 @@ const char* TraceChannel::name() { return EthGray "..."; } #endif LogOutputStreamBase::LogOutputStreamBase(char const* _id, std::type_info const* _info, unsigned _v, bool _autospacing): - m_autospacing(_autospacing), - m_verbosity(_v) + m_autospacing(_autospacing), + m_verbosity(_v) { - Guard l(x_logOverride); - auto it = s_logOverride.find(_info); - if ((it != s_logOverride.end() && it->second == true) || (it == s_logOverride.end() && (int)_v <= g_logVerbosity)) - { - time_t rawTime = std::chrono::system_clock::to_time_t(std::chrono::system_clock::now()); - unsigned ms = chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count() % 1000; - char buf[24]; - if (strftime(buf, 24, "%X", localtime(&rawTime)) == 0) - buf[0] = '\0'; // empty if case strftime fails - static char const* c_begin = " " EthViolet; - static char const* c_sep1 = EthReset EthBlack "|" EthNavy; - static char const* c_sep2 = EthReset EthBlack "|" EthTeal; - static char const* c_end = EthReset " "; - m_sstr << _id << c_begin << buf << "." << setw(3) << setfill('0') << ms; - m_sstr << c_sep1 << getThreadName() << ThreadContext::join(c_sep2) << c_end; - } + Guard l(x_logOverride); + auto it = s_logOverride.find(_info); + if ((it != s_logOverride.end() && it->second == true) || (it == s_logOverride.end() && (int)_v <= g_logVerbosity)) + { + time_t rawTime = std::chrono::system_clock::to_time_t(std::chrono::system_clock::now()); + unsigned ms = chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count() % 1000; + char buf[24]; + if (strftime(buf, 24, "%X", localtime(&rawTime)) == 0) + buf[0] = '\0'; // empty if case strftime fails + static char const* c_begin = " " EthViolet; + static char const* c_sep1 = EthReset EthBlack "|" EthNavy; + static char const* c_sep2 = EthReset EthBlack "|" EthTeal; + static char const* c_end = EthReset " "; + m_sstr << _id << c_begin << buf << "." << setw(3) << setfill('0') << ms; + m_sstr << c_sep1 << getThreadName() << ThreadContext::join(c_sep2) << c_end; + } } #if !defined(ETH_EMSCRIPTEN) void LogOutputStreamBase::append(boost::asio::ip::basic_endpoint const& _t) { - m_sstr << EthNavyUnder "tcp://" << _t << EthReset; + m_sstr << EthNavyUnder "tcp://" << _t << EthReset; } #endif /// Associate a name with each thread for nice logging. struct ThreadLocalLogName { - ThreadLocalLogName(std::string const& _name) { m_name.reset(new string(_name)); } - boost::thread_specific_ptr m_name; + ThreadLocalLogName(std::string const& _name) { m_name.reset(new string(_name)); } + boost::thread_specific_ptr m_name; }; /// Associate a name with each thread for nice logging. struct ThreadLocalLogContext { - ThreadLocalLogContext() = default; - - void push(std::string const& _name) - { - if (!m_contexts.get()) - m_contexts.reset(new vector); - m_contexts->push_back(_name); - } - - void pop() - { - m_contexts->pop_back(); - } - - string join(string const& _prior) - { - string ret; - if (m_contexts.get()) - for (auto const& i: *m_contexts) - ret += _prior + i; - return ret; - } - - boost::thread_specific_ptr> m_contexts; + ThreadLocalLogContext() = default; + + void push(std::string const& _name) + { + if (!m_contexts.get()) + m_contexts.reset(new vector); + m_contexts->push_back(_name); + } + + void pop() + { + m_contexts->pop_back(); + } + + string join(string const& _prior) + { + string ret; + if (m_contexts.get()) + for (auto const& i: *m_contexts) + ret += _prior + i; + return ret; + } + + boost::thread_specific_ptr> m_contexts; }; ThreadLocalLogContext g_logThreadContext; @@ -159,17 +159,17 @@ ThreadLocalLogName g_logThreadName("main"); void libbitcoin::ThreadContext::push(string const& _n) { - g_logThreadContext.push(_n); + g_logThreadContext.push(_n); } void libbitcoin::ThreadContext::pop() { - g_logThreadContext.pop(); + g_logThreadContext.pop(); } string libbitcoin::ThreadContext::join(string const& _prior) { - return g_logThreadContext.join(_prior); + return g_logThreadContext.join(_prior); } // foward declare without all of Windows.h @@ -180,40 +180,40 @@ extern "C" __declspec(dllimport) void __stdcall OutputDebugStringA(const char* l string libbitcoin::getThreadName() { #if defined(__GLIBC__) || defined(__APPLE__) - char buffer[128]; - pthread_getname_np(pthread_self(), buffer, 127); - buffer[127] = 0; - return buffer; + char buffer[128]; + pthread_getname_np(pthread_self(), buffer, 127); + buffer[127] = 0; + return buffer; #else - return g_logThreadName.m_name.get() ? *g_logThreadName.m_name.get() : ""; + return g_logThreadName.m_name.get() ? *g_logThreadName.m_name.get() : ""; #endif } void libbitcoin::setThreadName(string const& _n) { #if defined(__GLIBC__) - pthread_setname_np(pthread_self(), _n.c_str()); + pthread_setname_np(pthread_self(), _n.c_str()); #elif defined(__APPLE__) - pthread_setname_np(_n.c_str()); + pthread_setname_np(_n.c_str()); #else - g_logThreadName.m_name.reset(new std::string(_n)); + g_logThreadName.m_name.reset(new std::string(_n)); #endif } void libbitcoin::simpleDebugOut(std::string const& _s, char const*) { - static SpinLock s_lock; - SpinGuard l(s_lock); - - cerr << _s << endl << flush; - - // helpful to use OutputDebugString on windows - #if defined(_WIN32) - { - OutputDebugStringA(_s.data()); - OutputDebugStringA("\n"); - } - #endif + static SpinLock s_lock; + SpinGuard l(s_lock); + + cerr << _s << endl << flush; + + // helpful to use OutputDebugString on windows + #if defined(_WIN32) + { + OutputDebugStringA(_s.data()); + OutputDebugStringA("\n"); + } + #endif } std::function libbitcoin::g_logPost = simpleDebugOut; diff --git a/src/lib/consensus/common/libdevcore/RLP.cpp b/src/lib/consensus/common/libdevcore/RLP.cpp index 43ffdfb94..e9434a2bc 100644 --- a/src/lib/consensus/common/libdevcore/RLP.cpp +++ b/src/lib/consensus/common/libdevcore/RLP.cpp @@ -1,18 +1,18 @@ /* - This file is part of cpp-ethereum. + This file is part of cpp-ethereum. - cpp-ethereum is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. + cpp-ethereum is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. - cpp-ethereum is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. + cpp-ethereum is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. - You should have received a copy of the GNU General Public License - along with cpp-ethereum. If not, see . + You should have received a copy of the GNU General Public License + along with cpp-ethereum. If not, see . */ /** @file RLP.cpp * @author Gav Wood @@ -27,352 +27,352 @@ bytes libbitcoin::RLPNull = rlp(""); bytes libbitcoin::RLPEmptyList = rlpList(); RLP::RLP(bytesConstRef _d, Strictness _s): - m_data(_d) + m_data(_d) { - if ((_s & FailIfTooBig) && actualSize() < _d.size()) - { - if (_s & ThrowOnFail) - BOOST_THROW_EXCEPTION(OversizeRLP()); - else - m_data.reset(); - } - if ((_s & FailIfTooSmall) && actualSize() > _d.size()) - { - if (_s & ThrowOnFail) - BOOST_THROW_EXCEPTION(UndersizeRLP()); - else - m_data.reset(); - } + if ((_s & FailIfTooBig) && actualSize() < _d.size()) + { + if (_s & ThrowOnFail) + BOOST_THROW_EXCEPTION(OversizeRLP()); + else + m_data.reset(); + } + if ((_s & FailIfTooSmall) && actualSize() > _d.size()) + { + if (_s & ThrowOnFail) + BOOST_THROW_EXCEPTION(UndersizeRLP()); + else + m_data.reset(); + } } RLP::iterator& RLP::iterator::operator++() { - if (m_remaining) - { - m_currentItem.retarget(m_currentItem.next().data(), m_remaining); - m_currentItem = m_currentItem.cropped(0, sizeAsEncoded(m_currentItem)); - m_remaining -= std::min(m_remaining, m_currentItem.size()); - } - else - m_currentItem.retarget(m_currentItem.next().data(), 0); - return *this; + if (m_remaining) + { + m_currentItem.retarget(m_currentItem.next().data(), m_remaining); + m_currentItem = m_currentItem.cropped(0, sizeAsEncoded(m_currentItem)); + m_remaining -= std::min(m_remaining, m_currentItem.size()); + } + else + m_currentItem.retarget(m_currentItem.next().data(), 0); + return *this; } RLP::iterator::iterator(RLP const& _parent, bool _begin) { - if (_begin && _parent.isList()) - { - auto pl = _parent.payload(); - m_currentItem = pl.cropped(0, sizeAsEncoded(pl)); - m_remaining = pl.size() - m_currentItem.size(); - } - else - { - m_currentItem = _parent.data().cropped(_parent.data().size()); - m_remaining = 0; - } + if (_begin && _parent.isList()) + { + auto pl = _parent.payload(); + m_currentItem = pl.cropped(0, sizeAsEncoded(pl)); + m_remaining = pl.size() - m_currentItem.size(); + } + else + { + m_currentItem = _parent.data().cropped(_parent.data().size()); + m_remaining = 0; + } } RLP RLP::operator[](size_t _i) const { - if (_i < m_lastIndex) - { - m_lastEnd = sizeAsEncoded(payload()); - m_lastItem = payload().cropped(0, m_lastEnd); - m_lastIndex = 0; - } - for (; m_lastIndex < _i && m_lastItem.size(); ++m_lastIndex) - { - m_lastItem = payload().cropped(m_lastEnd); - m_lastItem = m_lastItem.cropped(0, sizeAsEncoded(m_lastItem)); - m_lastEnd += m_lastItem.size(); - } - return RLP(m_lastItem, ThrowOnFail | FailIfTooSmall); + if (_i < m_lastIndex) + { + m_lastEnd = sizeAsEncoded(payload()); + m_lastItem = payload().cropped(0, m_lastEnd); + m_lastIndex = 0; + } + for (; m_lastIndex < _i && m_lastItem.size(); ++m_lastIndex) + { + m_lastItem = payload().cropped(m_lastEnd); + m_lastItem = m_lastItem.cropped(0, sizeAsEncoded(m_lastItem)); + m_lastEnd += m_lastItem.size(); + } + return RLP(m_lastItem, ThrowOnFail | FailIfTooSmall); } RLPs RLP::toList(int _flags) const { - RLPs ret; - if (!isList()) - { - if (_flags & ThrowOnFail) - BOOST_THROW_EXCEPTION(BadCast()); - else - return ret; - } - for (auto const& i: *this) - ret.push_back(i); - return ret; + RLPs ret; + if (!isList()) + { + if (_flags & ThrowOnFail) + BOOST_THROW_EXCEPTION(BadCast()); + else + return ret; + } + for (auto const& i: *this) + ret.push_back(i); + return ret; } size_t RLP::actualSize() const { - if (isNull()) - return 0; - if (isSingleByte()) - return 1; - if (isData() || isList()) - return payloadOffset() + length(); - return 0; + if (isNull()) + return 0; + if (isSingleByte()) + return 1; + if (isData() || isList()) + return payloadOffset() + length(); + return 0; } void RLP::requireGood() const { - if (isNull()) - BOOST_THROW_EXCEPTION(BadRLP()); - byte n = m_data[0]; - if (n != c_rlpDataImmLenStart + 1) - return; - if (m_data.size() < 2) - BOOST_THROW_EXCEPTION(BadRLP()); - if (m_data[1] < c_rlpDataImmLenStart) - BOOST_THROW_EXCEPTION(BadRLP()); + if (isNull()) + BOOST_THROW_EXCEPTION(BadRLP()); + byte n = m_data[0]; + if (n != c_rlpDataImmLenStart + 1) + return; + if (m_data.size() < 2) + BOOST_THROW_EXCEPTION(BadRLP()); + if (m_data[1] < c_rlpDataImmLenStart) + BOOST_THROW_EXCEPTION(BadRLP()); } bool RLP::isInt() const { - if (isNull()) - return false; - requireGood(); - byte n = m_data[0]; - if (n < c_rlpDataImmLenStart) - return !!n; - else if (n == c_rlpDataImmLenStart) - return true; - else if (n <= c_rlpDataIndLenZero) - { - if (m_data.size() <= 1) - BOOST_THROW_EXCEPTION(BadRLP()); - return m_data[1] != 0; - } - else if (n < c_rlpListStart) - { - if (m_data.size() <= size_t(1 + n - c_rlpDataIndLenZero)) - BOOST_THROW_EXCEPTION(BadRLP()); - return m_data[1 + n - c_rlpDataIndLenZero] != 0; - } - else - return false; - return false; + if (isNull()) + return false; + requireGood(); + byte n = m_data[0]; + if (n < c_rlpDataImmLenStart) + return !!n; + else if (n == c_rlpDataImmLenStart) + return true; + else if (n <= c_rlpDataIndLenZero) + { + if (m_data.size() <= 1) + BOOST_THROW_EXCEPTION(BadRLP()); + return m_data[1] != 0; + } + else if (n < c_rlpListStart) + { + if (m_data.size() <= size_t(1 + n - c_rlpDataIndLenZero)) + BOOST_THROW_EXCEPTION(BadRLP()); + return m_data[1 + n - c_rlpDataIndLenZero] != 0; + } + else + return false; + return false; } size_t RLP::length() const { - if (isNull()) - return 0; - requireGood(); - size_t ret = 0; - byte const n = m_data[0]; - if (n < c_rlpDataImmLenStart) - return 1; - else if (n <= c_rlpDataIndLenZero) - return n - c_rlpDataImmLenStart; - else if (n < c_rlpListStart) - { - if (m_data.size() <= size_t(n - c_rlpDataIndLenZero)) - BOOST_THROW_EXCEPTION(BadRLP()); - if (m_data.size() > 1) - if (m_data[1] == 0) - BOOST_THROW_EXCEPTION(BadRLP()); - unsigned lengthSize = n - c_rlpDataIndLenZero; - if (lengthSize > sizeof(ret)) - // We did not check, but would most probably not fit in our memory. - BOOST_THROW_EXCEPTION(UndersizeRLP()); - // No leading zeroes. - if (!m_data[1]) - BOOST_THROW_EXCEPTION(BadRLP()); - for (unsigned i = 0; i < lengthSize; ++i) - ret = (ret << 8) | m_data[i + 1]; - // Must be greater than the limit. - if (ret < c_rlpListStart - c_rlpDataImmLenStart - c_rlpMaxLengthBytes) - BOOST_THROW_EXCEPTION(BadRLP()); - } - else if (n <= c_rlpListIndLenZero) - return n - c_rlpListStart; - else - { - unsigned lengthSize = n - c_rlpListIndLenZero; - if (m_data.size() <= lengthSize) - BOOST_THROW_EXCEPTION(BadRLP()); - if (m_data.size() > 1) - if (m_data[1] == 0) - BOOST_THROW_EXCEPTION(BadRLP()); - if (lengthSize > sizeof(ret)) - // We did not check, but would most probably not fit in our memory. - BOOST_THROW_EXCEPTION(UndersizeRLP()); - if (!m_data[1]) - BOOST_THROW_EXCEPTION(BadRLP()); - for (unsigned i = 0; i < lengthSize; ++i) - ret = (ret << 8) | m_data[i + 1]; - if (ret < 0x100 - c_rlpListStart - c_rlpMaxLengthBytes) - BOOST_THROW_EXCEPTION(BadRLP()); - } - // We have to be able to add payloadOffset to length without overflow. - // This rejects roughly 4GB-sized RLPs on some platforms. - if (ret >= std::numeric_limits::max() - 0x100) - BOOST_THROW_EXCEPTION(UndersizeRLP()); - return ret; + if (isNull()) + return 0; + requireGood(); + size_t ret = 0; + byte const n = m_data[0]; + if (n < c_rlpDataImmLenStart) + return 1; + else if (n <= c_rlpDataIndLenZero) + return n - c_rlpDataImmLenStart; + else if (n < c_rlpListStart) + { + if (m_data.size() <= size_t(n - c_rlpDataIndLenZero)) + BOOST_THROW_EXCEPTION(BadRLP()); + if (m_data.size() > 1) + if (m_data[1] == 0) + BOOST_THROW_EXCEPTION(BadRLP()); + unsigned lengthSize = n - c_rlpDataIndLenZero; + if (lengthSize > sizeof(ret)) + // We did not check, but would most probably not fit in our memory. + BOOST_THROW_EXCEPTION(UndersizeRLP()); + // No leading zeroes. + if (!m_data[1]) + BOOST_THROW_EXCEPTION(BadRLP()); + for (unsigned i = 0; i < lengthSize; ++i) + ret = (ret << 8) | m_data[i + 1]; + // Must be greater than the limit. + if (ret < c_rlpListStart - c_rlpDataImmLenStart - c_rlpMaxLengthBytes) + BOOST_THROW_EXCEPTION(BadRLP()); + } + else if (n <= c_rlpListIndLenZero) + return n - c_rlpListStart; + else + { + unsigned lengthSize = n - c_rlpListIndLenZero; + if (m_data.size() <= lengthSize) + BOOST_THROW_EXCEPTION(BadRLP()); + if (m_data.size() > 1) + if (m_data[1] == 0) + BOOST_THROW_EXCEPTION(BadRLP()); + if (lengthSize > sizeof(ret)) + // We did not check, but would most probably not fit in our memory. + BOOST_THROW_EXCEPTION(UndersizeRLP()); + if (!m_data[1]) + BOOST_THROW_EXCEPTION(BadRLP()); + for (unsigned i = 0; i < lengthSize; ++i) + ret = (ret << 8) | m_data[i + 1]; + if (ret < 0x100 - c_rlpListStart - c_rlpMaxLengthBytes) + BOOST_THROW_EXCEPTION(BadRLP()); + } + // We have to be able to add payloadOffset to length without overflow. + // This rejects roughly 4GB-sized RLPs on some platforms. + if (ret >= std::numeric_limits::max() - 0x100) + BOOST_THROW_EXCEPTION(UndersizeRLP()); + return ret; } size_t RLP::items() const { - if (isList()) - { - bytesConstRef d = payload(); - size_t i = 0; - for (; d.size(); ++i) - d = d.cropped(sizeAsEncoded(d)); - return i; - } - return 0; + if (isList()) + { + bytesConstRef d = payload(); + size_t i = 0; + for (; d.size(); ++i) + d = d.cropped(sizeAsEncoded(d)); + return i; + } + return 0; } RLPStream& RLPStream::appendRaw(bytesConstRef _s, size_t _itemCount) { - m_out.insert(m_out.end(), _s.begin(), _s.end()); - noteAppended(_itemCount); - return *this; + m_out.insert(m_out.end(), _s.begin(), _s.end()); + noteAppended(_itemCount); + return *this; } void RLPStream::noteAppended(size_t _itemCount) { - if (!_itemCount) - return; -// cdebug << "noteAppended(" << _itemCount << ")"; - while (m_listStack.size()) - { - if (m_listStack.back().first < _itemCount) - BOOST_THROW_EXCEPTION(RLPException() << errinfo_comment("itemCount too large") << RequirementError((bigint)m_listStack.back().first, (bigint)_itemCount)); - m_listStack.back().first -= _itemCount; - if (m_listStack.back().first) - break; - else - { - auto p = m_listStack.back().second; - m_listStack.pop_back(); - size_t s = m_out.size() - p; // list size - auto brs = bytesRequired(s); - unsigned encodeSize = s < c_rlpListImmLenCount ? 1 : (1 + brs); -// cdebug << "s: " << s << ", p: " << p << ", m_out.size(): " << m_out.size() << ", encodeSize: " << encodeSize << " (br: " << brs << ")"; - auto os = m_out.size(); - m_out.resize(os + encodeSize); - memmove(m_out.data() + p + encodeSize, m_out.data() + p, os - p); - if (s < c_rlpListImmLenCount) - m_out[p] = (byte)(c_rlpListStart + s); - else if (c_rlpListIndLenZero + brs <= 0xff) - { - m_out[p] = (byte)(c_rlpListIndLenZero + brs); - byte* b = &(m_out[p + brs]); - for (; s; s >>= 8) - *(b--) = (byte)s; - } - else - BOOST_THROW_EXCEPTION(RLPException() << errinfo_comment("itemCount too large for RLP")); - } - _itemCount = 1; // for all following iterations, we've effectively appended a single item only since we completed a list. - } + if (!_itemCount) + return; +// cdebug << "noteAppended(" << _itemCount << ")"; + while (m_listStack.size()) + { + if (m_listStack.back().first < _itemCount) + BOOST_THROW_EXCEPTION(RLPException() << errinfo_comment("itemCount too large") << RequirementError((bigint)m_listStack.back().first, (bigint)_itemCount)); + m_listStack.back().first -= _itemCount; + if (m_listStack.back().first) + break; + else + { + auto p = m_listStack.back().second; + m_listStack.pop_back(); + size_t s = m_out.size() - p; // list size + auto brs = bytesRequired(s); + unsigned encodeSize = s < c_rlpListImmLenCount ? 1 : (1 + brs); +// cdebug << "s: " << s << ", p: " << p << ", m_out.size(): " << m_out.size() << ", encodeSize: " << encodeSize << " (br: " << brs << ")"; + auto os = m_out.size(); + m_out.resize(os + encodeSize); + memmove(m_out.data() + p + encodeSize, m_out.data() + p, os - p); + if (s < c_rlpListImmLenCount) + m_out[p] = (byte)(c_rlpListStart + s); + else if (c_rlpListIndLenZero + brs <= 0xff) + { + m_out[p] = (byte)(c_rlpListIndLenZero + brs); + byte* b = &(m_out[p + brs]); + for (; s; s >>= 8) + *(b--) = (byte)s; + } + else + BOOST_THROW_EXCEPTION(RLPException() << errinfo_comment("itemCount too large for RLP")); + } + _itemCount = 1; // for all following iterations, we've effectively appended a single item only since we completed a list. + } } RLPStream& RLPStream::appendList(size_t _items) { -// cdebug << "appendList(" << _items << ")"; - if (_items) - m_listStack.push_back(std::make_pair(_items, m_out.size())); - else - appendList(bytes()); - return *this; +// cdebug << "appendList(" << _items << ")"; + if (_items) + m_listStack.push_back(std::make_pair(_items, m_out.size())); + else + appendList(bytes()); + return *this; } RLPStream& RLPStream::appendList(bytesConstRef _rlp) { - if (_rlp.size() < c_rlpListImmLenCount) - m_out.push_back((byte)(_rlp.size() + c_rlpListStart)); - else - pushCount(_rlp.size(), c_rlpListIndLenZero); - appendRaw(_rlp, 1); - return *this; + if (_rlp.size() < c_rlpListImmLenCount) + m_out.push_back((byte)(_rlp.size() + c_rlpListStart)); + else + pushCount(_rlp.size(), c_rlpListIndLenZero); + appendRaw(_rlp, 1); + return *this; } RLPStream& RLPStream::append(bytesConstRef _s, bool _compact) { - size_t s = _s.size(); - byte const* d = _s.data(); - if (_compact) - for (size_t i = 0; i < _s.size() && !*d; ++i, --s, ++d) {} + size_t s = _s.size(); + byte const* d = _s.data(); + if (_compact) + for (size_t i = 0; i < _s.size() && !*d; ++i, --s, ++d) {} - if (s == 1 && *d < c_rlpDataImmLenStart) - m_out.push_back(*d); - else - { - if (s < c_rlpDataImmLenCount) - m_out.push_back((byte)(s + c_rlpDataImmLenStart)); - else - pushCount(s, c_rlpDataIndLenZero); - appendRaw(bytesConstRef(d, s), 0); - } - noteAppended(); - return *this; + if (s == 1 && *d < c_rlpDataImmLenStart) + m_out.push_back(*d); + else + { + if (s < c_rlpDataImmLenCount) + m_out.push_back((byte)(s + c_rlpDataImmLenStart)); + else + pushCount(s, c_rlpDataIndLenZero); + appendRaw(bytesConstRef(d, s), 0); + } + noteAppended(); + return *this; } RLPStream& RLPStream::append(bigint _i) { - if (!_i) - m_out.push_back(c_rlpDataImmLenStart); - else if (_i < c_rlpDataImmLenStart) - m_out.push_back((byte)_i); - else - { - unsigned br = bytesRequired(_i); - if (br < c_rlpDataImmLenCount) - m_out.push_back((byte)(br + c_rlpDataImmLenStart)); - else - { - auto brbr = bytesRequired(br); - if (c_rlpDataIndLenZero + brbr > 0xff) - BOOST_THROW_EXCEPTION(RLPException() << errinfo_comment("Number too large for RLP")); - m_out.push_back((byte)(c_rlpDataIndLenZero + brbr)); - pushInt(br, brbr); - } - pushInt(_i, br); - } - noteAppended(); - return *this; + if (!_i) + m_out.push_back(c_rlpDataImmLenStart); + else if (_i < c_rlpDataImmLenStart) + m_out.push_back((byte)_i); + else + { + unsigned br = bytesRequired(_i); + if (br < c_rlpDataImmLenCount) + m_out.push_back((byte)(br + c_rlpDataImmLenStart)); + else + { + auto brbr = bytesRequired(br); + if (c_rlpDataIndLenZero + brbr > 0xff) + BOOST_THROW_EXCEPTION(RLPException() << errinfo_comment("Number too large for RLP")); + m_out.push_back((byte)(c_rlpDataIndLenZero + brbr)); + pushInt(br, brbr); + } + pushInt(_i, br); + } + noteAppended(); + return *this; } void RLPStream::pushCount(size_t _count, byte _base) { - auto br = bytesRequired(_count); - if (int(br) + _base > 0xff) - BOOST_THROW_EXCEPTION(RLPException() << errinfo_comment("Count too large for RLP")); - m_out.push_back((byte)(br + _base)); // max 8 bytes. - pushInt(_count, br); + auto br = bytesRequired(_count); + if (int(br) + _base > 0xff) + BOOST_THROW_EXCEPTION(RLPException() << errinfo_comment("Count too large for RLP")); + m_out.push_back((byte)(br + _base)); // max 8 bytes. + pushInt(_count, br); } static void streamOut(std::ostream& _out, libbitcoin::RLP const& _d, unsigned _depth = 0) { - if (_depth > 64) - _out << ""; - else if (_d.isNull()) - _out << "null"; - else if (_d.isInt()) - _out << std::showbase << std::hex << std::nouppercase << _d.toInt(RLP::LaissezFaire) << dec; - else if (_d.isData()) - _out << escaped(_d.toString(), false); - else if (_d.isList()) - { - _out << "["; - int j = 0; - for (auto i: _d) - { - _out << (j++ ? ", " : " "); - streamOut(_out, i, _depth + 1); - } - _out << " ]"; - } + if (_depth > 64) + _out << ""; + else if (_d.isNull()) + _out << "null"; + else if (_d.isInt()) + _out << std::showbase << std::hex << std::nouppercase << _d.toInt(RLP::LaissezFaire) << dec; + else if (_d.isData()) + _out << escaped(_d.toString(), false); + else if (_d.isList()) + { + _out << "["; + int j = 0; + for (auto i: _d) + { + _out << (j++ ? ", " : " "); + streamOut(_out, i, _depth + 1); + } + _out << " ]"; + } } std::ostream& libbitcoin::operator<<(std::ostream& _out, RLP const& _d) { - streamOut(_out, _d); - return _out; + streamOut(_out, _d); + return _out; } diff --git a/src/lib/consensus/common/libdevcore/SHA3.cpp b/src/lib/consensus/common/libdevcore/SHA3.cpp index 40eef35ce..8d5be8f44 100644 --- a/src/lib/consensus/common/libdevcore/SHA3.cpp +++ b/src/lib/consensus/common/libdevcore/SHA3.cpp @@ -1,18 +1,18 @@ /* - This file is part of cpp-ethereum. + This file is part of cpp-ethereum. - cpp-ethereum is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. + cpp-ethereum is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. - cpp-ethereum is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. + cpp-ethereum is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. - You should have received a copy of the GNU General Public License - along with cpp-ethereum. If not, see . + You should have received a copy of the GNU General Public License + along with cpp-ethereum. If not, see . */ /** @file SHA3.cpp * @author Gav Wood @@ -65,12 +65,12 @@ decsha3(512) /*** Constants. ***/ static const uint8_t rho[24] = \ { 1, 3, 6, 10, 15, 21, - 28, 36, 45, 55, 2, 14, - 27, 41, 56, 8, 25, 43, - 62, 18, 39, 61, 20, 44}; + 28, 36, 45, 55, 2, 14, + 27, 41, 56, 8, 25, 43, + 62, 18, 39, 61, 20, 44}; static const uint8_t pi[24] = \ {10, 7, 11, 17, 18, 3, - 5, 16, 8, 21, 24, 4, + 5, 16, 8, 21, 24, 4, 15, 23, 19, 13, 12, 2, 20, 14, 22, 9, 6, 1}; static const uint64_t RC[24] = \ @@ -98,30 +98,30 @@ static inline void keccakf(void* state) { uint8_t x, y; for (int i = 0; i < 24; i++) { - // Theta - FOR5(x, 1, - b[x] = 0; - FOR5(y, 5, - b[x] ^= a[x + y]; )) - FOR5(x, 1, - FOR5(y, 5, - a[y + x] ^= b[(x + 4) % 5] ^ rol(b[(x + 1) % 5], 1); )) - // Rho and pi - t = a[1]; - x = 0; - REPEAT24(b[0] = a[pi[x]]; - a[pi[x]] = rol(t, rho[x]); - t = b[0]; - x++; ) - // Chi - FOR5(y, - 5, - FOR5(x, 1, - b[x] = a[y + x];) - FOR5(x, 1, - a[y + x] = b[x] ^ ((~b[(x + 1) % 5]) & b[(x + 2) % 5]); )) - // Iota - a[0] ^= RC[i]; + // Theta + FOR5(x, 1, + b[x] = 0; + FOR5(y, 5, + b[x] ^= a[x + y]; )) + FOR5(x, 1, + FOR5(y, 5, + a[y + x] ^= b[(x + 4) % 5] ^ rol(b[(x + 1) % 5], 1); )) + // Rho and pi + t = a[1]; + x = 0; + REPEAT24(b[0] = a[pi[x]]; + a[pi[x]] = rol(t, rho[x]); + t = b[0]; + x++; ) + // Chi + FOR5(y, + 5, + FOR5(x, 1, + b[x] = a[y + x];) + FOR5(x, 1, + a[y + x] = b[x] ^ ((~b[(x + 1) % 5]) & b[(x + 2) % 5]); )) + // Iota + a[0] ^= RC[i]; } } @@ -134,15 +134,15 @@ static inline void keccakf(void* state) { _(for (size_t i = 0; i < L; i += ST) { S; }) #define mkapply_ds(NAME, S) \ static inline void NAME(uint8_t* dst, \ - const uint8_t* src, \ - size_t len) { \ - FOR(i, 1, len, S); \ + const uint8_t* src, \ + size_t len) { \ + FOR(i, 1, len, S); \ } #define mkapply_sd(NAME, S) \ static inline void NAME(const uint8_t* src, \ - uint8_t* dst, \ - size_t len) { \ - FOR(i, 1, len, S); \ + uint8_t* dst, \ + size_t len) { \ + FOR(i, 1, len, S); \ } mkapply_ds(xorin, dst[i] ^= src[i]) // xorin @@ -154,18 +154,18 @@ mkapply_sd(setout, dst[i] = src[i]) // setout // Fold P*F over the full blocks of an input. #define foldP(I, L, F) \ while (L >= rate) { \ - F(a, I, rate); \ - P(a); \ - I += rate; \ - L -= rate; \ + F(a, I, rate); \ + P(a); \ + I += rate; \ + L -= rate; \ } /** The sponge-based hash construction. **/ static inline int hash(uint8_t* out, size_t outlen, - const uint8_t* in, size_t inlen, - size_t rate, uint8_t delim) { + const uint8_t* in, size_t inlen, + size_t rate, uint8_t delim) { if ((out == NULL) || ((in == NULL) && inlen != 0) || (rate >= Plen)) { - return -1; + return -1; } uint8_t a[Plen] = {0}; // Absorb input. @@ -187,16 +187,16 @@ static inline int hash(uint8_t* out, size_t outlen, /*** Helper macros to define SHA3 and SHAKE instances. ***/ #define defshake(bits) \ int shake##bits(uint8_t* out, size_t outlen, \ - const uint8_t* in, size_t inlen) { \ - return hash(out, outlen, in, inlen, 200 - (bits / 4), 0x1f); \ + const uint8_t* in, size_t inlen) { \ + return hash(out, outlen, in, inlen, 200 - (bits / 4), 0x1f); \ } #define defsha3(bits) \ int sha3_##bits(uint8_t* out, size_t outlen, \ - const uint8_t* in, size_t inlen) { \ - if (outlen > (bits/8)) { \ - return -1; \ - } \ - return hash(out, outlen, in, inlen, 200 - (bits / 4), 0x01); \ + const uint8_t* in, size_t inlen) { \ + if (outlen > (bits/8)) { \ + return -1; \ + } \ + return hash(out, outlen, in, inlen, 200 - (bits / 4), 0x01); \ } /*** FIPS202 SHAKE VOFs ***/ @@ -215,13 +215,13 @@ unsigned g_sha3Counter = 0; bool sha3(bytesConstRef _input, bytesRef o_output) { - // FIXME: What with unaligned memory? - if (o_output.size() != 32) - return false; - ++g_sha3Counter; - keccak::sha3_256(o_output.data(), 32, _input.data(), _input.size()); -// keccak::keccak(ret.data(), 32, (uint64_t const*)_input.data(), _input.size()); - return true; + // FIXME: What with unaligned memory? + if (o_output.size() != 32) + return false; + ++g_sha3Counter; + keccak::sha3_256(o_output.data(), 32, _input.data(), _input.size()); +// keccak::keccak(ret.data(), 32, (uint64_t const*)_input.data(), _input.size()); + return true; } } diff --git a/src/lib/consensus/common/miner/MinerAux.cpp b/src/lib/consensus/common/miner/MinerAux.cpp index ba320484c..9920f07b9 100644 --- a/src/lib/consensus/common/miner/MinerAux.cpp +++ b/src/lib/consensus/common/miner/MinerAux.cpp @@ -34,117 +34,117 @@ MinerAux* MinerAux::get() LightType MinerAux::get_light(h256& _seedHash) { - UpgradableGuard l(get()->x_lights); - if (get()->m_lights.count(_seedHash)) - return get()->m_lights.at(_seedHash); - UpgradeGuard l2(l); - return (get()->m_lights[_seedHash] = make_shared(_seedHash)); + UpgradableGuard l(get()->x_lights); + if (get()->m_lights.count(_seedHash)) + return get()->m_lights.at(_seedHash); + UpgradeGuard l2(l); + return (get()->m_lights[_seedHash] = make_shared(_seedHash)); } //static std::function s_dagCallback; static int dagCallbackShim(unsigned _p) { - return 0; + return 0; } FullType MinerAux::get_full(h256& _seedHash) { - FullType ret; - auto l = get_light(_seedHash); - DEV_GUARDED(get()->x_fulls) - if ((ret = get()->m_fulls[_seedHash].lock())) - { - get()->m_lastUsedFull = ret; - return ret; - } - //s_dagCallback = _f; - ret = make_shared(l->light, dagCallbackShim); - DEV_GUARDED(get()->x_fulls) - get()->m_fulls[_seedHash] = get()->m_lastUsedFull = ret; - return ret; + FullType ret; + auto l = get_light(_seedHash); + DEV_GUARDED(get()->x_fulls) + if ((ret = get()->m_fulls[_seedHash].lock())) + { + get()->m_lastUsedFull = ret; + return ret; + } + //s_dagCallback = _f; + ret = make_shared(l->light, dagCallbackShim); + DEV_GUARDED(get()->x_fulls) + get()->m_fulls[_seedHash] = get()->m_lastUsedFull = ret; + return ret; } bool MinerAux::search(libbitcoin::chain::header& header, std::function is_exit) { - auto tid = std::this_thread::get_id(); - static std::mt19937_64 s_eng((utcTime() + std::hash()(tid))); - uint64_t tryNonce = s_eng(); - ethash_return_value ethashReturn; - FullType dag; - h256 seed = HeaderAux::seedHash(header); - h256 header_hash = HeaderAux::hashHead(header); - h256 boundary = HeaderAux::boundary(header); + auto tid = std::this_thread::get_id(); + static std::mt19937_64 s_eng((utcTime() + std::hash()(tid))); + uint64_t tryNonce = s_eng(); + ethash_return_value ethashReturn; + FullType dag; + h256 seed = HeaderAux::seedHash(header); + h256 header_hash = HeaderAux::hashHead(header); + h256 boundary = HeaderAux::boundary(header); std::chrono::steady_clock::time_point timeStart; uint64_t ms; uint64_t hashCount = 1; - while( nullptr == dag) - { - log::debug(LOG_MINER) << "start generate dag\n"; + while( nullptr == dag) + { + log::debug(LOG_MINER) << "start generate dag\n"; try { dag = get_full(seed); } catch (const ExternalFunctionFailure&) { return false; } - } - log::debug(LOG_MINER) << "Start miner @ height: "<< header.number << '\n'; + } + log::debug(LOG_MINER) << "Start miner @ height: "<< header.number << '\n'; timeStart = std::chrono::steady_clock::now(); - for (; ; tryNonce++, hashCount++) - { - ethashReturn = ethash_full_compute(dag->full, *(ethash_h256_t*)header_hash.data(), tryNonce); - h256 value = h256((uint8_t*)ðashReturn.result, h256::ConstructFromPointer); - h256 mixhash =h256((uint8_t*)ðashReturn.mix_hash, h256::ConstructFromPointer); - if (value <= boundary ) - { - MinerAux::setNonce(header, (u64)tryNonce); - MinerAux::setMixHash(header, mixhash); - log::debug(LOG_MINER) << "find slolution! block height: "<< header.number << '\n'; - break; - } - if(is_exit() == true) - { - ethashReturn.success = false; - return ethashReturn.success; - } - } + for (; ; tryNonce++, hashCount++) + { + ethashReturn = ethash_full_compute(dag->full, *(ethash_h256_t*)header_hash.data(), tryNonce); + h256 value = h256((uint8_t*)ðashReturn.result, h256::ConstructFromPointer); + h256 mixhash =h256((uint8_t*)ðashReturn.mix_hash, h256::ConstructFromPointer); + if (value <= boundary ) + { + MinerAux::setNonce(header, (u64)tryNonce); + MinerAux::setMixHash(header, mixhash); + log::debug(LOG_MINER) << "find slolution! block height: "<< header.number << '\n'; + break; + } + if(is_exit() == true) + { + ethashReturn.success = false; + return ethashReturn.success; + } + } ms = std::chrono::duration_cast(std::chrono::steady_clock::now() - timeStart).count(); ms = ms? ms : 1; get()->m_rate = hashCount * 1000 / ms; - return ethashReturn.success; + return ethashReturn.success; } bool MinerAux::verifySeal(libbitcoin::chain::header& _header, libbitcoin::chain::header& _parent) { - Result result; - h256 seedHash = HeaderAux::seedHash(_header); - h256 headerHash = HeaderAux::hashHead(_header); - Nonce nonce = (Nonce)_header.nonce; - if( _header.bits != HeaderAux::calculateDifficulty(_header, _parent)) - { - log::error(LOG_MINER) << _header.number<<" block , verify diffculty failed\n"; - return false; - } - DEV_GUARDED(get()->x_fulls) - if (FullType dag = get()->m_fulls[seedHash].lock()) - { - result = dag->compute(headerHash, nonce); - - if(result.value <= HeaderAux::boundary(_header) && (result.mixHash).hex() == ((h256)_header.mixhash).hex()) - { - //log::debug(LOG_MINER) << _header.number <<" block has been verified (Full)\n"; - return true; - } - return false; - } - result = get()->get_light(seedHash)->compute(headerHash, nonce); - if(result.value <= HeaderAux::boundary(_header) && (result.mixHash).hex() == ((h256)_header.mixhash).hex()) - { - //log::debug(LOG_MINER) << _header.number <<" block has been verified (Light)\n"; - return true; - } - log::error(LOG_MINER) << _header.number <<" block verified failed !\n"; - return false; + Result result; + h256 seedHash = HeaderAux::seedHash(_header); + h256 headerHash = HeaderAux::hashHead(_header); + Nonce nonce = (Nonce)_header.nonce; + if( _header.bits != HeaderAux::calculateDifficulty(_header, _parent)) + { + log::error(LOG_MINER) << _header.number<<" block , verify diffculty failed\n"; + return false; + } + DEV_GUARDED(get()->x_fulls) + if (FullType dag = get()->m_fulls[seedHash].lock()) + { + result = dag->compute(headerHash, nonce); + + if(result.value <= HeaderAux::boundary(_header) && (result.mixHash).hex() == ((h256)_header.mixhash).hex()) + { + //log::debug(LOG_MINER) << _header.number <<" block has been verified (Full)\n"; + return true; + } + return false; + } + result = get()->get_light(seedHash)->compute(headerHash, nonce); + if(result.value <= HeaderAux::boundary(_header) && (result.mixHash).hex() == ((h256)_header.mixhash).hex()) + { + //log::debug(LOG_MINER) << _header.number <<" block has been verified (Light)\n"; + return true; + } + log::error(LOG_MINER) << _header.number <<" block verified failed !\n"; + return false; } diff --git a/src/lib/consensus/consensus/consensus.cpp b/src/lib/consensus/consensus/consensus.cpp index a828d4f0a..850c3daea 100644 --- a/src/lib/consensus/consensus/consensus.cpp +++ b/src/lib/consensus/consensus/consensus.cpp @@ -37,7 +37,7 @@ namespace libbitcoin { namespace consensus { -// Static initialization of libsecp256k1 initialization context. +// Static initialization of libsecp256k1 initialization context. ECCVerifyHandle TxInputStream::secp256k1_context_ = ECCVerifyHandle(); TxInputStream::TxInputStream(const unsigned char* transaction, @@ -180,9 +180,9 @@ unsigned int verify_flags_to_script_flags(unsigned int flags) } // This function is published. The implementation exposes no satoshi internals. -verify_result_type verify_script(const unsigned char* transaction, - size_t transaction_size, const unsigned char* prevout_script, - size_t prevout_script_size, unsigned int tx_input_index, +verify_result_type verify_script(const unsigned char* transaction, + size_t transaction_size, const unsigned char* prevout_script, + size_t prevout_script_size, unsigned int tx_input_index, unsigned int flags) { if (transaction_size > 0 && transaction == NULL) @@ -192,7 +192,7 @@ verify_result_type verify_script(const unsigned char* transaction, throw std::invalid_argument("prevout_script"); CTransaction tx; - try + try { TxInputStream stream(transaction, transaction_size); Unserialize(stream, tx, SER_NETWORK, PROTOCOL_VERSION); diff --git a/src/lib/database/databases/address_did_database.cpp b/src/lib/database/databases/address_did_database.cpp index 6da30f2ac..f2f1698c5 100644 --- a/src/lib/database/databases/address_did_database.cpp +++ b/src/lib/database/databases/address_did_database.cpp @@ -44,12 +44,12 @@ BC_CONSTEXPR size_t initial_lookup_file_size = header_size + minimum_records_siz BC_CONSTEXPR size_t record_size = hash_table_multimap_record_size(); BC_CONSTEXPR size_t did_transfer_record_size = 1 + 36 + 4 + 8 + 2 + 4 + DID_DETAIL_FIX_SIZE; // DID_DETAIL_FIX_SIZE is the biggest one -// + std::max({ETP_FIX_SIZE, DID_DETAIL_FIX_SIZE, DID_TRANSFER_FIX_SIZE}); +// + std::max({ETP_FIX_SIZE, DID_DETAIL_FIX_SIZE, DID_TRANSFER_FIX_SIZE}); BC_CONSTEXPR size_t row_record_size = hash_table_record_size(did_transfer_record_size); address_did_database::address_did_database(const path& lookup_filename, const path& rows_filename, std::shared_ptr mutex) - : lookup_file_(lookup_filename, mutex), + : lookup_file_(lookup_filename, mutex), lookup_header_(lookup_file_, number_buckets), lookup_manager_(lookup_file_, header_size, record_size), lookup_map_(lookup_header_, lookup_manager_), @@ -133,16 +133,16 @@ void address_did_database::store_input(const short_hash& key, serial.write_4_bytes_little_endian(input_height); // 4 serial.write_8_bytes_little_endian(previous.checksum()); // 8 - serial.write_2_bytes_little_endian(0); // 2 use etp type fill incase invalid when deser - serial.write_4_bytes_little_endian(timestamp); // 4 - // did data should be here but input has no these data + serial.write_2_bytes_little_endian(0); // 2 use etp type fill incase invalid when deser + serial.write_4_bytes_little_endian(timestamp); // 4 + // did data should be here but input has no these data }; rows_multimap_.add_row(key, write); } void address_did_database::delete_old_did(const short_hash& key) { - delete_last_row(key); + delete_last_row(key); } void address_did_database::delete_last_row(const short_hash& key) @@ -178,12 +178,12 @@ business_record::list address_did_database::get(const short_hash& key, // value or checksum { deserial.read_8_bytes_little_endian() }, - - // business_kd; + + // business_kd; //deserial.read_2_bytes_little_endian(), - // timestamp; + // timestamp; //deserial.read_4_bytes_little_endian(), - + business_data::factory_from_data(deserial) // 2 + 4 are in this class }; }; @@ -211,11 +211,11 @@ business_record::list address_did_database::get(const short_hash& key, return result; } /// get all record of key from database -std::shared_ptr> address_did_database::get(const std::string& address, const std::string& symbol, +std::shared_ptr> address_did_database::get(const std::string& address, const std::string& symbol, size_t start_height, size_t end_height, uint64_t limit, uint64_t page_number) const { - data_chunk addr_data(address.begin(), address.end()); - auto key = ripemd160_hash(addr_data); + data_chunk addr_data(address.begin(), address.end()); + auto key = ripemd160_hash(addr_data); // Read the height value from the row. const auto read_height = [](uint8_t* data) @@ -242,12 +242,12 @@ std::shared_ptr> address_did_database::get(const st // value or checksum { deserial.read_8_bytes_little_endian() }, - - // business_kd; + + // business_kd; //deserial.read_2_bytes_little_endian(), - // timestamp; + // timestamp; //deserial.read_4_bytes_little_endian(), - + business_data::factory_from_data(deserial) // 2 + 4 are in this class }; }; @@ -266,12 +266,12 @@ std::shared_ptr> address_did_database::get(const st // This obtains a remap safe address pointer against the rows file. const auto record = rows_list_.get(index); const auto address = REMAP_ADDRESS(record); - auto height = read_height(address); + auto height = read_height(address); std::string did_symbol; // Skip rows below from_height. - if (((start_height == 0)&&(end_height == 0)) - || ((start_height <= height) && (height < end_height))) { // from current block height + if (((start_height == 0)&&(end_height == 0)) + || ((start_height <= height) && (height < end_height))) { // from current block height //result->emplace_back(read_row(address)); auto row = read_row(address); if (symbol.empty()) { // all utxo @@ -289,7 +289,7 @@ std::shared_ptr> address_did_database::get(const st auto transfer = boost::get(row.data.get_data()); did_symbol = transfer.get_symbol(); } - + if (symbol == did_symbol) { cnt++; if((limit > 0) && (page_number > 0) && ((cnt - 1) / limit) < (page_number - 1)) @@ -308,8 +308,8 @@ std::shared_ptr> address_did_database::get(const st std::shared_ptr> address_did_database::get(const std::string& address, size_t start_height, size_t end_height) const { - data_chunk addr_data(address.begin(), address.end()); - auto key = ripemd160_hash(addr_data); + data_chunk addr_data(address.begin(), address.end()); + auto key = ripemd160_hash(addr_data); // Read the height value from the row. const auto read_height = [](uint8_t* data) @@ -336,12 +336,12 @@ std::shared_ptr> address_did_database::get(const st // value or checksum { deserial.read_8_bytes_little_endian() }, - - // business_kd; + + // business_kd; //deserial.read_2_bytes_little_endian(), - // timestamp; + // timestamp; //deserial.read_4_bytes_little_endian(), - + business_data::factory_from_data(deserial) // 2 + 4 are in this class }; }; @@ -355,10 +355,10 @@ std::shared_ptr> address_did_database::get(const st // This obtains a remap safe address pointer against the rows file. const auto record = rows_list_.get(index); const auto address = REMAP_ADDRESS(record); - auto height = read_height(address); + auto height = read_height(address); // Skip rows below from_height. - if (((start_height == 0)&&(end_height == 0)) - || ((start_height <= height) && (height < end_height))) // from current block height + if (((start_height == 0)&&(end_height == 0)) + || ((start_height <= height) && (height < end_height))) // from current block height result->emplace_back(read_row(address)); } @@ -387,31 +387,31 @@ std::shared_ptr> address_did_database::get(size_t i // value or checksum { deserial.read_8_bytes_little_endian() }, - - // business_kd; + + // business_kd; //deserial.read_2_bytes_little_endian(), - // timestamp; + // timestamp; //deserial.read_4_bytes_little_endian(), - + business_data::factory_from_data(deserial) // 2 + 4 are in this class }; }; - + auto result = std::make_shared>(); auto sh_idx_vec = rows_multimap_.lookup(idx); - - for(auto each : *sh_idx_vec) { - - const auto records = record_multimap_iterable(rows_list_, each); - - for (const auto index: records) - { - // This obtains a remap safe address pointer against the rows file. - const auto record = rows_list_.get(index); - const auto address = REMAP_ADDRESS(record); - result->emplace_back(read_row(address)); - } - } + + for(auto each : *sh_idx_vec) { + + const auto records = record_multimap_iterable(rows_list_, each); + + for (const auto index: records) + { + // This obtains a remap safe address pointer against the rows file. + const auto record = rows_list_.get(index); + const auto address = REMAP_ADDRESS(record); + result->emplace_back(read_row(address)); + } + } // TODO: we could sort result here. return result; @@ -436,26 +436,26 @@ business_record address_did_database::get_record(size_t idx) const // value or checksum { deserial.read_8_bytes_little_endian() }, - + // business_kd; //deserial.read_2_bytes_little_endian(), // timestamp; //deserial.read_4_bytes_little_endian(), - + business_data::factory_from_data(deserial) // 2 + 4 are in this class }; }; - + // This obtains a remap safe address pointer against the rows file. const auto record = rows_list_.get(idx); const auto address = REMAP_ADDRESS(record); return read_row(address); } business_history::list address_did_database::get_business_history(const short_hash& key, - size_t from_height) const + size_t from_height) const { - business_record::list compact = get(key, from_height, 0); - + business_record::list compact = get(key, from_height, 0); + business_history::list result; @@ -470,7 +470,7 @@ business_history::list address_did_database::get_business_history(const short_ha row.value = output->val_chk_sum.value; row.spend = { null_hash, max_uint32 }; row.temporary_checksum = output->point.checksum(); - row.data = output->data; + row.data = output->data; result.emplace_back(row); output = compact.erase(output); continue; @@ -523,226 +523,226 @@ business_history::list address_did_database::get_business_history(const short_ha } // get address dids in the database(blockchain) -std::shared_ptr> address_did_database::get_address_business_history(const std::string& address, - size_t from_height) const +std::shared_ptr> address_did_database::get_address_business_history(const std::string& address, + size_t from_height) const { - data_chunk data(address.begin(), address.end()); - auto key = ripemd160_hash(data); - business_history::list result = get_business_history(key, from_height); - auto unspent = std::make_shared>(); - + data_chunk data(address.begin(), address.end()); + auto key = ripemd160_hash(data); + business_history::list result = get_business_history(key, from_height); + auto unspent = std::make_shared>(); + for (auto& row: result) { if ((row.spend.hash == null_hash)) {// unspent business - row.status = business_status::unspent; - unspent->emplace_back(row); + row.status = business_status::unspent; + unspent->emplace_back(row); + } + + if (row.output_height != 0 + &&(row.spend.hash == null_hash || row.spend_height == 0)) {// confirmed business + row.status = business_status::confirmed; + unspent->emplace_back(row); } - if (row.output_height != 0 - &&(row.spend.hash == null_hash || row.spend_height == 0)) {// confirmed business - row.status = business_status::confirmed; - unspent->emplace_back(row); - } - } - return unspent; - + return unspent; + } // get special kind of did in the database(blockchain) /* status -- // 0 -- unspent 1 -- confirmed */ -business_history::list address_did_database::get_business_history(const std::string& address, - size_t from_height, business_kind kind, uint8_t status) const +business_history::list address_did_database::get_business_history(const std::string& address, + size_t from_height, business_kind kind, uint8_t status) const { - data_chunk data(address.begin(), address.end()); - auto key = ripemd160_hash(data); - business_history::list result = get_business_history(key, from_height); - business_history::list unspent; - // did type check - if((kind != business_kind::did_register) // did_detail - && (kind != business_kind::did_transfer) // did_transfer - && (kind != business_kind::etp)) - return unspent; - + data_chunk data(address.begin(), address.end()); + auto key = ripemd160_hash(data); + business_history::list result = get_business_history(key, from_height); + business_history::list unspent; + // did type check + if((kind != business_kind::did_register) // did_detail + && (kind != business_kind::did_transfer) // did_transfer + && (kind != business_kind::etp)) + return unspent; + for (const auto& row: result) { - if(row.data.get_kind_value() != kind) - continue; - + if(row.data.get_kind_value() != kind) + continue; + if ((row.spend.hash == null_hash) - && (status == 0)) // unspent business - unspent.emplace_back(row); - - if (row.output_height != 0 - &&(row.spend.hash == null_hash || row.spend_height == 0) - && (status == 1)) // confirmed business - unspent.emplace_back(row); - + && (status == 0)) // unspent business + unspent.emplace_back(row); + + if (row.output_height != 0 + &&(row.spend.hash == null_hash || row.spend_height == 0) + && (status == 1)) // confirmed business + unspent.emplace_back(row); + } - return unspent; - + return unspent; + } // get special kind of did in the database(blockchain) /* status -- // 0 -- unspent 1 -- confirmed */ -business_history::list address_did_database::get_business_history(const std::string& address, - size_t from_height, business_kind kind, uint32_t time_begin, uint32_t time_end) const +business_history::list address_did_database::get_business_history(const std::string& address, + size_t from_height, business_kind kind, uint32_t time_begin, uint32_t time_end) const { - data_chunk data(address.begin(), address.end()); - auto key = ripemd160_hash(data); - business_history::list result = get_business_history(key, from_height); - business_history::list unspent; - // did type check - if((kind != business_kind::did_register) // did_detail - && (kind != business_kind::did_transfer) // did_transfer - && (kind != business_kind::etp)) - return unspent; - + data_chunk data(address.begin(), address.end()); + auto key = ripemd160_hash(data); + business_history::list result = get_business_history(key, from_height); + business_history::list unspent; + // did type check + if((kind != business_kind::did_register) // did_detail + && (kind != business_kind::did_transfer) // did_transfer + && (kind != business_kind::etp)) + return unspent; + for (auto& row: result) { - if(row.data.get_kind_value() != kind - || row.data.get_timestamp()time_end) - continue; - + if(row.data.get_kind_value() != kind + || row.data.get_timestamp()time_end) + continue; + if ((row.spend.hash == null_hash)) {//0 -- unspent business - row.status = 0; - unspent.emplace_back(row); + row.status = 0; + unspent.emplace_back(row); + } + + if (row.output_height != 0 + &&(row.spend.hash == null_hash || row.spend_height == 0)) {// 1 -- confirmed business + row.status = 1; + unspent.emplace_back(row); } - if (row.output_height != 0 - &&(row.spend.hash == null_hash || row.spend_height == 0)) {// 1 -- confirmed business - row.status = 1; - unspent.emplace_back(row); - } - } - return unspent; - + return unspent; + } // get special kind of did in the database(blockchain) -business_address_did::list address_did_database::get_dids(const std::string& address, - size_t from_height, business_kind kind) const +business_address_did::list address_did_database::get_dids(const std::string& address, + size_t from_height, business_kind kind) const { - data_chunk data(address.begin(), address.end()); - auto key = ripemd160_hash(data); - business_history::list result = get_business_history(key, from_height); - business_address_did::list unspent; - // did type check - if((kind != business_kind::did_register) // did_detail - && (kind != business_kind::did_transfer)) // did_transfer - return unspent; - + data_chunk data(address.begin(), address.end()); + auto key = ripemd160_hash(data); + business_history::list result = get_business_history(key, from_height); + business_address_did::list unspent; + // did type check + if((kind != business_kind::did_register) // did_detail + && (kind != business_kind::did_transfer)) // did_transfer + return unspent; + for (const auto& row: result) { - if(row.data.get_kind_value() != kind) - continue; - - uint8_t status = 0xff; - if (row.spend.hash == null_hash) - status = 0; // 0 -- unspent 1 -- confirmed - - if (row.output_height != 0 && + if(row.data.get_kind_value() != kind) + continue; + + uint8_t status = 0xff; + if (row.spend.hash == null_hash) + status = 0; // 0 -- unspent 1 -- confirmed + + if (row.output_height != 0 && (row.spend.hash == null_hash || row.spend_height == 0)) status = 1; - - business_address_did detail; - if(row.data.get_kind_value() == business_kind::did_register) // did register - { - auto issue_info = boost::get(row.data.get_data()); - detail.detail = issue_info; - } - else if(row.data.get_kind_value() == business_kind::did_transfer)//did transfer - { - auto issue_info = boost::get(row.data.get_data()); - detail.detail = issue_info; - } - - detail.address = address; // account address - detail.status = status; // 0 -- unspent 1 -- confirmed - unspent.emplace_back(detail); + + business_address_did detail; + if(row.data.get_kind_value() == business_kind::did_register) // did register + { + auto issue_info = boost::get(row.data.get_data()); + detail.detail = issue_info; + } + else if(row.data.get_kind_value() == business_kind::did_transfer)//did transfer + { + auto issue_info = boost::get(row.data.get_data()); + detail.detail = issue_info; + } + + detail.address = address; // account address + detail.status = status; // 0 -- unspent 1 -- confirmed + unspent.emplace_back(detail); } - return unspent; - + return unspent; + } // get all kinds of did in the database(blockchain) -business_address_did::list address_did_database::get_dids(const std::string& address, - size_t from_height) const +business_address_did::list address_did_database::get_dids(const std::string& address, + size_t from_height) const { - data_chunk data(address.begin(), address.end()); - auto key = ripemd160_hash(data); - business_history::list result = get_business_history(key, from_height); - business_address_did::list unspent; + data_chunk data(address.begin(), address.end()); + auto key = ripemd160_hash(data); + business_history::list result = get_business_history(key, from_height); + business_address_did::list unspent; for (const auto& row: result) { - if((row.data.get_kind_value() != business_kind::did_register) // did_detail - && (row.data.get_kind_value() != business_kind::did_transfer)) // did_transfer - continue; - - uint8_t status = 0xff; - if (row.spend.hash == null_hash) - status = 0; // 0 -- unspent 1 -- confirmed - - if (row.output_height != 0 && + if((row.data.get_kind_value() != business_kind::did_register) // did_detail + && (row.data.get_kind_value() != business_kind::did_transfer)) // did_transfer + continue; + + uint8_t status = 0xff; + if (row.spend.hash == null_hash) + status = 0; // 0 -- unspent 1 -- confirmed + + if (row.output_height != 0 && (row.spend.hash == null_hash || row.spend_height == 0)) status = 1; - - business_address_did detail; - if(row.data.get_kind_value() == business_kind::did_register) // did register - { - auto issue_info = boost::get(row.data.get_data()); - detail.detail = issue_info; - } - else if(row.data.get_kind_value() == business_kind::did_transfer)//did transfer - { - auto transfer_info = boost::get(row.data.get_data()); - detail.detail = transfer_info; - } - - detail.address = address; // account address - detail.status = status; // 0 -- unspent 1 -- confirmed - unspent.emplace_back(detail); + + business_address_did detail; + if(row.data.get_kind_value() == business_kind::did_register) // did register + { + auto issue_info = boost::get(row.data.get_data()); + detail.detail = issue_info; + } + else if(row.data.get_kind_value() == business_kind::did_transfer)//did transfer + { + auto transfer_info = boost::get(row.data.get_data()); + detail.detail = transfer_info; + } + + detail.address = address; // account address + detail.status = status; // 0 -- unspent 1 -- confirmed + unspent.emplace_back(detail); } - return unspent; - + return unspent; + } -business_address_message::list address_did_database::get_messages(const std::string& address, - size_t from_height) const +business_address_message::list address_did_database::get_messages(const std::string& address, + size_t from_height) const { - data_chunk data(address.begin(), address.end()); - auto key = ripemd160_hash(data); - business_history::list result = get_business_history(key, from_height); - business_address_message::list unspent; + data_chunk data(address.begin(), address.end()); + auto key = ripemd160_hash(data); + business_history::list result = get_business_history(key, from_height); + business_address_message::list unspent; for (const auto& row: result) { - if((row.data.get_kind_value() != business_kind::message)) // did_detail - continue; - - uint8_t status = 0xff; - if (row.spend.hash == null_hash) - status = 0; // 0 -- unspent 1 -- confirmed - - if (row.output_height != 0 && + if((row.data.get_kind_value() != business_kind::message)) // did_detail + continue; + + uint8_t status = 0xff; + if (row.spend.hash == null_hash) + status = 0; // 0 -- unspent 1 -- confirmed + + if (row.output_height != 0 && (row.spend.hash == null_hash || row.spend_height == 0)) status = 1; - - business_address_message detail; - auto issue_info = boost::get(row.data.get_data()); - detail.msg = issue_info; - - detail.address = address; // account address - detail.status = status; // 0 -- unspent 1 -- confirmed - unspent.emplace_back(detail); + + business_address_message detail; + auto issue_info = boost::get(row.data.get_data()); + detail.msg = issue_info; + + detail.address = address; // account address + detail.status = status; // 0 -- unspent 1 -- confirmed + unspent.emplace_back(detail); } - return unspent; - + return unspent; + } void address_did_database::sync() { diff --git a/src/lib/database/databases/asset_database.cpp b/src/lib/database/databases/asset_database.cpp index f67a8e562..5a13c5365 100644 --- a/src/lib/database/databases/asset_database.cpp +++ b/src/lib/database/databases/asset_database.cpp @@ -46,28 +46,28 @@ asset_database::~asset_database() asset_result asset_database::get_asset_result(const hash_digest& hash) const { - const auto memory = get(hash); + const auto memory = get(hash); return asset_result(memory); } -/// +/// std::shared_ptr> asset_database::get_asset_details() const { - auto vec_acc = std::make_shared>(); - uint64_t i = 0; - for ( i = 0; i < get_bucket_count(); i++ ) { - auto memo = lookup_map_.find(i); - if(memo->size()) - { - const auto action = [&](memory_ptr elem) - { - const auto memory = REMAP_ADDRESS(elem); - auto deserial = make_deserializer_unsafe(memory); - vec_acc->push_back(asset_detail::factory_from_data(deserial)); - }; - std::for_each(memo->begin(), memo->end(), action); - } - } - return vec_acc; + auto vec_acc = std::make_shared>(); + uint64_t i = 0; + for ( i = 0; i < get_bucket_count(); i++ ) { + auto memo = lookup_map_.find(i); + if(memo->size()) + { + const auto action = [&](memory_ptr elem) + { + const auto memory = REMAP_ADDRESS(elem); + auto deserial = make_deserializer_unsafe(memory); + vec_acc->push_back(asset_detail::factory_from_data(deserial)); + }; + std::for_each(memo->begin(), memo->end(), action); + } + } + return vec_acc; } void asset_database::store(const hash_digest& hash, const asset_detail& sp_detail) @@ -76,7 +76,7 @@ void asset_database::store(const hash_digest& hash, const asset_detail& sp_detai const auto key = hash; const auto sp_size = sp_detail.serialized_size(); #ifdef MVS_DEBUG - log::debug("asset_database::store") << sp_detail.to_string(); + log::debug("asset_database::store") << sp_detail.to_string(); #endif BITCOIN_ASSERT(sp_size <= max_size_t); const auto value_size = static_cast(sp_size); @@ -87,7 +87,7 @@ void asset_database::store(const hash_digest& hash, const asset_detail& sp_detai serial.write_data(sp_detail.to_data()); }; //get_lookup_map().store(key, write, value_size); - lookup_map_.store(key, write, value_size); + lookup_map_.store(key, write, value_size); } } // namespace database } // namespace libbitcoin diff --git a/src/lib/database/databases/base_database.cpp b/src/lib/database/databases/base_database.cpp index efc77fe69..874eae22e 100644 --- a/src/lib/database/databases/base_database.cpp +++ b/src/lib/database/databases/base_database.cpp @@ -39,7 +39,7 @@ BC_CONSTEXPR size_t initial_map_file_size = header_size + minimum_slabs_size; base_database::base_database(const path& map_filename, std::shared_ptr mutex) - : lookup_file_(map_filename, mutex), + : lookup_file_(map_filename, mutex), lookup_header_(lookup_file_, number_buckets), lookup_manager_(lookup_file_, header_size), lookup_map_(lookup_header_, lookup_manager_) diff --git a/src/lib/database/databases/block_database.cpp b/src/lib/database/databases/block_database.cpp index 79a148a0e..0f78801d5 100644 --- a/src/lib/database/databases/block_database.cpp +++ b/src/lib/database/databases/block_database.cpp @@ -53,7 +53,7 @@ const file_offset block_database::empty = 0; block_database::block_database(const path& map_filename, const path& index_filename, std::shared_ptr mutex) - : lookup_file_(map_filename, mutex), + : lookup_file_(map_filename, mutex), lookup_header_(lookup_file_, number_buckets), lookup_manager_(lookup_file_, header_size), lookup_map_(lookup_header_, lookup_manager_), @@ -104,7 +104,7 @@ bool block_database::start() return lookup_file_.start() && index_file_.start() && - lookup_header_.start() && + lookup_header_.start() && lookup_manager_.start() && index_manager_.start(); } diff --git a/src/lib/database/databases/blockchain_did_database.cpp b/src/lib/database/databases/blockchain_did_database.cpp index 99a2998ff..92790b6f3 100644 --- a/src/lib/database/databases/blockchain_did_database.cpp +++ b/src/lib/database/databases/blockchain_did_database.cpp @@ -114,17 +114,17 @@ void blockchain_did_database::sync() std::shared_ptr blockchain_did_database::get(const hash_digest& hash) const { - std::shared_ptr detail(nullptr); + std::shared_ptr detail(nullptr); const auto raw_memory = lookup_map_.find(hash); - if(raw_memory) { - const auto memory = REMAP_ADDRESS(raw_memory); - detail = std::make_shared(); - auto deserial = make_deserializer_unsafe(memory); - detail->from_data(deserial); - } - - return detail; + if(raw_memory) { + const auto memory = REMAP_ADDRESS(raw_memory); + detail = std::make_shared(); + auto deserial = make_deserializer_unsafe(memory); + detail->from_data(deserial); + } + + return detail; } @@ -144,29 +144,29 @@ std::shared_ptr> blockchain_did_database::get_histor } - return did_details; + return did_details; } /// std::shared_ptr> blockchain_did_database::get_blockchain_dids() const { - auto vec_acc = std::make_shared>(); - uint64_t i = 0; - for( i = 0; i < number_buckets; i++ ) { - auto memo = lookup_map_.find(i); - //log::debug("get_accounts size=")<size(); - if(memo->size()) - { - const auto action = [&](memory_ptr elem) - { - const auto memory = REMAP_ADDRESS(elem); - auto deserial = make_deserializer_unsafe(memory); - vec_acc->push_back(blockchain_did::factory_from_data(deserial)); - }; - std::for_each(memo->begin(), memo->end(), action); - } - } - return vec_acc; + auto vec_acc = std::make_shared>(); + uint64_t i = 0; + for( i = 0; i < number_buckets; i++ ) { + auto memo = lookup_map_.find(i); + //log::debug("get_accounts size=")<size(); + if(memo->size()) + { + const auto action = [&](memory_ptr elem) + { + const auto memory = REMAP_ADDRESS(elem); + auto deserial = make_deserializer_unsafe(memory); + vec_acc->push_back(blockchain_did::factory_from_data(deserial)); + }; + std::for_each(memo->begin(), memo->end(), action); + } + } + return vec_acc; } void blockchain_did_database::store(const hash_digest& hash, const blockchain_did& sp_detail) @@ -179,7 +179,7 @@ void blockchain_did_database::store(const hash_digest& hash, const blockchain_di const auto sp_size = sp_detail.serialized_size(); #ifdef MVS_DEBUG - log::debug("did_database::store") << sp_detail.to_string(); + log::debug("did_database::store") << sp_detail.to_string(); #endif BITCOIN_ASSERT(sp_size <= max_size_t); const auto value_size = static_cast(sp_size); @@ -189,7 +189,7 @@ void blockchain_did_database::store(const hash_digest& hash, const blockchain_di auto serial = make_serializer(REMAP_ADDRESS(data)); serial.write_data(sp_detail.to_data()); }; - lookup_map_.store(key, write, value_size); + lookup_map_.store(key, write, value_size); } std::shared_ptr blockchain_did_database::update_address_status(const hash_digest &hash,uint32_t status ) diff --git a/src/lib/database/databases/history_database.cpp b/src/lib/database/databases/history_database.cpp index d5ad3183e..4cb4cf37e 100644 --- a/src/lib/database/databases/history_database.cpp +++ b/src/lib/database/databases/history_database.cpp @@ -46,7 +46,7 @@ BC_CONSTEXPR size_t row_record_size = hash_table_record_size(value_ history_database::history_database(const path& lookup_filename, const path& rows_filename, std::shared_ptr mutex) - : lookup_file_(lookup_filename, mutex), + : lookup_file_(lookup_filename, mutex), lookup_header_(lookup_file_, number_buckets), lookup_manager_(lookup_file_, header_size, record_size), lookup_map_(lookup_header_, lookup_manager_), diff --git a/src/lib/database/databases/spend_database.cpp b/src/lib/database/databases/spend_database.cpp index 541955b04..61b25232d 100644 --- a/src/lib/database/databases/spend_database.cpp +++ b/src/lib/database/databases/spend_database.cpp @@ -43,7 +43,7 @@ BC_CONSTEXPR size_t record_size = hash_table_record_size(value_siz spend_database::spend_database(const path& filename, std::shared_ptr mutex) - : lookup_file_(filename, mutex), + : lookup_file_(filename, mutex), lookup_header_(lookup_file_, number_buckets), lookup_manager_(lookup_file_, header_size, record_size), lookup_map_(lookup_header_, lookup_manager_) diff --git a/src/lib/database/databases/transaction_database.cpp b/src/lib/database/databases/transaction_database.cpp index 425e48271..82245dc8f 100644 --- a/src/lib/database/databases/transaction_database.cpp +++ b/src/lib/database/databases/transaction_database.cpp @@ -39,7 +39,7 @@ BC_CONSTEXPR size_t initial_map_file_size = header_size + minimum_slabs_size; transaction_database::transaction_database(const path& map_filename, std::shared_ptr mutex) - : lookup_file_(map_filename, mutex), + : lookup_file_(map_filename, mutex), lookup_header_(lookup_file_, number_buckets), lookup_manager_(lookup_file_, header_size), lookup_map_(lookup_header_, lookup_manager_) diff --git a/src/lib/database/memory/memory_map.cpp b/src/lib/database/memory/memory_map.cpp index e883556a1..70b07a8b3 100644 --- a/src/lib/database/memory/memory_map.cpp +++ b/src/lib/database/memory/memory_map.cpp @@ -46,7 +46,7 @@ #include #include -// memory_map is be able to support 32 bit but because the database +// memory_map is be able to support 32 bit but because the database // requires a larger file this is not validated or supported. #ifndef __ANDROID__ static_assert(sizeof(void*) == sizeof(uint64_t), "Not a 64 bit system!"); diff --git a/src/lib/database/mman-win32/mman.c b/src/lib/database/mman-win32/mman.c index e3b4d828f..fe9479963 100644 --- a/src/lib/database/mman-win32/mman.c +++ b/src/lib/database/mman-win32/mman.c @@ -96,7 +96,7 @@ void* mmap(void* addr, size_t len, int prot, int flags, int fildes, oft__ off) return MAP_FAILED; } - const HANDLE handle = ((flags & MAP_ANONYMOUS) == 0) ? + const HANDLE handle = ((flags & MAP_ANONYMOUS) == 0) ? (HANDLE)_get_osfhandle(fildes) : INVALID_HANDLE_VALUE; if ((flags & MAP_ANONYMOUS) == 0 && handle == INVALID_HANDLE_VALUE) diff --git a/src/lib/database/primitives/record_manager.cpp b/src/lib/database/primitives/record_manager.cpp index 0241a4081..aa0d1d617 100644 --- a/src/lib/database/primitives/record_manager.cpp +++ b/src/lib/database/primitives/record_manager.cpp @@ -43,7 +43,7 @@ namespace libbitcoin { namespace database { - + // TODO: guard against overflows. record_manager::record_manager(memory_map& file, file_offset header_size, diff --git a/src/lib/database/result/account_address_result.cpp b/src/lib/database/result/account_address_result.cpp index 5847a9332..25935c693 100644 --- a/src/lib/database/result/account_address_result.cpp +++ b/src/lib/database/result/account_address_result.cpp @@ -30,7 +30,7 @@ namespace database { template std::shared_ptr deserialize_account_address_detail(const Iterator first) { - auto detail = std::make_shared(); + auto detail = std::make_shared(); auto deserial = make_deserializer_unsafe(first); detail->from_data(deserial); return detail; @@ -44,13 +44,13 @@ account_address_result::account_address_result(const memory_ptr slab) std::shared_ptr account_address_result::get_account_address_detail() const { //BITCOIN_ASSERT(get_slab()); - std::shared_ptr addr(nullptr); - if(get_slab()) - { - const auto memory = REMAP_ADDRESS(get_slab()); - addr = deserialize_account_address_detail(memory); - } - return addr; + std::shared_ptr addr(nullptr); + if(get_slab()) + { + const auto memory = REMAP_ADDRESS(get_slab()); + addr = deserialize_account_address_detail(memory); + } + return addr; } } // namespace database } // namespace libbitcoin diff --git a/src/lib/database/result/account_result.cpp b/src/lib/database/result/account_result.cpp index 2c572784b..a6af945e8 100644 --- a/src/lib/database/result/account_result.cpp +++ b/src/lib/database/result/account_result.cpp @@ -30,7 +30,7 @@ namespace database { template std::shared_ptr deserialize_account_detail(const Iterator first) { - auto detail = std::make_shared(); + auto detail = std::make_shared(); auto deserial = make_deserializer_unsafe(first); detail->from_data(deserial); return detail; @@ -43,13 +43,13 @@ account_result::account_result(const memory_ptr slab) std::shared_ptr account_result::get_account_detail() const { //BITCOIN_ASSERT(get_slab()); - std::shared_ptr sp_acc(nullptr); - if(get_slab()) - { - const auto memory = REMAP_ADDRESS(get_slab()); - sp_acc = deserialize_account_detail(memory); - } - return sp_acc; + std::shared_ptr sp_acc(nullptr); + if(get_slab()) + { + const auto memory = REMAP_ADDRESS(get_slab()); + sp_acc = deserialize_account_detail(memory); + } + return sp_acc; } } // namespace database } // namespace libbitcoin diff --git a/src/lib/database/result/asset_result.cpp b/src/lib/database/result/asset_result.cpp index a9822aa2b..91e37c218 100644 --- a/src/lib/database/result/asset_result.cpp +++ b/src/lib/database/result/asset_result.cpp @@ -30,10 +30,10 @@ namespace database { template std::shared_ptr deserialize_account_detail(const Iterator first) { - auto detail = std::make_shared(); - auto deserial = make_deserializer_unsafe(first); - detail->from_data(deserial); - return detail; + auto detail = std::make_shared(); + auto deserial = make_deserializer_unsafe(first); + detail->from_data(deserial); + return detail; } asset_result::asset_result(const memory_ptr slab) : base_result(slab) @@ -43,13 +43,13 @@ asset_result::asset_result(const memory_ptr slab) std::shared_ptr asset_result::get_asset_detail() const { //BITCOIN_ASSERT(get_slab()); - std::shared_ptr sp_acc(nullptr); - if(get_slab()) - { - const auto memory = REMAP_ADDRESS(get_slab()); - sp_acc = deserialize_account_detail(memory); - } - return sp_acc; + std::shared_ptr sp_acc(nullptr); + if(get_slab()) + { + const auto memory = REMAP_ADDRESS(get_slab()); + sp_acc = deserialize_account_detail(memory); + } + return sp_acc; } diff --git a/src/lib/explorer/callback_state.cpp b/src/lib/explorer/callback_state.cpp index 8078aac35..a86c51046 100644 --- a/src/lib/explorer/callback_state.cpp +++ b/src/lib/explorer/callback_state.cpp @@ -32,12 +32,12 @@ namespace libbitcoin { namespace explorer { - + callback_state::callback_state(std::ostream& error, std::ostream& output, const encoding_engine engine) - : stopped_(true), refcount_(0), result_(console_result::okay), + : stopped_(true), refcount_(0), result_(console_result::okay), engine_(engine), error_(error), output_(output) - + { } diff --git a/src/lib/explorer/commands/fetch-stealth.cpp b/src/lib/explorer/commands/fetch-stealth.cpp index 4a0f60bd6..4022fb182 100644 --- a/src/lib/explorer/commands/fetch-stealth.cpp +++ b/src/lib/explorer/commands/fetch-stealth.cpp @@ -81,6 +81,6 @@ console_result fetch_stealth::invoke(std::ostream& output, std::ostream& error) return state.get_result(); } -} //namespace commands -} //namespace explorer -} //namespace libbitcoin +} //namespace commands +} //namespace explorer +} //namespace libbitcoin diff --git a/src/lib/explorer/commands/help.cpp b/src/lib/explorer/commands/help.cpp index 09249e303..ac3286cd4 100644 --- a/src/lib/explorer/commands/help.cpp +++ b/src/lib/explorer/commands/help.cpp @@ -57,6 +57,6 @@ console_result help::invoke(std::ostream& output, std::ostream& error) return console_result::okay; } -} //namespace commands -} //namespace explorer -} //namespace libbitcoin +} //namespace commands +} //namespace explorer +} //namespace libbitcoin diff --git a/src/lib/explorer/commands/offline/stealth-decode.cpp b/src/lib/explorer/commands/offline/stealth-decode.cpp index aea513f13..a10d2aaef 100644 --- a/src/lib/explorer/commands/offline/stealth-decode.cpp +++ b/src/lib/explorer/commands/offline/stealth-decode.cpp @@ -46,6 +46,6 @@ console_result stealth_decode::invoke(std::ostream& output, return console_result::okay; } -} //namespace commands -} //namespace explorer -} //namespace libbitcoin +} //namespace commands +} //namespace explorer +} //namespace libbitcoin diff --git a/src/lib/explorer/commands/offline/stealth-encode.cpp b/src/lib/explorer/commands/offline/stealth-encode.cpp index a4f09fd37..5beb62087 100644 --- a/src/lib/explorer/commands/offline/stealth-encode.cpp +++ b/src/lib/explorer/commands/offline/stealth-encode.cpp @@ -69,6 +69,6 @@ console_result stealth_encode::invoke(std::ostream& output, return console_result::okay; } -} //namespace commands -} //namespace explorer -} //namespace libbitcoin +} //namespace commands +} //namespace explorer +} //namespace libbitcoin diff --git a/src/lib/explorer/commands/offline/stealth-public.cpp b/src/lib/explorer/commands/offline/stealth-public.cpp index 2661b711c..544224909 100644 --- a/src/lib/explorer/commands/offline/stealth-public.cpp +++ b/src/lib/explorer/commands/offline/stealth-public.cpp @@ -49,6 +49,6 @@ console_result stealth_public::invoke(std::ostream& output, return console_result::okay; } -} //namespace commands -} //namespace explorer -} //namespace libbitcoin +} //namespace commands +} //namespace explorer +} //namespace libbitcoin diff --git a/src/lib/explorer/commands/offline/stealth-secret.cpp b/src/lib/explorer/commands/offline/stealth-secret.cpp index 153d11eef..cc7e25419 100644 --- a/src/lib/explorer/commands/offline/stealth-secret.cpp +++ b/src/lib/explorer/commands/offline/stealth-secret.cpp @@ -50,6 +50,6 @@ console_result stealth_secret::invoke(std::ostream& output, return console_result::okay; } -} //namespace commands -} //namespace explorer -} //namespace libbitcoin +} //namespace commands +} //namespace explorer +} //namespace libbitcoin diff --git a/src/lib/explorer/commands/offline/stealth-shared.cpp b/src/lib/explorer/commands/offline/stealth-shared.cpp index cf6b579b2..8c718affd 100644 --- a/src/lib/explorer/commands/offline/stealth-shared.cpp +++ b/src/lib/explorer/commands/offline/stealth-shared.cpp @@ -38,7 +38,7 @@ console_result stealth_shared::invoke(std::ostream& output, // Bound parameters. const auto& secret = get_secret_argument(); const auto& pubkey = get_pubkey_argument(); - + ec_compressed product(pubkey); if (!bc::ec_multiply(product, secret)) { @@ -52,6 +52,6 @@ console_result stealth_shared::invoke(std::ostream& output, return console_result::okay; } -} //namespace commands -} //namespace explorer -} //namespace libbitcoin +} //namespace commands +} //namespace explorer +} //namespace libbitcoin diff --git a/src/lib/explorer/commands/offline/tx-decode.cpp b/src/lib/explorer/commands/offline/tx-decode.cpp index e6d8b978e..c178c197a 100644 --- a/src/lib/explorer/commands/offline/tx-decode.cpp +++ b/src/lib/explorer/commands/offline/tx-decode.cpp @@ -46,6 +46,6 @@ console_result tx_decode::invoke(std::ostream& output, std::ostream& error) return console_result::okay; } -} //namespace commands -} //namespace explorer -} //namespace libbitcoin +} //namespace commands +} //namespace explorer +} //namespace libbitcoin diff --git a/src/lib/explorer/commands/offline_commands_impl.cpp b/src/lib/explorer/commands/offline_commands_impl.cpp index e06772ba2..5e30bf51d 100644 --- a/src/lib/explorer/commands/offline_commands_impl.cpp +++ b/src/lib/explorer/commands/offline_commands_impl.cpp @@ -59,7 +59,7 @@ bw::word_list get_mnemonic_new(const bw::dictionary_list& language, const data_c //mnemonic-to-seed -data_chunk get_mnemonic_to_seed(const bw::dictionary_list& language, +data_chunk get_mnemonic_to_seed(const bw::dictionary_list& language, const bw::word_list& words, std::string passphrase) { @@ -151,6 +151,6 @@ bw::hd_private get_hd_new(const data_chunk& seed, uint32_t version) return private_key; } -} //namespace commands -} //namespace explorer -} //namespace libbitcoin +} //namespace commands +} //namespace explorer +} //namespace libbitcoin diff --git a/src/lib/explorer/commands/send-tx.cpp b/src/lib/explorer/commands/send-tx.cpp index a84df14ea..161cbd97c 100644 --- a/src/lib/explorer/commands/send-tx.cpp +++ b/src/lib/explorer/commands/send-tx.cpp @@ -67,6 +67,6 @@ console_result send_tx::invoke(std::ostream& output, std::ostream& error) return state.get_result(); } -} //namespace commands -} //namespace explorer -} //namespace libbitcoin +} //namespace commands +} //namespace explorer +} //namespace libbitcoin diff --git a/src/lib/explorer/commands/settings.cpp b/src/lib/explorer/commands/settings.cpp index 7766a7c1f..297f86e90 100644 --- a/src/lib/explorer/commands/settings.cpp +++ b/src/lib/explorer/commands/settings.cpp @@ -64,15 +64,15 @@ console_result commands::settings::invoke(std::ostream& output, serialize(get_network_identifier_setting()); list["network.connect_retries"] = serialize(get_network_connect_retries_setting()); - list["network.connect_timeout_seconds"] = + list["network.connect_timeout_seconds"] = serialize(get_network_connect_timeout_seconds_setting()); list["network.channel_handshake_seconds"] = serialize(get_network_channel_handshake_seconds_setting()); list["network.hosts_file"] = get_network_hosts_file_setting().string(); - list["network.debug_file"] = + list["network.debug_file"] = get_network_debug_file_setting().string(); - list["network.error_file"] = + list["network.error_file"] = get_network_error_file_setting().string(); network::settings settings(bc::settings::mainnet); @@ -94,13 +94,13 @@ console_result commands::settings::invoke(std::ostream& output, serialize(get_server_connect_timeout_seconds_setting()); list["server.server_public_key"] = serialize(get_server_server_public_key_setting()); - list["server.client_private_key"] = + list["server.client_private_key"] = serialize(get_server_client_private_key_setting()); write_stream(output, json_helper().prop_tree(list), encoding); return console_result::okay; } -} //namespace commands -} //namespace explorer -} //namespace libbitcoin +} //namespace commands +} //namespace explorer +} //namespace libbitcoin diff --git a/src/lib/explorer/commands/validate-tx.cpp b/src/lib/explorer/commands/validate-tx.cpp index a0afb6e9b..66b61cae5 100644 --- a/src/lib/explorer/commands/validate-tx.cpp +++ b/src/lib/explorer/commands/validate-tx.cpp @@ -79,6 +79,6 @@ console_result validate_tx::invoke(std::ostream& output, return state.get_result(); } -} //namespace commands -} //namespace explorer -} //namespace libbitcoin +} //namespace commands +} //namespace explorer +} //namespace libbitcoin diff --git a/src/lib/explorer/config/byte.cpp b/src/lib/explorer/config/byte.cpp index 470d9e1a4..155061620 100644 --- a/src/lib/explorer/config/byte.cpp +++ b/src/lib/explorer/config/byte.cpp @@ -56,14 +56,14 @@ byte::byte(const byte& other) byte::operator uint8_t() const { - return value_; + return value_; } std::istream& operator>>(std::istream& input, byte& argument) { std::string decimal; input >> decimal; - + // We have this byte class only because deserialization doesn't // treat 8 bit values as decimal numbers (unlike 16+ bit numbers). diff --git a/src/lib/explorer/config/endorsement.cpp b/src/lib/explorer/config/endorsement.cpp index a6992039a..c9663d5ac 100644 --- a/src/lib/explorer/config/endorsement.cpp +++ b/src/lib/explorer/config/endorsement.cpp @@ -40,7 +40,7 @@ static bool decode_endorsement(bc::endorsement& endorsement, const std::string& encoded) { bc::endorsement decoded; - if (!decode_base16(decoded, encoded) || + if (!decode_base16(decoded, encoded) || (decoded.size() > max_endorsement_size)) return false; diff --git a/src/lib/explorer/config/input.cpp b/src/lib/explorer/config/input.cpp index 276108257..83d50a3da 100644 --- a/src/lib/explorer/config/input.cpp +++ b/src/lib/explorer/config/input.cpp @@ -88,7 +88,7 @@ input::input(const chain::input_point& value) input::operator const tx_input_type&() const { - return value_; + return value_; } std::istream& operator>>(std::istream& stream, input& argument) diff --git a/src/lib/explorer/config/point.cpp b/src/lib/explorer/config/point.cpp index c7f1a6c5c..efda8c8d1 100644 --- a/src/lib/explorer/config/point.cpp +++ b/src/lib/explorer/config/point.cpp @@ -85,7 +85,7 @@ point::point(const point& other) point::operator const chain::output_point&() const { - return value_; + return value_; } std::istream& operator>>(std::istream& input, point& argument) diff --git a/src/lib/explorer/config/signature.cpp b/src/lib/explorer/config/signature.cpp index c64a595d9..39dc9d404 100644 --- a/src/lib/explorer/config/signature.cpp +++ b/src/lib/explorer/config/signature.cpp @@ -41,7 +41,7 @@ static bool decode_signature(wallet::message_signature& signature, { // There is no bc::decode_base64 array-based override. data_chunk decoded; - if (!decode_base64(decoded, encoded) || + if (!decode_base64(decoded, encoded) || (decoded.size() != wallet::message_signature_size)) return false; diff --git a/src/lib/explorer/config/wrapper.cpp b/src/lib/explorer/config/wrapper.cpp index b28795fa9..932fc3fb7 100644 --- a/src/lib/explorer/config/wrapper.cpp +++ b/src/lib/explorer/config/wrapper.cpp @@ -82,7 +82,7 @@ std::istream& operator>>(std::istream& input, wrapper& argument) { std::string hexcode; input >> hexcode; - + // The checksum is validated here. if (!unwrap(argument.value_, base16(hexcode))) { diff --git a/src/lib/explorer/display.cpp b/src/lib/explorer/display.cpp index 72228a806..87a3df794 100644 --- a/src/lib/explorer/display.cpp +++ b/src/lib/explorer/display.cpp @@ -69,7 +69,7 @@ static std::string fixup_boost_po_what_en(const std::string& what) return message; } -void display_invalid_parameter(std::ostream& stream, +void display_invalid_parameter(std::ostream& stream, const std::string& message) { stream << format(BX_INVALID_PARAMETER) % fixup_boost_po_what_en(message); @@ -77,9 +77,9 @@ void display_invalid_parameter(std::ostream& stream, void display_usage(std::ostream& stream) { - stream + stream << std::endl << BX_COMMAND_USAGE << std::endl - << format(BX_VERSION_MESSAGE) % + << format(BX_VERSION_MESSAGE) % MVS_EXPLORER_VERSION << std::endl << BX_COMMANDS_HEADER << std::endl << std::endl; diff --git a/src/lib/explorer/extensions/account_info.cpp b/src/lib/explorer/extensions/account_info.cpp index 7456151b5..666c87f14 100644 --- a/src/lib/explorer/extensions/account_info.cpp +++ b/src/lib/explorer/extensions/account_info.cpp @@ -42,8 +42,8 @@ account_info::account_info(blockchain::block_chain_impl& blockchain, std::string { } account_info::account_info(blockchain::block_chain_impl& blockchain, std::string& passphrase, - account& meta, std::vector& addr_vec, std::vector& asset_vec): - blockchain_(blockchain), passphrase_(passphrase), meta_(meta), addr_vec_(addr_vec), asset_vec_(asset_vec) + account& meta, std::vector& addr_vec, std::vector& asset_vec): + blockchain_(blockchain), passphrase_(passphrase), meta_(meta), addr_vec_(addr_vec), asset_vec_(asset_vec) { } @@ -64,20 +64,20 @@ bool account_info::from_data(reader& source) meta_.from_data(source); account_address addr; - uint32_t addr_size = source.read_4_bytes_little_endian(); - while(addr_size--) { - addr.reset(); - addr.from_data(source); - addr_vec_.push_back(addr); - } + uint32_t addr_size = source.read_4_bytes_little_endian(); + while(addr_size--) { + addr.reset(); + addr.from_data(source); + addr_vec_.push_back(addr); + } asset_detail detail; - uint32_t asset_size = source.read_4_bytes_little_endian(); - while(asset_size--) { - detail.reset(); - detail.from_data(source); - asset_vec_.push_back(detail); - } + uint32_t asset_size = source.read_4_bytes_little_endian(); + while(asset_size--) { + detail.reset(); + detail.from_data(source); + asset_vec_.push_back(detail); + } return true; } @@ -102,19 +102,19 @@ void account_info::to_data(writer& sink) const { meta_.to_data(sink); // account_address vector - sink.write_4_bytes_little_endian(addr_vec_.size()); - if(addr_vec_.size()){ - for(auto& each : addr_vec_) { - each.to_data(sink); - } - } + sink.write_4_bytes_little_endian(addr_vec_.size()); + if(addr_vec_.size()){ + for(auto& each : addr_vec_) { + each.to_data(sink); + } + } // account asset vector - sink.write_4_bytes_little_endian(asset_vec_.size()); - if(asset_vec_.size()) { - for(auto& each : asset_vec_) { - each.to_data(sink); - } - } + sink.write_4_bytes_little_endian(asset_vec_.size()); + if(asset_vec_.size()) { + for(auto& each : asset_vec_) { + each.to_data(sink); + } + } } account account_info::get_account() const { @@ -159,12 +159,12 @@ void account_info::encrypt() { auto src_data = to_data(); append_checksum(src_data); - data_chunk pass_chunk(passphrase_.begin(), passphrase_.end()); + data_chunk pass_chunk(passphrase_.begin(), passphrase_.end()); aes256_common_encrypt(src_data, pass_chunk, data_); } void account_info::decrypt(std::string& hexcode) { - data_chunk pass_chunk(passphrase_.begin(), passphrase_.end()); + data_chunk pass_chunk(passphrase_.begin(), passphrase_.end()); data_chunk encrypt_data = base16(hexcode); aes256_common_decrypt(encrypt_data, pass_chunk, data_); if(!verify_checksum(data_)) diff --git a/src/lib/explorer/extensions/command_assistant.cpp b/src/lib/explorer/extensions/command_assistant.cpp index b7ea9b3fb..b9ab8f7b4 100644 --- a/src/lib/explorer/extensions/command_assistant.cpp +++ b/src/lib/explorer/extensions/command_assistant.cpp @@ -1,5 +1,5 @@ /** - * Copyright (c) 2016-2018 mvs developers + * Copyright (c) 2016-2018 mvs developers * * This file is part of metaverse-explorer. * diff --git a/src/lib/explorer/extensions/commands/didsendasset.cpp b/src/lib/explorer/extensions/commands/didsendasset.cpp index 397e6f63a..d45cb5632 100644 --- a/src/lib/explorer/extensions/commands/didsendasset.cpp +++ b/src/lib/explorer/extensions/commands/didsendasset.cpp @@ -51,7 +51,7 @@ console_result didsendasset::invoke(Json::Value& jv_output, tempaddress = argument_.did; } else { - tempaddress = get_address_from_did(argument_.did,blockchain); + tempaddress = get_address_from_did(argument_.did,blockchain); attach.set_to_did(argument_.did); attach.set_version(DID_ATTACH_VERIFY_VERSION); } diff --git a/src/lib/explorer/extensions/commands/didsendassetfrom.cpp b/src/lib/explorer/extensions/commands/didsendassetfrom.cpp index b5285fc43..f91c2ad56 100644 --- a/src/lib/explorer/extensions/commands/didsendassetfrom.cpp +++ b/src/lib/explorer/extensions/commands/didsendassetfrom.cpp @@ -49,7 +49,7 @@ console_result didsendassetfrom::invoke(Json::Value& jv_output, fromaddress = argument_.fromdid; } else { - fromaddress = get_address_from_did(argument_.fromdid, blockchain); + fromaddress = get_address_from_did(argument_.fromdid, blockchain); attach.set_from_did(argument_.fromdid); attach.set_version(DID_ATTACH_VERIFY_VERSION); } @@ -59,7 +59,7 @@ console_result didsendassetfrom::invoke(Json::Value& jv_output, toaddress = argument_.todid; } else { - toaddress = get_address_from_did(argument_.todid,blockchain); + toaddress = get_address_from_did(argument_.todid,blockchain); attach.set_to_did(argument_.todid); attach.set_version(DID_ATTACH_VERIFY_VERSION); } diff --git a/src/lib/explorer/extensions/commands/didsendfrom.cpp b/src/lib/explorer/extensions/commands/didsendfrom.cpp index 3e34aef1f..7c14e8f59 100644 --- a/src/lib/explorer/extensions/commands/didsendfrom.cpp +++ b/src/lib/explorer/extensions/commands/didsendfrom.cpp @@ -62,7 +62,7 @@ console_result didsendfrom::invoke(Json::Value& jv_output, if (blockchain.is_valid_address(argument_.todid)) { toaddress = argument_.todid; } - else { + else { toaddress = get_address_from_did(argument_.todid,blockchain); attach.set_to_did(argument_.todid); attach.set_version(DID_ATTACH_VERIFY_VERSION); diff --git a/src/lib/explorer/extensions/commands/didsendmore.cpp b/src/lib/explorer/extensions/commands/didsendmore.cpp index 0a1b935dd..c512bb792 100644 --- a/src/lib/explorer/extensions/commands/didsendmore.cpp +++ b/src/lib/explorer/extensions/commands/didsendmore.cpp @@ -41,8 +41,8 @@ console_result didsendmore::invoke (Json::Value& jv_output, if (!changesymbol.empty()) { auto address = changesymbol; - if(!blockchain.is_valid_address(changesymbol)) - address = get_address_from_did(changesymbol,blockchain); + if(!blockchain.is_valid_address(changesymbol)) + address = get_address_from_did(changesymbol,blockchain); } // receiver diff --git a/src/lib/explorer/extensions/commands/getblock.cpp b/src/lib/explorer/extensions/commands/getblock.cpp index 62ac5cd73..1fa552b57 100644 --- a/src/lib/explorer/extensions/commands/getblock.cpp +++ b/src/lib/explorer/extensions/commands/getblock.cpp @@ -1,5 +1,5 @@ /** - * Copyright (c) 2016-2018 mvs developers + * Copyright (c) 2016-2018 mvs developers * * This file is part of metaverse-explorer. * diff --git a/src/lib/explorer/extensions/commands/getblockheader.cpp b/src/lib/explorer/extensions/commands/getblockheader.cpp index 44485ba63..251118a92 100644 --- a/src/lib/explorer/extensions/commands/getblockheader.cpp +++ b/src/lib/explorer/extensions/commands/getblockheader.cpp @@ -66,15 +66,15 @@ console_result getblockheader::invoke(Json::Value& jv_output, { auto&& jheader = config::json_helper(get_api_version()).prop_tree(header); - if( !jheader.isObject() - || !jheader["result"].isObject() - || !jheader["result"]["hash"].isString()) { + if( !jheader.isObject() + || !jheader["result"].isObject() + || !jheader["result"]["hash"].isString()) { - throw block_hash_get_exception{"getbestblockhash got parser exception."}; - } + throw block_hash_get_exception{"getbestblockhash got parser exception."}; + } if (option_.is_getbestblockhash) { - auto&& blockhash = jheader["result"]["hash"].asString(); + auto&& blockhash = jheader["result"]["hash"].asString(); jv_output = blockhash; } else { if (get_api_version() == 1) { diff --git a/src/lib/explorer/extensions/commands/getdid.cpp b/src/lib/explorer/extensions/commands/getdid.cpp index 1acdca7e6..eb982b007 100644 --- a/src/lib/explorer/extensions/commands/getdid.cpp +++ b/src/lib/explorer/extensions/commands/getdid.cpp @@ -34,7 +34,7 @@ console_result getdid::invoke (Json::Value& jv_output, libbitcoin::server::server_node& node) { Json::Value json_value; - + auto& blockchain = node.chain_impl(); if(option_.symbol.empty()) @@ -42,8 +42,8 @@ console_result getdid::invoke (Json::Value& jv_output, auto sh_vec = blockchain.get_registered_dids(); // add blockchain dids - for (auto& elem: *sh_vec) - json_value.append(elem.get_symbol()); + for (auto& elem: *sh_vec) + json_value.append(elem.get_symbol()); if (get_api_version() == 1 && json_value.isNull()) { //compatible for v1 jv_output["dids"] = ""; @@ -60,7 +60,7 @@ console_result getdid::invoke (Json::Value& jv_output, { didSymbol = blockchain.get_did_from_address(didSymbol); if(didSymbol.empty()) - throw address_not_bound_did_exception{"address is not binded with some did on the blockchain"}; + throw address_not_bound_did_exception{"address is not binded with some did on the blockchain"}; } // check did symbol @@ -86,7 +86,7 @@ console_result getdid::invoke (Json::Value& jv_output, jv_output["addresses"] = ""; } else { - jv_output["did"] = didSymbol; + jv_output["did"] = didSymbol; jv_output["addresses"] = json_value; } diff --git a/src/lib/explorer/extensions/commands/importaccount.cpp b/src/lib/explorer/extensions/commands/importaccount.cpp index 0d217942e..4a3ee33b0 100644 --- a/src/lib/explorer/extensions/commands/importaccount.cpp +++ b/src/lib/explorer/extensions/commands/importaccount.cpp @@ -42,9 +42,9 @@ console_result importaccount::invoke(Json::Value& jv_output, throw account_existed_exception{"account already exist"}; #ifdef NDEBUG - if (auth_.name.length() > 128 || auth_.name.length() < 3 || - option_.passwd.length() > 128 || option_.passwd.length() < 6) - throw argument_exceed_limit_exception{"name length in [3, 128], password length in [6, 128]"}; + if (auth_.name.length() > 128 || auth_.name.length() < 3 || + option_.passwd.length() > 128 || option_.passwd.length() < 6) + throw argument_exceed_limit_exception{"name length in [3, 128], password length in [6, 128]"}; #endif if (argument_.words.size() == 1) diff --git a/src/lib/explorer/extensions/commands/listbalances.cpp b/src/lib/explorer/extensions/commands/listbalances.cpp index d2abcc0e4..13efb79bb 100644 --- a/src/lib/explorer/extensions/commands/listbalances.cpp +++ b/src/lib/explorer/extensions/commands/listbalances.cpp @@ -89,9 +89,9 @@ console_result listbalances::invoke(Json::Value& jv_output, } if (get_api_version() == 1 && all_balances.isNull()) { //compatible for v1 - aroot["balances"] = ""; + aroot["balances"] = ""; } else { - aroot["balances"] = all_balances; + aroot["balances"] = all_balances; } return console_result::okay; diff --git a/src/lib/explorer/extensions/exception.cpp b/src/lib/explorer/extensions/exception.cpp index 1f114607b..ab6b84ca3 100644 --- a/src/lib/explorer/extensions/exception.cpp +++ b/src/lib/explorer/extensions/exception.cpp @@ -25,7 +25,7 @@ std::ostream& operator<<(std::ostream& out, const explorer_exception& ex) } void relay_exception(std::stringstream& ss) -{ +{ try { Json::Reader reader; diff --git a/src/lib/explorer/extensions/node_method_wrapper.cpp b/src/lib/explorer/extensions/node_method_wrapper.cpp index 2b0fac7b2..11e1438b0 100644 --- a/src/lib/explorer/extensions/node_method_wrapper.cpp +++ b/src/lib/explorer/extensions/node_method_wrapper.cpp @@ -1,5 +1,5 @@ /** - * Copyright (c) 2016-2018 mvs developers + * Copyright (c) 2016-2018 mvs developers * * This file is part of metaverse-explorer. * @@ -27,16 +27,16 @@ namespace commands { // ----------------------------- checker methods ------------------------------ -void administrator_required_checker(bc::server::server_node& node, +void administrator_required_checker(bc::server::server_node& node, const std::string& name, const std::string& auth) { auto& blockchain = node.chain_impl(); - // administrator_required option is true - if (node.server_settings().administrator_required) { - if(!blockchain.is_admin_account(name)) + // administrator_required option is true + if (node.server_settings().administrator_required) { + if(!blockchain.is_admin_account(name)) throw account_authority_exception{"Administrator name must be [administerator],incorrect vocabulary @_@."}; - blockchain.is_account_passwd_valid(name, auth); + blockchain.is_account_passwd_valid(name, auth); } } diff --git a/src/lib/network/acceptor.cpp b/src/lib/network/acceptor.cpp index 4241cf3e4..f065686e8 100644 --- a/src/lib/network/acceptor.cpp +++ b/src/lib/network/acceptor.cpp @@ -134,14 +134,14 @@ void acceptor::accept(accept_handler handler) void acceptor::safe_accept(socket::ptr socket, accept_handler handler) { // Critical Section (external) - /////////////////////////////////////////////////////////////////////////// + /////////////////////////////////////////////////////////////////////////// const auto locked = socket->get_socket(); // async_accept will not invoke the handler within this function. acceptor_->async_accept(locked->get(), std::bind(&acceptor::handle_accept, shared_from_this(), _1, socket, handler)); - /////////////////////////////////////////////////////////////////////////// + /////////////////////////////////////////////////////////////////////////// } void acceptor::handle_accept(const boost_code& ec, socket::ptr socket, diff --git a/src/lib/network/channel.cpp b/src/lib/network/channel.cpp index e88a615c5..7f8c476b2 100644 --- a/src/lib/network/channel.cpp +++ b/src/lib/network/channel.cpp @@ -44,7 +44,7 @@ static deadline::ptr alarm(threadpool& pool, const asio::duration& duration) // TODO: configure settings.protocol_maximum and settings.protocol_minimum. // Limit to version::limit::maximum and version::limit::minimum respectively -// and if protocol_maximum is then below protocol_minimum return a failure. +// and if protocol_maximum is then below protocol_minimum return a failure. // On handshake send peer version.maxiumum and on receipt of protocol_peer // if it is below protocol_minimum drop the channel, otherwise set // protocol_version to the lesser of protocol_maximum and protocol_peer. @@ -114,8 +114,8 @@ void channel::invoke_protocol_start_handler(const code& ec) if (!protocol_start_handler_) return; if (ec) { - protocol_start_handler_ = nullptr; - return; + protocol_start_handler_ = nullptr; + return; } func = std::move(protocol_start_handler_); @@ -130,7 +130,7 @@ void channel::invoke_protocol_start_handler(const code& ec) // It is possible that this may be called multiple times. void channel::handle_stopping() { - invoke_protocol_start_handler(error::channel_stopped); + invoke_protocol_start_handler(error::channel_stopped); expiration_->stop(); inactivity_->stop(); } @@ -152,7 +152,7 @@ void channel::start_expiration() std::bind(&channel::handle_expiration, shared_from_base(), _1)); if (stopped()) - expiration_->stop(); + expiration_->stop(); } void channel::handle_expiration(const code& ec) @@ -177,7 +177,7 @@ void channel::start_inactivity() std::bind(&channel::handle_inactivity, shared_from_base(), _1)); if (stopped()) - inactivity_->stop(); + inactivity_->stop(); } void channel::handle_inactivity(const code& ec) diff --git a/src/lib/network/connections.cpp b/src/lib/network/connections.cpp index 4e039080d..bc19d4b9e 100644 --- a/src/lib/network/connections.cpp +++ b/src/lib/network/connections.cpp @@ -55,7 +55,7 @@ void connections::stop(const code& ec) //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ mutex_.unlock_upgrade_and_lock(); stopped_ = true; - mutex_.unlock_and_lock_upgrade(); + mutex_.unlock_and_lock_upgrade(); //--------------------------------------------------------------------- // Once stopped this list cannot change, but must copy to escape lock. @@ -103,15 +103,15 @@ void connections::exists(const authority& address, truth_handler handler) const config::authority::list connections::authority_list() { - config::authority::list address_list; - address_list.reserve(channels_.size()); - mutex_.lock_upgrade(); - std::find_if(channels_.begin(), channels_.end(), [&address_list](channel::ptr channel){ - address_list.push_back(channel->authority()); - return false; - }); - mutex_.unlock_upgrade(); - return address_list; + config::authority::list address_list; + address_list.reserve(channels_.size()); + mutex_.lock_upgrade(); + std::find_if(channels_.begin(), channels_.end(), [&address_list](channel::ptr channel){ + address_list.push_back(channel->authority()); + return false; + }); + mutex_.unlock_upgrade(); + return address_list; } bool connections::safe_remove(channel::ptr channel) diff --git a/src/lib/network/connector.cpp b/src/lib/network/connector.cpp index a6a6c7236..88a942a39 100644 --- a/src/lib/network/connector.cpp +++ b/src/lib/network/connector.cpp @@ -36,7 +36,7 @@ namespace libbitcoin { namespace network { #define NAME "connector" - + using namespace bc::config; using namespace std::placeholders; @@ -101,7 +101,7 @@ bool connector::stopped() // public: void connector::connect(const endpoint& endpoint, connect_handler handler - , resolve_handler h) + , resolve_handler h) { connect(endpoint.host(), endpoint.port(), handler, h); } @@ -161,12 +161,12 @@ static asio::ipv6 to_boost_address(const message::ip_address& in) // public: void connector::connect(const authority& authority, connect_handler handler - , resolve_handler h) + , resolve_handler h) { // connect(authority.to_hostname(), authority.port(), handler, h); - auto ip = to_boost_address(authority.ip()); - auto ipv4_hostname = to_ipv4_hostname(ip); - connect(ipv4_hostname.empty() ? to_ipv6_hostname(ip) : ipv4_hostname, authority.port(), handler, h); + auto ip = to_boost_address(authority.ip()); + auto ipv4_hostname = to_ipv4_hostname(ip); + connect(ipv4_hostname.empty() ? to_ipv6_hostname(ip) : ipv4_hostname, authority.port(), handler, h); } // public: @@ -203,15 +203,15 @@ void connector::connect(const std::string& hostname, uint16_t port, void connector::handle_resolve(const boost_code& ec, asio::iterator iterator, connect_handler handler, resolve_handler h) { - auto it = iterator; - asio::iterator end; - if (h) - { - while(it != end){ - h(*it); - ++it; - } - } + auto it = iterator; + asio::iterator end; + if (h) + { + while(it != end){ + h(*it); + ++it; + } + } // Critical Section /////////////////////////////////////////////////////////////////////////// mutex_.lock_shared(); @@ -237,23 +237,23 @@ void connector::handle_resolve(const boost_code& ec, asio::iterator iterator, const auto timeout = settings_.connect_timeout(); const auto timer = std::make_shared(pool_, timeout); const auto socket = std::make_shared(pool_); - + // Retain a socket reference until connected, allowing connect cancelation. pending_.store(socket); - + // Manage the socket-timer race, terminating if either fails. const auto handle_connect = synchronize(handler, 1, NAME, false); - + // This is branch #1 of the connnect sequence. timer->start( std::bind(&connector::handle_timer, shared_from_this(), _1, socket, handle_connect)); safe_connect(resolver_iterator, socket, timer, handle_connect); }; - + // Get all hosts under one DNS record. for (asio::iterator end; iterator != end; ++iterator) - { + { do_connecting(iterator); break; // FIXME. chenhao, can not query all hosts, caused by loop fastly } @@ -266,17 +266,17 @@ void connector::safe_connect(asio::iterator iterator, socket::ptr socket, deadline::ptr timer, connect_handler handler) { // Critical Section (external) - /////////////////////////////////////////////////////////////////////////// + /////////////////////////////////////////////////////////////////////////// const auto locked = socket->get_socket(); // This is branch #2 of the connnect sequence. using namespace boost::asio; - ip::tcp::endpoint endpoint = *iterator; + ip::tcp::endpoint endpoint = *iterator; - locked->get().async_connect(endpoint, + locked->get().async_connect(endpoint, std::bind(&connector::handle_connect, shared_from_this(), _1, socket, timer, handler)); - /////////////////////////////////////////////////////////////////////////// + /////////////////////////////////////////////////////////////////////////// } // Timer sequence. diff --git a/src/lib/network/hosts.cpp b/src/lib/network/hosts.cpp index 0ad8fc038..72c9efe3d 100644 --- a/src/lib/network/hosts.cpp +++ b/src/lib/network/hosts.cpp @@ -39,10 +39,10 @@ hosts::hosts(threadpool& pool, const settings& settings) dispatch_(pool, NAME), file_path_(default_data_path() / settings.hosts_file), disabled_(settings.host_pool_capacity == 0), - pool_(pool), + pool_(pool), seed_count(settings.seeds.size()) { -// buffer_.reserve(std::max(settings.host_pool_capacity, 1u)); +// buffer_.reserve(std::max(settings.host_pool_capacity, 1u)); } // private @@ -74,77 +74,77 @@ code hosts::fetch(address& out, const config::authority::list& excluded_list) { /////////////////////////////////////////////////////////////////////////// // Critical Section - shared_lock lock(mutex_); - fetch_times++; - config::authority::list addresses; - list* buffer=nullptr; - { - - if (stopped_) - { - return error::service_stopped; - } - - if (fetch_times % 5 == 4 && !inactive_.empty()) - buffer = &inactive_; - else - buffer = &buffer_; - } - - for(auto entry: *buffer) - { - auto iter = std::find(excluded_list.begin(), excluded_list.end(), config::authority(entry) ); - if(iter == excluded_list.end()) - { - addresses.push_back(config::authority(entry)); - } - } - - if (addresses.empty()) { - if (inactive_.empty()) { - return error::not_found; - } - const auto index = static_cast(pseudo_random() % inactive_.size()); - - size_t i = 0; - for (const auto& entry : inactive_) - { - if (i == index) { - out = entry; - break; - } - i++; - } - - return error::success; - } - - const auto index = static_cast(pseudo_random() % addresses.size()); - out = addresses[index].to_network_address(); - -// const auto index = static_cast(pseudo_random() % hosts_.size()); -// out = hosts_[index].to_network_address(); + shared_lock lock(mutex_); + fetch_times++; + config::authority::list addresses; + list* buffer=nullptr; + { + + if (stopped_) + { + return error::service_stopped; + } + + if (fetch_times % 5 == 4 && !inactive_.empty()) + buffer = &inactive_; + else + buffer = &buffer_; + } + + for(auto entry: *buffer) + { + auto iter = std::find(excluded_list.begin(), excluded_list.end(), config::authority(entry) ); + if(iter == excluded_list.end()) + { + addresses.push_back(config::authority(entry)); + } + } + + if (addresses.empty()) { + if (inactive_.empty()) { + return error::not_found; + } + const auto index = static_cast(pseudo_random() % inactive_.size()); + + size_t i = 0; + for (const auto& entry : inactive_) + { + if (i == index) { + out = entry; + break; + } + i++; + } + + return error::success; + } + + const auto index = static_cast(pseudo_random() % addresses.size()); + out = addresses[index].to_network_address(); + +// const auto index = static_cast(pseudo_random() % hosts_.size()); +// out = hosts_[index].to_network_address(); return error::success; /////////////////////////////////////////////////////////////////////////// } hosts::address::list hosts::copy() { - address::list copy; - - shared_lock lock{mutex_}; - copy.reserve(buffer_.size()); - for (auto& h:buffer_) { - copy.push_back(h); - } - return copy; + address::list copy; + + shared_lock lock{mutex_}; + copy.reserve(buffer_.size()); + for (auto& h:buffer_) { + copy.push_back(h); + } + return copy; } void hosts::handle_timer(const code& ec) { - if (ec.value() != error::success){ - return; - } + if (ec.value() != error::success){ + return; + } mutex_.lock_upgrade(); @@ -155,27 +155,27 @@ void hosts::handle_timer(const code& ec) } mutex_.unlock_upgrade_and_lock(); - bc::ofstream file(file_path_.string()); - const auto file_error = file.bad(); - - if (!file_error) - { - log::debug(LOG_NETWORK) << "sync hosts to file(" << file_path_.string() << "), active hosts size is " - << buffer_.size() << " hosts found, inactive hosts size is " << inactive_.size(); - for (const auto& entry: buffer_) - file << config::authority(entry) << std::endl; - for (const auto& entry: inactive_) - file << config::authority(entry) << std::endl; - } - else - { - log::error(LOG_NETWORK) << "hosts file (" << file_path_.string() << ") open failed" ; - mutex_.unlock(); - return; - } - - mutex_.unlock(); - snap_timer_->start(std::bind(&hosts::handle_timer, shared_from_this(), std::placeholders::_1)); + bc::ofstream file(file_path_.string()); + const auto file_error = file.bad(); + + if (!file_error) + { + log::debug(LOG_NETWORK) << "sync hosts to file(" << file_path_.string() << "), active hosts size is " + << buffer_.size() << " hosts found, inactive hosts size is " << inactive_.size(); + for (const auto& entry: buffer_) + file << config::authority(entry) << std::endl; + for (const auto& entry: inactive_) + file << config::authority(entry) << std::endl; + } + else + { + log::error(LOG_NETWORK) << "hosts file (" << file_path_.string() << ") open failed" ; + mutex_.unlock(); + return; + } + + mutex_.unlock(); + snap_timer_->start(std::bind(&hosts::handle_timer, shared_from_this(), std::placeholders::_1)); } // load @@ -212,15 +212,15 @@ code hosts::start() if (host.port() != 0) { - auto network_address = host.to_network_address(); - if(network_address.is_routable()) - { - buffer_.insert(network_address); - } - else - { - log::debug(LOG_NETWORK) << "host start is not routable," << config::authority{network_address}; - } + auto network_address = host.to_network_address(); + if(network_address.is_routable()) + { + buffer_.insert(network_address); + } + else + { + log::debug(LOG_NETWORK) << "host start is not routable," << config::authority{network_address}; + } } } } @@ -360,10 +360,10 @@ code hosts::remove(const address& host) mutex_.unlock_upgrade_and_lock(); auto iter = inactive_.find(host); - if (iter == inactive_.end()) { - inactive_.insert(host); - } - mutex_.unlock(); + if (iter == inactive_.end()) { + inactive_.insert(host); + } + mutex_.unlock(); /////////////////////////////////////////////////////////////////////////// return error::success; @@ -395,7 +395,7 @@ code hosts::store(const address& host) buffer_.insert(host); auto iter = inactive_.find(host); if (iter != inactive_.end()){ - inactive_.erase(iter); + inactive_.erase(iter); } mutex_.unlock(); diff --git a/src/lib/network/p2p.cpp b/src/lib/network/p2p.cpp index a908e5180..af370245f 100644 --- a/src/lib/network/p2p.cpp +++ b/src/lib/network/p2p.cpp @@ -257,7 +257,7 @@ session_outbound::ptr p2p::attach_outbound_session() // IOW queued shutdown operations must not enqueue additional work. // This is not short-circuited by a stopped test because we need to ensure it -// completes at least once before returning. This requires a unique lock be +// completes at least once before returning. This requires a unique lock be // taken around the entire section, which poses a deadlock risk. Instead this // is thread safe and idempotent, allowing it to be unguarded. bool p2p::stop() @@ -279,7 +279,7 @@ bool p2p::stop() // Stop accepting channels and stop those that exist (self-clearing). connections_->stop(error::service_stopped); - + //shutdown upnp map_port(false); @@ -399,7 +399,7 @@ void p2p::handle_new_connection(const code& ec, channel::ptr channel, { // Connection-in-use indicated here by error::address_in_use. handler(ec); - + if (!ec && channel->notify()) channel_subscriber_->relay(error::success, channel); } @@ -480,7 +480,7 @@ void p2p::thread_map_port(uint16_t map_port) /* miniupnpc 1.9.20150730 */ int error = 0; devlist = upnpDiscover(2000, multicastif, minissdpdpath, 0, 0, 2, &error); - + #endif struct UPNPUrls urls; @@ -496,7 +496,7 @@ void p2p::thread_map_port(uint16_t map_port) if (r == 1) { std::string strDesc = std::string("ETP v") + MVS_VERSION; - + try { while (true) { @@ -595,7 +595,7 @@ config::authority::ptr p2p::get_out_address() { freeUPNPDevlist(devlist); devlist = nullptr; if (r != 0) FreeUPNPUrls(&urls); - + return std::make_shared(settings_.self); } diff --git a/src/lib/network/protocols/protocol.cpp b/src/lib/network/protocols/protocol.cpp index 34a1bcd46..df918a0de 100644 --- a/src/lib/network/protocols/protocol.cpp +++ b/src/lib/network/protocols/protocol.cpp @@ -63,7 +63,7 @@ void protocol::set_peer_version(message::version::ptr value) uint32_t protocol::peer_start_height() { - return channel_->peer_start_height(); + return channel_->peer_start_height(); } threadpool& protocol::pool() @@ -79,7 +79,7 @@ void protocol::stop(const code& ec) bool protocol::misbehaving(int32_t howmuch) { - return channel_->misbehaving(howmuch); + return channel_->misbehaving(howmuch); } } // namespace network diff --git a/src/lib/network/protocols/protocol_address.cpp b/src/lib/network/protocols/protocol_address.cpp index 344506cea..3df3b007c 100644 --- a/src/lib/network/protocols/protocol_address.cpp +++ b/src/lib/network/protocols/protocol_address.cpp @@ -73,7 +73,7 @@ void protocol_address::start() self_ = address({ { nt_address } }); SEND2(self_, handle_send, _1, self_.command); } - + } #ifdef USE_UPNP @@ -97,7 +97,7 @@ void protocol_address::start() } #endif - + // If we can't store addresses we don't ask for or handle them. if (settings.host_pool_capacity == 0) diff --git a/src/lib/network/protocols/protocol_events.cpp b/src/lib/network/protocols/protocol_events.cpp index 00e163afc..704239438 100644 --- a/src/lib/network/protocols/protocol_events.cpp +++ b/src/lib/network/protocols/protocol_events.cpp @@ -56,7 +56,7 @@ void protocol_events::start(event_handler handler) handler_.store(handler); SUBSCRIBE_STOP1(handle_stopped, _1); if (channel_stopped()) - set_event(error::channel_stopped); + set_event(error::channel_stopped); } // Stop. @@ -67,7 +67,7 @@ void protocol_events::handle_stopped(const code& ec) log::trace(LOG_NETWORK) << "Stop protocol_" << name() << " on [" << authority() << "] " << ec.message(); - + // Event handlers can depend on this code for channel stop. set_event(error::channel_stopped); } diff --git a/src/lib/network/protocols/protocol_timer.cpp b/src/lib/network/protocols/protocol_timer.cpp index 47247c479..3327005ee 100644 --- a/src/lib/network/protocols/protocol_timer.cpp +++ b/src/lib/network/protocols/protocol_timer.cpp @@ -74,8 +74,8 @@ void protocol_timer::reset_timer() timer_->start(BIND1(handle_timer, _1)); if (stopped()) { - timer_->stop(); - return; + timer_->stop(); + return; } } diff --git a/src/lib/network/protocols/protocol_version.cpp b/src/lib/network/protocols/protocol_version.cpp index 8cd5818c2..cbf26d331 100644 --- a/src/lib/network/protocols/protocol_version.cpp +++ b/src/lib/network/protocols/protocol_version.cpp @@ -100,10 +100,10 @@ void protocol_version::start(event_handler handler) void protocol_version::handle_complete(const code& ec) { - if (!complete_handler_) - return; - complete_handler_(ec); - complete_handler_ = nullptr; + if (!complete_handler_) + return; + complete_handler_(ec); + complete_handler_ = nullptr; } void protocol_version::send_version(const message::version& self) diff --git a/src/lib/network/proxy.cpp b/src/lib/network/proxy.cpp index d1728817f..af018a38f 100644 --- a/src/lib/network/proxy.cpp +++ b/src/lib/network/proxy.cpp @@ -198,7 +198,7 @@ void proxy::handle_read_heading(const boost_code& ec, size_t) if (!head.is_valid()) { - log::warning(LOG_NETWORK) + log::warning(LOG_NETWORK) << "Invalid heading from [" << authority() << "]"; stop(error::bad_stream); return; @@ -276,7 +276,7 @@ void proxy::handle_read_payload(const boost_code& ec, size_t payload_size, stop(error::bad_stream); return; } - + /////////////////////////////////////////////////////////////////////////// // TODO: we aren't getting a stream benefit if we read the full payload // before parsing the message. Should just make this a message parse. diff --git a/src/lib/network/sessions/session.cpp b/src/lib/network/sessions/session.cpp index 50ae021ad..c3a26841a 100644 --- a/src/lib/network/sessions/session.cpp +++ b/src/lib/network/sessions/session.cpp @@ -106,12 +106,12 @@ bool session::blacklisted(const authority& authority) const void session::remove(const message::network_address& address, result_handler handler) { - network_.remove(address, handler); + network_.remove(address, handler); } void session::store(const message::network_address& address) { - network_.store(address, [](const code&){}); + network_.store(address, [](const code&){}); } // Socket creators. @@ -270,7 +270,7 @@ void session::handle_handshake(const code& ec, channel::ptr channel, return; } - truth_handler handler = + truth_handler handler = BIND_3(handle_is_pending, _1, channel, handle_started); // The loopback test is for incoming channels only. diff --git a/src/lib/network/sessions/session_batch.cpp b/src/lib/network/sessions/session_batch.cpp index e323e9793..c86c14970 100644 --- a/src/lib/network/sessions/session_batch.cpp +++ b/src/lib/network/sessions/session_batch.cpp @@ -153,9 +153,9 @@ void session_batch::handle_connect(const code& ec, channel::ptr channel, << "Failure connecting to [" << host << "] " << count << "," << ec.message(); if (ec == error::channel_timeout) // if connect is not aviliable, change it into inactive state - remove(host.to_network_address(), [](const code&){}); - else - store(host.to_network_address()); + remove(host.to_network_address(), [](const code&){}); + else + store(host.to_network_address()); handler(ec, channel); return; } diff --git a/src/lib/network/sessions/session_inbound.cpp b/src/lib/network/sessions/session_inbound.cpp index 48367d47f..767cdf864 100644 --- a/src/lib/network/sessions/session_inbound.cpp +++ b/src/lib/network/sessions/session_inbound.cpp @@ -134,7 +134,7 @@ void session_inbound::handle_accept(const code& ec, channel::ptr channel, void session_inbound::handle_connection_count(size_t connections, channel::ptr channel) { - const auto connection_limit = settings_.inbound_connections + + const auto connection_limit = settings_.inbound_connections + settings_.outbound_connections; if (connections >= connection_limit) @@ -144,11 +144,11 @@ void session_inbound::handle_connection_count(size_t connections, << channel->authority() << "] due to connection limit."; return; } - + log::trace(LOG_NETWORK) << "Connected inbound channel [" << channel->authority() << "]"; - register_channel(channel, + register_channel(channel, BIND2(handle_channel_start, _1, channel), BIND1(handle_channel_stop, _1)); } @@ -161,7 +161,7 @@ void session_inbound::handle_channel_start(const code& ec, log::trace(LOG_NETWORK) << "Inbound channel failed to start [" << channel->authority() << "] " << ec.message(); - channel->stop(ec); + channel->stop(ec); return; } diff --git a/src/lib/network/sessions/session_manual.cpp b/src/lib/network/sessions/session_manual.cpp index c247f2fcc..ae58b83cd 100644 --- a/src/lib/network/sessions/session_manual.cpp +++ b/src/lib/network/sessions/session_manual.cpp @@ -114,10 +114,10 @@ void session_manual::handle_connect(const code& ec, channel::ptr channel, auto shared_this = shared_from_base(); const auto timer = std::make_shared(pool_, asio::seconds(3)); - + // Retry logic. if (settings_.manual_attempt_limit == 0) - delay_new_connection(hostname, port, handler, 0); + delay_new_connection(hostname, port, handler, 0); else if (retries > 0) delay_new_connection(hostname, port, handler, retries); else @@ -130,7 +130,7 @@ void session_manual::handle_connect(const code& ec, channel::ptr channel, << "Connected manual channel [" << config::endpoint(hostname, port) << "] as [" << channel->authority() << "]"; - register_channel(channel, + register_channel(channel, BIND5(handle_channel_start, _1, hostname, port, channel, handler), BIND3(handle_channel_stop, _1, hostname, port)); } @@ -170,21 +170,21 @@ void session_manual::attach_protocols(channel::ptr channel) } void session_manual::delay_new_connection(const std::string& hostname, uint16_t port - , channel_handler handler, uint32_t retries) + , channel_handler handler, uint32_t retries) { - auto timer = std::make_shared(pool_, asio::seconds(2)); - auto self = shared_from_this(); - timer->start([this, timer, self, hostname, port, handler, retries](const code& ec){ - if (stopped()) - { - return; - } - auto pThis = shared_from_this(); - auto action = [this, pThis, hostname, port, handler, retries](){ - start_connect(hostname, port, handler, retries); - }; - pool_.service().post(action); - }); + auto timer = std::make_shared(pool_, asio::seconds(2)); + auto self = shared_from_this(); + timer->start([this, timer, self, hostname, port, handler, retries](const code& ec){ + if (stopped()) + { + return; + } + auto pThis = shared_from_this(); + auto action = [this, pThis, hostname, port, handler, retries](){ + start_connect(hostname, port, handler, retries); + }; + pool_.service().post(action); + }); } // After a stop we don't use the caller's start handler, but keep connecting. diff --git a/src/lib/network/sessions/session_outbound.cpp b/src/lib/network/sessions/session_outbound.cpp index ce4caa505..e1d1ce171 100644 --- a/src/lib/network/sessions/session_outbound.cpp +++ b/src/lib/network/sessions/session_outbound.cpp @@ -74,7 +74,7 @@ void session_outbound::handle_started(const code& ec, result_handler handler) const auto connect = create_connector(); for (size_t peer = 0; peer < settings_.outbound_connections; ++peer) { - log::debug(LOG_NETWORK) << "new connection"; + log::debug(LOG_NETWORK) << "new connection"; new_connection(connect); } @@ -100,19 +100,19 @@ void session_outbound::new_connection(connector::ptr connect) void session_outbound::delay_new_connect(connector::ptr connect) { - auto timer = std::make_shared(pool_, asio::seconds(2)); - auto self = shared_from_this(); - timer->start([this, connect, timer, self](const code& ec){ - if (stopped()) - { - return; - } - auto pThis = shared_from_this(); - auto action = [this, pThis, connect](){ - new_connection(connect); - }; - pool_.service().post(action); - }); + auto timer = std::make_shared(pool_, asio::seconds(2)); + auto self = shared_from_this(); + timer->start([this, connect, timer, self](const code& ec){ + if (stopped()) + { + return; + } + auto pThis = shared_from_this(); + auto action = [this, pThis, connect](){ + new_connection(connect); + }; + pool_.service().post(action); + }); } void session_outbound::delay_reseeding() @@ -120,7 +120,7 @@ void session_outbound::delay_reseeding() if (!network__.network_settings().enable_re_seeding) { return; } - + if (in_reseeding) { return; } @@ -162,7 +162,7 @@ void session_outbound::handle_connect(const code& ec, channel::ptr channel, log::trace(LOG_NETWORK) << "Connected to outbound channel [" << channel->authority() << "]"; ++outbound_counter; - register_channel(channel, + register_channel(channel, BIND3(handle_channel_start, _1, connect, channel), BIND3(handle_channel_stop, _1, connect, channel)); } diff --git a/src/lib/network/sessions/session_seed.cpp b/src/lib/network/sessions/session_seed.cpp index 22561ee7a..2aae0ae1d 100644 --- a/src/lib/network/sessions/session_seed.cpp +++ b/src/lib/network/sessions/session_seed.cpp @@ -40,7 +40,7 @@ using namespace std::placeholders; session_seed::session_seed(p2p& network) : session(network, true, false), CONSTRUCT_TRACK(session_seed), - network_{network} + network_{network} { } @@ -81,7 +81,7 @@ void session_seed::handle_count(size_t start_size, result_handler handler) if (start_size != 0) { log::debug(LOG_NETWORK) - << "Seeding is not required because there are " + << "Seeding is not required because there are " << start_size << " cached addresses."; handler(error::success); return; @@ -94,7 +94,7 @@ void session_seed::handle_count(size_t start_size, result_handler handler) handler(error::operation_failed); return; } - + // This is NOT technically the end of the start sequence, since the handler // is not invoked until seeding operations are complete. start_seeding(start_size, create_connector(), handler); @@ -133,8 +133,8 @@ void session_seed::start_seed(const config::endpoint& seed, // OUTBOUND CONNECT connect->connect(seed, BIND4(handle_connect, _1, _2, seed, handler), [this](const asio::endpoint& endpoint){ - network_.store(config::authority{endpoint}.to_network_address(), [](const code& ec){}); - log::debug(LOG_NETWORK) << "session seed store," << endpoint ; + network_.store(config::authority{endpoint}.to_network_address(), [](const code& ec){}); + log::debug(LOG_NETWORK) << "session seed store," << endpoint ; }); } @@ -161,7 +161,7 @@ void session_seed::handle_connect(const code& ec, channel::ptr channel, log::info(LOG_NETWORK) << "Connected seed [" << seed << "] as " << channel->authority(); - register_channel(channel, + register_channel(channel, BIND3(handle_channel_start, _1, channel, handler), BIND1(handle_channel_stop, _1)); } diff --git a/src/lib/network/settings.cpp b/src/lib/network/settings.cpp index 958e41859..90a61122d 100644 --- a/src/lib/network/settings.cpp +++ b/src/lib/network/settings.cpp @@ -128,7 +128,7 @@ duration settings::channel_expiration() const duration settings::channel_germination() const { return seconds(channel_germination_seconds); -} +} } // namespace network } // namespace libbitcoin diff --git a/src/lib/node/parser.cpp b/src/lib/node/parser.cpp index b66afe440..42100d8fd 100644 --- a/src/lib/node/parser.cpp +++ b/src/lib/node/parser.cpp @@ -36,7 +36,7 @@ BC_DECLARE_CONFIG_DEFAULT_PATH("libbitcoin" / "bn.cfg") namespace libbitcoin { namespace node { - + using namespace boost::filesystem; using namespace boost::program_options; using namespace bc::config; @@ -88,12 +88,12 @@ options_metadata parser::load_options() default_value(false)->zero_tokens(), "Display version information." ) - ( - "daemon,d", - value(&configured.daemon)-> - default_value(false)->zero_tokens(), - "Run in daemon mode or not" - ) + ( + "daemon,d", + value(&configured.daemon)-> + default_value(false)->zero_tokens(), + "Run in daemon mode or not" + ) // ( // BS_UI_VARIABLE "ui,u", // value(&configured.ui)-> @@ -253,7 +253,7 @@ options_metadata parser::load_settings() "network.upnp_map_port", value(&configured.network.upnp_map_port), "Persistent host:port channels, multiple entries allowed." - ) + ) ( "network.be_found", value(&configured.network.be_found), @@ -339,7 +339,7 @@ bool parser::parse(int argc, const char* argv[], std::ostream& error) load_environment_variables(variables, BN_ENVIRONMENT_VARIABLE_PREFIX); // Don't load the rest if any of these options are specified. - if (!get_option(variables, BN_VERSION_VARIABLE) && + if (!get_option(variables, BN_VERSION_VARIABLE) && !get_option(variables, BN_SETTINGS_VARIABLE) && !get_option(variables, BN_HELP_VARIABLE)) { diff --git a/src/lib/node/protocols/protocol_block_in.cpp b/src/lib/node/protocols/protocol_block_in.cpp index 632782927..c8676c555 100644 --- a/src/lib/node/protocols/protocol_block_in.cpp +++ b/src/lib/node/protocols/protocol_block_in.cpp @@ -88,8 +88,8 @@ void protocol_block_in::start() blockchain_.subscribe_reorganize( BIND4(handle_reorganized, _1, _2, _3, _4)); if (channel_stopped()) { - blockchain_.fired(); - } + blockchain_.fired(); + } // Send initial get_[blocks|headers] message by simulating first heartbeat. // set_event(error::success); @@ -119,14 +119,14 @@ void protocol_block_in::get_block_inventory(const code& ec) } auto& blockchain = static_cast(blockchain_); - uint64_t top; - auto is_got = blockchain.get_last_height(top); - int64_t block_interval = 20000; - auto res = static_cast(top) - static_cast(peer_start_height()) - block_interval; - if (!is_got || res > 0) - { - return ; - } + uint64_t top; + auto is_got = blockchain.get_last_height(top); + int64_t block_interval = 20000; + auto res = static_cast(top) - static_cast(peer_start_height()) - block_interval; + if (!is_got || res > 0) + { + return ; + } static uint32_t num = 0; // This is also sent after each reorg. @@ -155,7 +155,7 @@ void protocol_block_in::send_get_blocks(const hash_digest& stop_hash) } void protocol_block_in::send_get_blocks(const hash_digest& from_hash, const hash_digest& to_hash) -{ +{ hash_list locator; locator.push_back(from_hash); code code; @@ -390,14 +390,14 @@ void protocol_block_in::handle_store_block(const code& ec, block_ptr message) << "Redundant block from [" << authority() << "] " << ec.message(); return; - } + } if(ec == (code)error::fetch_more_block) { log::trace(LOG_NODE) << "fetch more blocks start_hash:" << encode_hash(message->header.hash()); - send_get_blocks(message->header.hash(), null_hash); + send_get_blocks(message->header.hash(), null_hash); return; } diff --git a/src/lib/node/protocols/protocol_block_out.cpp b/src/lib/node/protocols/protocol_block_out.cpp index 52f7604c5..5c8e173d5 100644 --- a/src/lib/node/protocols/protocol_block_out.cpp +++ b/src/lib/node/protocols/protocol_block_out.cpp @@ -89,8 +89,8 @@ void protocol_block_out::start() blockchain_.subscribe_reorganize( BIND4(handle_reorganized, _1, _2, _3, _4)); if (channel_stopped()) { - blockchain_.fired(); - } + blockchain_.fired(); + } } // Receive send_headers. @@ -170,24 +170,24 @@ bool protocol_block_out::handle_receive_get_headers(const code& ec, auto need_to_locate = true; if (locator_size > 0) { - auto& blockchain = static_cast(static_cast(blockchain_)); - uint64_t height{0}; - auto ok = blockchain.get_height(height, message->start_hashes.back()); - if (!ok) - { - need_to_locate = false; - } + auto& blockchain = static_cast(static_cast(blockchain_)); + uint64_t height{0}; + auto ok = blockchain.get_height(height, message->start_hashes.back()); + if (!ok) + { + need_to_locate = false; + } } if (need_to_locate) { - auto& blockchain = static_cast(static_cast(blockchain_)); - uint64_t top; - auto is_got = blockchain.get_last_height(top); - int64_t block_interval = 2000; - auto res = static_cast(top) - static_cast(peer_start_height()) - block_interval; - blockchain_.fetch_locator_block_headers(*message, threshold, res>0?locator_cap:10, - BIND2(handle_fetch_locator_headers, _1, _2)); + auto& blockchain = static_cast(static_cast(blockchain_)); + uint64_t top; + auto is_got = blockchain.get_last_height(top); + int64_t block_interval = 2000; + auto res = static_cast(top) - static_cast(peer_start_height()) - block_interval; + blockchain_.fetch_locator_block_headers(*message, threshold, res>0?locator_cap:10, + BIND2(handle_fetch_locator_headers, _1, _2)); } return true; @@ -257,10 +257,10 @@ bool protocol_block_out::handle_receive_get_blocks(const code& ec, // that case we would not respond but our peer's other peer should. const auto threshold = last_locator_top_.load(); auto& blockchain = static_cast(blockchain_); - uint64_t top; - auto is_got = blockchain.get_last_height(top); - int64_t block_interval = 2000; - auto res = static_cast(top) - static_cast(peer_start_height()) - block_interval; + uint64_t top; + auto is_got = blockchain.get_last_height(top); + int64_t block_interval = 2000; + auto res = static_cast(top) - static_cast(peer_start_height()) - block_interval; blockchain_.fetch_locator_block_hashes(*message, threshold, res>0?locator_cap:10, BIND2(handle_fetch_locator_hashes, _1, _2)); @@ -428,15 +428,15 @@ bool protocol_block_out::handle_reorganized(const code& ec, size_t fork_point, if (!announcement.elements.empty()) { - auto& blockchain = static_cast(blockchain_); - uint64_t top; - auto is_got = blockchain.get_last_height(top); - int64_t block_interval = 20000; - auto res = std::abs(static_cast(top) - static_cast(peer_start_height())); - if (!is_got || res > block_interval) - { - return true; - } + auto& blockchain = static_cast(blockchain_); + uint64_t top; + auto is_got = blockchain.get_last_height(top); + int64_t block_interval = 20000; + auto res = std::abs(static_cast(top) - static_cast(peer_start_height())); + if (!is_got || res > block_interval) + { + return true; + } SEND2(announcement, handle_send, _1, announcement.command); } return true; @@ -451,15 +451,15 @@ bool protocol_block_out::handle_reorganized(const code& ec, size_t fork_point, if (!announcement.inventories.empty()) { - auto& blockchain = static_cast(blockchain_); - uint64_t top; - auto is_got = blockchain.get_last_height(top); - int64_t block_interval = 20000; - auto res = std::abs(static_cast(top) - static_cast(peer_start_height())); - if (!is_got || res > block_interval) - { - return true; - } + auto& blockchain = static_cast(blockchain_); + uint64_t top; + auto is_got = blockchain.get_last_height(top); + int64_t block_interval = 20000; + auto res = std::abs(static_cast(top) - static_cast(peer_start_height())); + if (!is_got || res > block_interval) + { + return true; + } SEND2(announcement, handle_send, _1, announcement.command); } return true; diff --git a/src/lib/node/protocols/protocol_block_sync.cpp b/src/lib/node/protocols/protocol_block_sync.cpp index 7f26cf326..4dea64655 100644 --- a/src/lib/node/protocols/protocol_block_sync.cpp +++ b/src/lib/node/protocols/protocol_block_sync.cpp @@ -146,11 +146,11 @@ bool protocol_block_sync::handle_receive(const code& ec, block_ptr message, // This is fired by the base timer and stop handler. void protocol_block_sync::handle_event(const code& ec, event_handler complete) { - if (ec == (code)error::service_stopped) - { - complete(ec); - return ; - } + if (ec == (code)error::service_stopped) + { + complete(ec); + return ; + } if (ec == (code)error::channel_stopped) { diff --git a/src/lib/node/protocols/protocol_header_sync.cpp b/src/lib/node/protocols/protocol_header_sync.cpp index fdf71d9c3..c3090801c 100644 --- a/src/lib/node/protocols/protocol_header_sync.cpp +++ b/src/lib/node/protocols/protocol_header_sync.cpp @@ -151,7 +151,7 @@ bool protocol_header_sync::handle_receive(const code& ec, headers_ptr message, // If we completed the last height the sync is complete/success. if (next > last_.height()) { - log::trace(LOG_NODE) << "protocol header sync handle receive complete"; + log::trace(LOG_NODE) << "protocol header sync handle receive complete"; complete(error::success); return false; } @@ -159,7 +159,7 @@ bool protocol_header_sync::handle_receive(const code& ec, headers_ptr message, // If we received fewer than 2000 the peer is exhausted, try another. if (message->elements.size() < max_header_response) { - log::trace(LOG_NODE) << "protocol header sync handle receive message size < max header response"; + log::trace(LOG_NODE) << "protocol header sync handle receive message size < max header response"; complete(error::operation_failed); return false; } @@ -205,7 +205,7 @@ void protocol_header_sync::headers_complete(const code& ec, event_handler handler) { - // This is end of the header sync sequence. + // This is end of the header sync sequence. handler(ec); // The session does not need to handle the stop. diff --git a/src/lib/node/protocols/protocol_miner.cpp b/src/lib/node/protocols/protocol_miner.cpp index d4c46ee99..50ad4a95d 100644 --- a/src/lib/node/protocols/protocol_miner.cpp +++ b/src/lib/node/protocols/protocol_miner.cpp @@ -27,33 +27,33 @@ namespace libbitcoin { namespace node { protocol_miner::protocol_miner(network::p2p& network - , network::channel::ptr channel - , blockchain::block_chain& blockchain - /*, blockchain::transaction_pool& pool*/) - :protocol_events{network, channel, NAME}, - blockchain_{blockchain}, - /*pool_{pool},*/ - CONSTRUCT_TRACK(protocol_miner) + , network::channel::ptr channel + , blockchain::block_chain& blockchain + /*, blockchain::transaction_pool& pool*/) + :protocol_events{network, channel, NAME}, + blockchain_{blockchain}, + /*pool_{pool},*/ + CONSTRUCT_TRACK(protocol_miner) { } void protocol_miner::start() { - using namespace std::placeholders; - protocol_events::start(BIND1(handle_stop, _1)); -// pool_.subscribe_transaction(BIND3(handle_accept_transaction, _1, _2, _3)); + using namespace std::placeholders; + protocol_events::start(BIND1(handle_stop, _1)); +// pool_.subscribe_transaction(BIND3(handle_accept_transaction, _1, _2, _3)); } void protocol_miner::handle_stop(const code& ec) { - log::trace(LOG_NODE) << "protocol miner handle stop," << ec.message(); + log::trace(LOG_NODE) << "protocol miner handle stop," << ec.message(); } /* bool protocol_miner::handle_accept_transaction(const code&, const indexes&, transaction_ptr) { - return true; + return true; } */ diff --git a/src/lib/node/protocols/protocol_transaction_in.cpp b/src/lib/node/protocols/protocol_transaction_in.cpp index 411fa9c9e..1c35f7ea2 100644 --- a/src/lib/node/protocols/protocol_transaction_in.cpp +++ b/src/lib/node/protocols/protocol_transaction_in.cpp @@ -82,8 +82,8 @@ void protocol_transaction_in::start() blockchain_.subscribe_reorganize( BIND4(handle_reorganized, _1, _2, _3, _4)); if (channel_stopped()) { - blockchain_.fired(); - } + blockchain_.fired(); + } } } @@ -152,7 +152,7 @@ void protocol_transaction_in::handle_filter_floaters(const code& ec, void protocol_transaction_in::send_get_data(const code& ec, get_data_ptr message) { - if (stopped() || ec == (code)error::service_stopped || + if (stopped() || ec == (code)error::service_stopped || message->inventories.empty()) return; diff --git a/src/lib/node/protocols/protocol_transaction_out.cpp b/src/lib/node/protocols/protocol_transaction_out.cpp index d822d76b6..f0a70c8b2 100644 --- a/src/lib/node/protocols/protocol_transaction_out.cpp +++ b/src/lib/node/protocols/protocol_transaction_out.cpp @@ -30,7 +30,7 @@ namespace node { #define NAME "transaction" #define CLASS protocol_transaction_out - + using namespace bc::blockchain; using namespace bc::message; using namespace bc::network; @@ -74,8 +74,8 @@ void protocol_transaction_out::start() // Subscribe to transaction pool notifications and relay txs. pool_.subscribe_transaction(BIND3(handle_floated, _1, _2, _3)); if (channel_stopped()) { - pool_.fired(); - } + pool_.fired(); + } } // TODO: move fee filter to a derived class protocol_transaction_out_70013. diff --git a/src/lib/node/sessions/session_block_sync.cpp b/src/lib/node/sessions/session_block_sync.cpp index 538a9084c..a0657a6bb 100644 --- a/src/lib/node/sessions/session_block_sync.cpp +++ b/src/lib/node/sessions/session_block_sync.cpp @@ -49,7 +49,7 @@ session_block_sync::session_block_sync(p2p& network, header_queue& hashes, simple_chain& chain, const settings& settings) : session_batch(network, false), blockchain_(chain), - reservations_count_{0}, + reservations_count_{0}, settings_(settings), reservations_(hashes, chain, settings), CONSTRUCT_TRACK(session_block_sync) @@ -93,7 +93,7 @@ void session_block_sync::handle_started(const code& ec, result_handler handler) // This is the end of the start sequence. for (const auto row: table) new_connection(connector, row, [func](const code& ec){ - func(ec); + func(ec); }); log::info(LOG_NODE) << "table size," << table.size(); @@ -133,9 +133,9 @@ void session_block_sync::handle_connect(const code& ec, channel::ptr channel, << ec.message(); if(ec.value() == error::not_satisfied) { - log::debug(LOG_NETWORK) << "session block sync handle connect, not satified"; - handle_complete(ec, channel, connect, row, handler); - return; + log::debug(LOG_NETWORK) << "session block sync handle connect, not satified"; + handle_complete(ec, channel, connect, row, handler); + return; } new_connection(connect, row, handler); return; @@ -175,8 +175,8 @@ void session_block_sync::attach_protocols(channel::ptr channel, { attach(channel)->start(); attach(channel)->start(); - attach(channel, row)->start( - BIND5(handle_complete, _1, channel, connect, row, handler)); + attach(channel, row)->start( + BIND5(handle_complete, _1, channel, connect, row, handler)); } void session_block_sync::handle_complete(const code& ec, channel::ptr channel, @@ -199,13 +199,13 @@ void session_block_sync::handle_complete(const code& ec, channel::ptr channel, if(ec.value() == error::not_satisfied) { - scoped_lock lock{mutex_}; - if(reservations_count_ != 1) - { - --reservations_count_; - handler(error::success); - return; - } + scoped_lock lock{mutex_}; + if(reservations_count_ != 1) + { + --reservations_count_; + handler(error::success); + return; + } } // There is no failure scenario, we ignore the result code here. @@ -213,7 +213,7 @@ void session_block_sync::handle_complete(const code& ec, channel::ptr channel, } void session_block_sync::handle_channel_stop(const code& ec, - network::connector::ptr connect, reservation::ptr row, result_handler handler) + network::connector::ptr connect, reservation::ptr row, result_handler handler) { log::info(LOG_NODE) << "Channel stopped on slot (" << row->slot() << ") " << ec.message(); diff --git a/src/lib/node/sessions/session_header_sync.cpp b/src/lib/node/sessions/session_header_sync.cpp index b429fbc3b..d62951850 100644 --- a/src/lib/node/sessions/session_header_sync.cpp +++ b/src/lib/node/sessions/session_header_sync.cpp @@ -58,8 +58,8 @@ session_header_sync::session_header_sync(p2p& network, header_queue& hashes, minimum_rate_(headers_per_second), blockchain_(blockchain), checkpoints_(checkpoint::sort(checkpoints)), - try_count_{0}, - synced_{false}, + try_count_{0}, + synced_{false}, CONSTRUCT_TRACK(session_header_sync) { static_assert(back_off_factor < 1.0, "invalid back-off factor"); @@ -114,11 +114,11 @@ void session_header_sync::handle_connect(const code& ec, channel::ptr channel, log::debug(LOG_NODE) << "Failure connecting header sync channel: " << ec.message(); if(ec.value() == error::not_satisfied) - { - log::debug(LOG_NETWORK) << "session header sync handle connect, not satified"; - handler(ec); - return; - } + { + log::debug(LOG_NETWORK) << "session header sync handle connect, not satified"; + handler(ec); + return; + } handle_channel_stop(ec, connect, handler); return; } @@ -154,20 +154,20 @@ void session_header_sync::attach_protocols(channel::ptr channel, connector::ptr connect, result_handler handler) { attach(channel)->start(); - attach(channel)->start(); - attach(channel, hashes_, minimum_rate_, last_) - ->start(BIND4(handle_complete, _1, channel, connect, handler)); + attach(channel)->start(); + attach(channel, hashes_, minimum_rate_, last_) + ->start(BIND4(handle_complete, _1, channel, connect, handler)); } void session_header_sync::handle_complete(const code& ec, channel::ptr channel, network::connector::ptr connect, result_handler handler) { - channel->stop(error::channel_stopped); + channel->stop(error::channel_stopped); if (!ec) { - synced_.store(true); - log::debug(LOG_NODE) - << "header sync handle complete successfully," << ec.message() ; + synced_.store(true); + log::debug(LOG_NODE) + << "header sync handle complete successfully," << ec.message() ; // This is the end of the header sync sequence. handler(ec); return; @@ -177,7 +177,7 @@ void session_header_sync::handle_complete(const code& ec, channel::ptr channel, minimum_rate_ = static_cast(minimum_rate_ * back_off_factor); log::debug(LOG_NODE) - << "handle complete failed," << ec.message() ; + << "handle complete failed," << ec.message() ; // // There is no failure scenario, we ignore the result code here. // new_connection(connect, handler); @@ -189,14 +189,14 @@ void session_header_sync::handle_channel_stop(const code& ec, network::connector << "Header sync channel stopped: " << ec.message(); if(!synced_) { - ++try_count_; - if (try_count_ == 10) - { - log::info(LOG_NETWORK) << "session header sync handle connect try count reach 10"; - handler(error::network_unreachable); - return; - } - new_connection(connect, handler); + ++try_count_; + if (try_count_ == 10) + { + log::info(LOG_NETWORK) << "session header sync handle connect try count reach 10"; + handler(error::network_unreachable); + return; + } + new_connection(connect, handler); } } @@ -265,7 +265,7 @@ code session_header_sync::get_range(checkpoint& out_seed, checkpoint& out_stop) if (!blockchain_.get_header(first_header, first_height)) return error::not_found; - + if (!checkpoints_.empty() && checkpoints_.back().height() > last_height) { out_stop = checkpoints_.back(); diff --git a/src/lib/node/sessions/session_inbound.cpp b/src/lib/node/sessions/session_inbound.cpp index 4649b9d30..e1a08e102 100644 --- a/src/lib/node/sessions/session_inbound.cpp +++ b/src/lib/node/sessions/session_inbound.cpp @@ -29,7 +29,7 @@ namespace libbitcoin { namespace node { - + using namespace bc::blockchain; using namespace bc::network; using namespace std::placeholders; @@ -76,7 +76,7 @@ void session_inbound::attach_handshake_protocols(channel::ptr channel, if (stopped() || ec) { - channel->invoke_protocol_start_handler(error::channel_stopped); + channel->invoke_protocol_start_handler(error::channel_stopped); } handle_started(ec); }); diff --git a/src/lib/node/sessions/session_manual.cpp b/src/lib/node/sessions/session_manual.cpp index e55ecd359..8567eab19 100644 --- a/src/lib/node/sessions/session_manual.cpp +++ b/src/lib/node/sessions/session_manual.cpp @@ -29,7 +29,7 @@ namespace libbitcoin { namespace node { - + using namespace bc::blockchain; using namespace bc::network; using namespace std::placeholders; @@ -47,7 +47,7 @@ session_manual::session_manual(p2p& network, block_chain& blockchain, void session_manual::attach_handshake_protocols(channel::ptr channel, result_handler handle_started) { - auto self = shared_from_this(); + auto self = shared_from_this(); attach(channel)->start([channel, handle_started, this, self](const code& ec){ if (!ec) { auto pt_ping = attach(channel)->do_subscribe(); @@ -67,18 +67,18 @@ void session_manual::attach_handshake_protocols(channel::ptr channel, } else { - channel->invoke_protocol_start_handler(error::channel_stopped); + channel->invoke_protocol_start_handler(error::channel_stopped); } handle_started(ec); if(stopped()) - channel->invoke_protocol_start_handler(error::channel_stopped); + channel->invoke_protocol_start_handler(error::channel_stopped); }); } void session_manual::attach_protocols(channel::ptr channel) { - channel->invoke_protocol_start_handler(error::success); + channel->invoke_protocol_start_handler(error::success); } } // namespace node diff --git a/src/lib/node/sessions/session_outbound.cpp b/src/lib/node/sessions/session_outbound.cpp index c695d9003..7e3a25baa 100644 --- a/src/lib/node/sessions/session_outbound.cpp +++ b/src/lib/node/sessions/session_outbound.cpp @@ -48,7 +48,7 @@ session_outbound::session_outbound(p2p& network, block_chain& blockchain, void session_outbound::attach_handshake_protocols(channel::ptr channel, result_handler handle_started) { - auto self = shared_from_this(); + auto self = shared_from_this(); attach(channel)->start([channel, handle_started, this, self](const code& ec){ if (!ec) { auto pt_ping = attach(channel)->do_subscribe(); @@ -68,10 +68,10 @@ void session_outbound::attach_handshake_protocols(channel::ptr channel, } if (stopped() || ec) - { - channel->invoke_protocol_start_handler(error::channel_stopped); - channel->stop(error::channel_stopped); - } + { + channel->invoke_protocol_start_handler(error::channel_stopped); + channel->stop(error::channel_stopped); + } handle_started(ec); }); diff --git a/src/lib/node/utility/header_queue.cpp b/src/lib/node/utility/header_queue.cpp index 65e5a7b18..bf486fd5b 100644 --- a/src/lib/node/utility/header_queue.cpp +++ b/src/lib/node/utility/header_queue.cpp @@ -101,7 +101,7 @@ void header_queue::initialize(const hash_digest& hash, size_t height) /////////////////////////////////////////////////////////////////////////// mutex_.lock_upgrade(); - const auto size = + const auto size = (checkpoints_.empty() || height > checkpoints_.back().height()) ? 1 : (checkpoints_.back().height() - height + 1); @@ -187,7 +187,7 @@ bool header_queue::dequeue(size_t count) //--------------------------------------------------------------------- return false; } - + //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ mutex_.unlock_upgrade_and_lock(); diff --git a/src/lib/protocol/response_packet.cpp b/src/lib/protocol/response_packet.cpp index 747913e75..f4bc7e599 100644 --- a/src/lib/protocol/response_packet.cpp +++ b/src/lib/protocol/response_packet.cpp @@ -33,7 +33,7 @@ namespace libbitcoin { namespace protocol { response_packet::response_packet() - : response_(nullptr) + : response_(nullptr) { } diff --git a/src/lib/protocol/zmq/authenticator.cpp b/src/lib/protocol/zmq/authenticator.cpp index 806b40464..67f28f554 100644 --- a/src/lib/protocol/zmq/authenticator.cpp +++ b/src/lib/protocol/zmq/authenticator.cpp @@ -6,7 +6,7 @@ * metaverse-protocol is free software: you can redistribute it and/or * modify it under the terms of the GNU Affero General Public License with * additional permissions to the one published by the Free Software - * Foundation, either version 3 of the License, or (at your option) + * Foundation, either version 3 of the License, or (at your option) * any later version. For more information see LICENSE. * * This program is distributed in the hope that it will be useful, diff --git a/src/lib/protocol/zmq/certificate.cpp b/src/lib/protocol/zmq/certificate.cpp index 5bfe43475..8efa74821 100644 --- a/src/lib/protocol/zmq/certificate.cpp +++ b/src/lib/protocol/zmq/certificate.cpp @@ -6,7 +6,7 @@ * metaverse-protocol is free software: you can redistribute it and/or * modify it under the terms of the GNU Affero General Public License with * additional permissions to the one published by the Free Software - * Foundation, either version 3 of the License, or (at your option) + * Foundation, either version 3 of the License, or (at your option) * any later version. For more information see LICENSE. * * This program is distributed in the hope that it will be useful, diff --git a/src/lib/protocol/zmq/context.cpp b/src/lib/protocol/zmq/context.cpp index 4193e50bb..a7277b216 100644 --- a/src/lib/protocol/zmq/context.cpp +++ b/src/lib/protocol/zmq/context.cpp @@ -6,7 +6,7 @@ * metaverse-protocol is free software: you can redistribute it and/or * modify it under the terms of the GNU Affero General Public License with * additional permissions to the one published by the Free Software - * Foundation, either version 3 of the License, or (at your option) + * Foundation, either version 3 of the License, or (at your option) * any later version. For more information see LICENSE. * * This program is distributed in the hope that it will be useful, diff --git a/src/lib/protocol/zmq/frame.cpp b/src/lib/protocol/zmq/frame.cpp index a95e92856..f8d02a365 100644 --- a/src/lib/protocol/zmq/frame.cpp +++ b/src/lib/protocol/zmq/frame.cpp @@ -6,7 +6,7 @@ * metaverse-protocol is free software: you can redistribute it and/or * modify it under the terms of the GNU Affero General Public License with * additional permissions to the one published by the Free Software - * Foundation, either version 3 of the License, or (at your option) + * Foundation, either version 3 of the License, or (at your option) * any later version. For more information see LICENSE. * * This program is distributed in the hope that it will be useful, diff --git a/src/lib/protocol/zmq/identifiers.cpp b/src/lib/protocol/zmq/identifiers.cpp index 4230e87af..0c53259e4 100644 --- a/src/lib/protocol/zmq/identifiers.cpp +++ b/src/lib/protocol/zmq/identifiers.cpp @@ -6,7 +6,7 @@ * metaverse-protocol is free software: you can redistribute it and/or * modify it under the terms of the GNU Affero General Public License with * additional permissions to the one published by the Free Software - * Foundation, either version 3 of the License, or (at your option) + * Foundation, either version 3 of the License, or (at your option) * any later version. For more information see LICENSE. * * This program is distributed in the hope that it will be useful, diff --git a/src/lib/protocol/zmq/message.cpp b/src/lib/protocol/zmq/message.cpp index d4425c9ae..c03ea029f 100644 --- a/src/lib/protocol/zmq/message.cpp +++ b/src/lib/protocol/zmq/message.cpp @@ -6,7 +6,7 @@ * metaverse-protocol is free software: you can redistribute it and/or * modify it under the terms of the GNU Affero General Public License with * additional permissions to the one published by the Free Software - * Foundation, either version 3 of the License, or (at your option) + * Foundation, either version 3 of the License, or (at your option) * any later version. For more information see LICENSE. * * This program is distributed in the hope that it will be useful, diff --git a/src/lib/protocol/zmq/poller.cpp b/src/lib/protocol/zmq/poller.cpp index 350cf4f21..15df0eb81 100644 --- a/src/lib/protocol/zmq/poller.cpp +++ b/src/lib/protocol/zmq/poller.cpp @@ -6,7 +6,7 @@ * metaverse-protocol is free software: you can redistribute it and/or * modify it under the terms of the GNU Affero General Public License with * additional permissions to the one published by the Free Software - * Foundation, either version 3 of the License, or (at your option) + * Foundation, either version 3 of the License, or (at your option) * any later version. For more information see LICENSE. * * This program is distributed in the hope that it will be useful, diff --git a/src/lib/protocol/zmq/socket.cpp b/src/lib/protocol/zmq/socket.cpp index 9eaaf03a4..bf9690590 100644 --- a/src/lib/protocol/zmq/socket.cpp +++ b/src/lib/protocol/zmq/socket.cpp @@ -6,7 +6,7 @@ * metaverse-protocol is free software: you can redistribute it and/or * modify it under the terms of the GNU Affero General Public License with * additional permissions to the one published by the Free Software - * Foundation, either version 3 of the License, or (at your option) + * Foundation, either version 3 of the License, or (at your option) * any later version. For more information see LICENSE. * * This program is distributed in the hope that it will be useful, @@ -199,7 +199,7 @@ bool socket::set_private_key(const config::sodium& key) // This must be called on the socket thread. bool socket::set_certificate(const certificate& certificate) { - return certificate && + return certificate && set_public_key(certificate.public_key().to_string()) && set_private_key(certificate.private_key().to_string()); } diff --git a/src/lib/protocol/zmq/worker.cpp b/src/lib/protocol/zmq/worker.cpp index 14614df7c..6efcd1759 100644 --- a/src/lib/protocol/zmq/worker.cpp +++ b/src/lib/protocol/zmq/worker.cpp @@ -6,7 +6,7 @@ * metaverse-protocol is free software: you can redistribute it and/or * modify it under the terms of the GNU Affero General Public License with * additional permissions to the one published by the Free Software - * Foundation, either version 3 of the License, or (at your option) + * Foundation, either version 3 of the License, or (at your option) * any later version. For more information see LICENSE. * * This program is distributed in the hope that it will be useful, diff --git a/src/lib/protocol/zmq/zeromq.cpp b/src/lib/protocol/zmq/zeromq.cpp index 6d5eb4902..cbcc7d1e4 100644 --- a/src/lib/protocol/zmq/zeromq.cpp +++ b/src/lib/protocol/zmq/zeromq.cpp @@ -6,7 +6,7 @@ * metaverse-protocol is free software: you can redistribute it and/or * modify it under the terms of the GNU Affero General Public License with * additional permissions to the one published by the Free Software - * Foundation, either version 3 of the License, or (at your option) + * Foundation, either version 3 of the License, or (at your option) * any later version. For more information see LICENSE. * * This program is distributed in the hope that it will be useful, diff --git a/src/mvsd/executor.cpp b/src/mvsd/executor.cpp index 724fb7441..e32cbe75e 100644 --- a/src/mvsd/executor.cpp +++ b/src/mvsd/executor.cpp @@ -96,10 +96,10 @@ void executor::do_version() void executor::set_admin() { - data_base db(metadata_.configured.database); - db.start(); - db.set_admin("administerator", "mvsgo"); - db.stop(); + data_base db(metadata_.configured.database); + db.start(); + db.set_admin("administerator", "mvsgo"); + db.stop(); } void executor::set_blackhole_did() @@ -135,8 +135,8 @@ bool executor::do_initchain() remove_all(data_path); throw std::runtime_error{ "initialize chain failed" }; } - // init admin account - set_admin(); + // init admin account + set_admin(); // init blackhole DID set_blackhole_did(); log::info(LOG_SERVER) << BS_INITCHAIN_COMPLETE; @@ -184,9 +184,9 @@ bool executor::menu() return true; } - try - { - log::info(LOG_SERVER) << "mvsd version " << MVS_VERSION; + try + { + log::info(LOG_SERVER) << "mvsd version " << MVS_VERSION; // set block data absolute path const auto& directory = metadata_.configured.database.directory ; if (!directory.is_absolute()) { @@ -197,18 +197,18 @@ bool executor::menu() metadata_.configured.database.directory = directory / default_directory; } - auto result = do_initchain(); // false means no need to initial chain + auto result = do_initchain(); // false means no need to initial chain - if (config.initchain) - { - return result; - } - } - catch(const std::exception& e){ // initialize failed - //log::error(LOG_SERVER) << format(BS_INITCHAIN_EXISTS) % data_path; - log::error(LOG_SERVER) << "initialize chain failed," << e.what(); - return false; - } + if (config.initchain) + { + return result; + } + } + catch(const std::exception& e){ // initialize failed + //log::error(LOG_SERVER) << format(BS_INITCHAIN_EXISTS) % data_path; + log::error(LOG_SERVER) << "initialize chain failed," << e.what(); + return false; + } // There are no command line arguments, just run the server. return run(); @@ -308,7 +308,7 @@ void executor::handle_stop(int code) if(SIGINT != code) { - do_backtrace("signal.out"); + do_backtrace("signal.out"); } log::info(LOG_SERVER) << format(BS_NODE_SIGNALED) % code; diff --git a/src/mvsd/executor.hpp b/src/mvsd/executor.hpp index 2b72ae08f..a326e3a70 100644 --- a/src/mvsd/executor.hpp +++ b/src/mvsd/executor.hpp @@ -53,7 +53,7 @@ class executor void do_settings(); void do_version(); bool do_initchain(); - void set_admin(); + void set_admin(); void set_blackhole_did(); void initialize_output(); diff --git a/src/mvsd/mgbubble/HttpServ.cpp b/src/mvsd/mgbubble/HttpServ.cpp index c8447c43b..70f1590ac 100644 --- a/src/mvsd/mgbubble/HttpServ.cpp +++ b/src/mvsd/mgbubble/HttpServ.cpp @@ -69,7 +69,7 @@ void HttpServ::rpc_request(mg_connection& nc, HttpMessage data, uint8_t rpc_vers data.data_to_arg(rpc_version); Json::Value jv_output; - + auto retcode = explorer::dispatch_command(data.argc(), const_cast(data.argv()), jv_output, node_, rpc_version); @@ -107,7 +107,7 @@ void HttpServ::rpc_request(mg_connection& nc, HttpMessage data, uint8_t rpc_vers root["id"] = data.jsonrpc_id(); root["error"]["code"] = (int32_t)e.code(); root["error"]["message"] = e.what(); - + out_ << root.toStyledString(); } } diff --git a/src/mvsd/mgbubble/MgServer.cpp b/src/mvsd/mgbubble/MgServer.cpp index 020cba904..3cb32cb13 100644 --- a/src/mvsd/mgbubble/MgServer.cpp +++ b/src/mvsd/mgbubble/MgServer.cpp @@ -189,7 +189,7 @@ void MgServer::ev_handler(struct mg_connection *nc, int ev, void *ev_data) break; } case MG_EV_WEBSOCKET_HANDSHAKE_REQUEST: { - struct http_message *msg = (struct http_message *)ev_data; + struct http_message *msg = (struct http_message *)ev_data; self->on_ws_handshake_req_handler(*nc, *msg); break; } diff --git a/src/mvsd/mgbubble/WsPushServ.cpp b/src/mvsd/mgbubble/WsPushServ.cpp index ac2320a0d..d110f0e29 100644 --- a/src/mvsd/mgbubble/WsPushServ.cpp +++ b/src/mvsd/mgbubble/WsPushServ.cpp @@ -48,7 +48,7 @@ void WsPushServ::run() { node_.subscribe_transaction_pool( std::bind(&WsPushServ::handle_transaction_pool, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)); - + node_.subscribe_blockchain( std::bind(&WsPushServ::handle_blockchain_reorganization, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4)); @@ -113,7 +113,7 @@ void WsPushServ::notify_blocks(uint32_t fork_point, const block_list& blocks) { if (stopped()) return; - + auto height = fork_point; for (const auto block : blocks) @@ -229,7 +229,7 @@ void WsPushServ::send_bad_response(struct mg_connection& nc, const char* message result["data"] = data; root["event"] = EV_MG_ERROR; root["result"] = result; - + auto&& tmp = root.toStyledString(); send_frame(nc, tmp.c_str(), tmp.size()); } @@ -287,7 +287,7 @@ void WsPushServ::on_ws_frame_handler(struct mg_connection& nc, websocket_message try { const char* begin = (const char*)msg.data; const char* end = begin + msg.size; - if (!reader.parse(begin, end, root) || !root.isObject() + if (!reader.parse(begin, end, root) || !root.isObject() || !root["event"].isString() || !root["channel"].isString() || !root["address"].isString()) { stringstream ss; ss << "parse request error, " diff --git a/src/mvsd/server/interface/protocol.cpp b/src/mvsd/server/interface/protocol.cpp index 0ec1bac53..8d894d3b9 100644 --- a/src/mvsd/server/interface/protocol.cpp +++ b/src/mvsd/server/interface/protocol.cpp @@ -39,8 +39,8 @@ using namespace std::placeholders; void protocol::broadcast_transaction(server_node& node, const message& request, send_handler handler) { - using transaction_ptr = libbitcoin::blockchain::transaction_pool::transaction_ptr; - using indexes = libbitcoin::blockchain::transaction_pool::indexes; + using transaction_ptr = libbitcoin::blockchain::transaction_pool::transaction_ptr; + using indexes = libbitcoin::blockchain::transaction_pool::indexes; static const auto version = bc::message::version::level::maximum; transaction_ptr tx = std::make_shared();; // bc::message::transaction_message tx; @@ -58,10 +58,10 @@ void protocol::broadcast_transaction(server_node& node, const message& request, // node.broadcast(tx, ignore_send, ignore_complete); node.pool().store(tx, [tx](const code& ec, transaction_ptr){ - log::debug(LOG_SERVER) << encode_hash(tx->hash()) << " confirmed"; + log::debug(LOG_SERVER) << encode_hash(tx->hash()) << " confirmed"; }, [handler, request, tx](const code& ec, transaction_ptr, indexes){ - log::debug(LOG_SERVER) << encode_hash(tx->hash()) << " validated"; - handler(message(request, ec)); + log::debug(LOG_SERVER) << encode_hash(tx->hash()) << " validated"; + handler(message(request, ec)); }); // Tell the user everything is fine. diff --git a/src/mvsd/server/messages/message.cpp b/src/mvsd/server/messages/message.cpp index 7e41a90f2..2f44ecd0b 100644 --- a/src/mvsd/server/messages/message.cpp +++ b/src/mvsd/server/messages/message.cpp @@ -122,7 +122,7 @@ code message::receive(zmq::socket& socket) if (ec) return ec; - + if (message.size() < 5 || message.size() > 6) return error::bad_stream; diff --git a/src/mvsd/server/parser.cpp b/src/mvsd/server/parser.cpp index 5f2d4d023..e3f3fbf87 100644 --- a/src/mvsd/server/parser.cpp +++ b/src/mvsd/server/parser.cpp @@ -60,7 +60,7 @@ options_metadata parser::load_options() ( BS_CONFIG_VARIABLE ",c", value(&configured.file)-> - default_value("mvs.conf"), + default_value("mvs.conf"), "Specify path to a configuration settings file based on path ~/.metaverse" ) ( @@ -87,18 +87,18 @@ options_metadata parser::load_options() default_value(false)->zero_tokens(), "Display version information." ) - ( - BS_DAEMON_VARIABLE ",d", - value(&configured.daemon)-> - default_value(false)->zero_tokens(), - "Run in daemon mode (unix/apple)." - ) - ( - "testnet,t", - value(&configured.use_testnet_rules)-> - default_value(false)->zero_tokens(), - "Use testnet rules for determination of work required, defaults to false." - ) + ( + BS_DAEMON_VARIABLE ",d", + value(&configured.daemon)-> + default_value(false)->zero_tokens(), + "Run in daemon mode (unix/apple)." + ) + ( + "testnet,t", + value(&configured.use_testnet_rules)-> + default_value(false)->zero_tokens(), + "Use testnet rules for determination of work required, defaults to false." + ) ( BS_DATADIR_VARIABLE ",D", value(&configured.data_dir)-> @@ -117,7 +117,7 @@ options_metadata parser::load_options() default_value(true)->zero_tokens(), "Add a upnp map port in your router which has a extern address to allow connections to your local address." ) - ; + ; return description; } @@ -277,7 +277,7 @@ options_metadata parser::load_settings() "If broadcast your upnp extern address on the network to allow others find you and connect you." ) ( - "network.seed", + "network.seed", value(&configured.network.seeds), "A seed node for initializing the host pool, multiple entries allowed." ) @@ -344,11 +344,11 @@ options_metadata parser::load_settings() ) /* [server] */ - ( - "server.administrator_required", - value(&configured.server.administrator_required), - "Whether wallet needs administrator to execute non-account commands(shutdown/getinfo...), defaults to false." - ) + ( + "server.administrator_required", + value(&configured.server.administrator_required), + "Whether wallet needs administrator to execute non-account commands(shutdown/getinfo...), defaults to false." + ) ( "server.mongoose_listen", value(&configured.server.mongoose_listen), @@ -483,15 +483,15 @@ bool parser::parse(int argc, const char* argv[], std::ostream& error) load_environment_variables(variables, BS_ENVIRONMENT_VARIABLE_PREFIX); // Don't load the rest if any of these options are specified. - if (!get_option(variables, BS_VERSION_VARIABLE) && + if (!get_option(variables, BS_VERSION_VARIABLE) && !get_option(variables, BS_SETTINGS_VARIABLE) && !get_option(variables, BS_HELP_VARIABLE)) { - if (get_option(variables, BS_TESTNET_VARIABLE)) - { - configured.network.hosts_file = "hosts-test.cache"; - const_cast(variables[BS_CONFIG_VARIABLE].as()) = "mvs-test.conf"; - } + if (get_option(variables, BS_TESTNET_VARIABLE)) + { + configured.network.hosts_file = "hosts-test.cache"; + const_cast(variables[BS_CONFIG_VARIABLE].as()) = "mvs-test.conf"; + } auto data_dir = variables[BS_DATADIR_VARIABLE].as(); if (!data_dir.empty()) { diff --git a/src/mvsd/server/server_node.cpp b/src/mvsd/server/server_node.cpp index c6a4e9a98..141acc367 100644 --- a/src/mvsd/server/server_node.cpp +++ b/src/mvsd/server/server_node.cpp @@ -149,7 +149,7 @@ bool server_node::close() /// Get miner. consensus::miner& server_node::miner() { - return miner_; + return miner_; } // Notification. @@ -223,7 +223,7 @@ bool server_node::start_query_services() (settings.subscription_limit > 0 && !public_notification_worker_.start()) || !start_query_workers(false))) return false; - + return true; } diff --git a/src/mvsd/server/services/block_service.cpp b/src/mvsd/server/services/block_service.cpp index 419154c00..1ddbb30e0 100644 --- a/src/mvsd/server/services/block_service.cpp +++ b/src/mvsd/server/services/block_service.cpp @@ -151,7 +151,7 @@ bool block_service::handle_reorganization(const code& ec, uint64_t fork_point, return false; if (ec == error::mock) - return true; + return true; if (ec) { diff --git a/src/mvsd/server/services/transaction_service.cpp b/src/mvsd/server/services/transaction_service.cpp index 328a60050..1030a2b29 100644 --- a/src/mvsd/server/services/transaction_service.cpp +++ b/src/mvsd/server/services/transaction_service.cpp @@ -153,9 +153,9 @@ bool transaction_service::handle_transaction(const code& ec, const index_list&, return false; if (ec == (code)error::mock) - { - return true; - } + { + return true; + } if (ec) { diff --git a/src/mvsd/server/utility/fetch_helpers.cpp b/src/mvsd/server/utility/fetch_helpers.cpp index fb702d6d4..5841c97a7 100644 --- a/src/mvsd/server/utility/fetch_helpers.cpp +++ b/src/mvsd/server/utility/fetch_helpers.cpp @@ -110,12 +110,12 @@ bool unwrap_fetch_transaction_args(hash_digest& hash, void chain_transaction_fetched(const code& ec, const chain::transaction& tx, const message& request, send_handler handler) { - // wdy add for tx is null reference - if((code)error::not_found == ec) { - handler(message(request, error::not_found)); - return; - } - + // wdy add for tx is null reference + if((code)error::not_found == ec) { + handler(message(request, error::not_found)); + return; + } + const auto result = build_chunk( { message::to_bytes(ec), diff --git a/src/mvsd/server/workers/notification_worker.cpp b/src/mvsd/server/workers/notification_worker.cpp index ee4436952..fc90ead3f 100644 --- a/src/mvsd/server/workers/notification_worker.cpp +++ b/src/mvsd/server/workers/notification_worker.cpp @@ -83,10 +83,10 @@ bool notification_worker::start() if(settings_.block_service_enabled) { - // Subscribe to blockchain reorganizations. - node_.subscribe_blockchain( - std::bind(¬ification_worker::handle_blockchain_reorganization, - this, _1, _2, _3, _4)); + // Subscribe to blockchain reorganizations. + node_.subscribe_blockchain( + std::bind(¬ification_worker::handle_blockchain_reorganization, + this, _1, _2, _3, _4)); } // Subscribe to transaction pool acceptances. @@ -264,7 +264,7 @@ void notification_worker::send_payment(const route& reply_to, uint32_t id, block_hash, tx.to_data() }); - + send(reply_to, address_update, id, payload); } @@ -572,9 +572,9 @@ bool notification_worker::handle_transaction_pool(const code& ec, return false; if (ec == (code)error::mock) - { - return true; - } + { + return true; + } if (ec) { diff --git a/src/windows/mvstray/mvstray.cpp b/src/windows/mvstray/mvstray.cpp index fe8d78f85..9ca000d86 100644 --- a/src/windows/mvstray/mvstray.cpp +++ b/src/windows/mvstray/mvstray.cpp @@ -19,7 +19,7 @@ * along with this program. If not, see . */ -#define WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN #include #include #include @@ -190,11 +190,11 @@ bool InitInstance(HINSTANCE hInstance, int nCmdShow, LPWSTR cmdLine) HICON hMainIcon = LoadIcon(hInstance, (LPCTSTR)MAKEINTRESOURCE(IDI_MVSTRAY)); - nidApp.cbSize = sizeof(NOTIFYICONDATA); // sizeof the struct in bytes - nidApp.hWnd = (HWND)hWnd; //handle of the window which will process this app. messages - nidApp.uID = IDI_MVSTRAY; //ID of the icon that will appear in the system tray - nidApp.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP; //ORing of all the flags - nidApp.hIcon = hMainIcon; // handle of the Icon to be displayed, obtained from LoadIcon + nidApp.cbSize = sizeof(NOTIFYICONDATA); // sizeof the struct in bytes + nidApp.hWnd = (HWND)hWnd; //handle of the window which will process this app. messages + nidApp.uID = IDI_MVSTRAY; //ID of the icon that will appear in the system tray + nidApp.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP; //ORing of all the flags + nidApp.hIcon = hMainIcon; // handle of the Icon to be displayed, obtained from LoadIcon nidApp.uCallbackMessage = WM_USER_SHELLICON; LoadString(hInstance, IDS_CONTROL_METAVERSE, nidApp.szTip, MAX_LOADSTRING); Shell_NotifyIcon(NIM_ADD, &nidApp); @@ -203,7 +203,7 @@ bool InitInstance(HINSTANCE hInstance, int nCmdShow, LPWSTR cmdLine) if (!bUIOpened) { SetTimer(hWnd, WM_TIMER_OPEN, 1000, nullptr); } - + return true; } @@ -213,7 +213,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) switch (message) { case WM_USER_SHELLICON: - // systray msg callback + // systray msg callback POINT lpClickPoint; switch (LOWORD(lParam)) { @@ -276,7 +276,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) else if (!MetaverseIsRunning()) { DestroyWindow(hWnd); } - } + } break; default: return DefWindowProc(hWnd, message, wParam, lParam); @@ -336,7 +336,7 @@ void EnableAutostart(bool enable) { if (lRes != ERROR_SUCCESS) return; - if (enable) + if (enable) { LPWSTR args = new WCHAR[lstrlen(commandLineFiltered) + MAX_PATH + 2]; if (GetTrayExePath(args, MAX_PATH))