Skip to content

Commit

Permalink
Merge pull request #332 from mvs-org/0.8.4
Browse files Browse the repository at this point in the history
Release 0.8.4
  • Loading branch information
codrush authored Sep 25, 2018
2 parents 4bb075f + cf5545a commit db59e28
Show file tree
Hide file tree
Showing 97 changed files with 1,817 additions and 1,462 deletions.
3 changes: 3 additions & 0 deletions builds/msvc-140/bitcoin/bitcoin.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
<ClCompile Include="..\..\..\src\lib\bitcoin\chain\header.cpp" />
<ClCompile Include="..\..\..\src\lib\bitcoin\chain\input.cpp" />
<ClCompile Include="..\..\..\src\lib\bitcoin\chain\output.cpp" />
<ClCompile Include="..\..\..\src\lib\bitcoin\chain\output_point.cpp" />
<ClCompile Include="..\..\..\src\lib\bitcoin\chain\point.cpp" />
<ClCompile Include="..\..\..\src\lib\bitcoin\chain\point_iterator.cpp" />
<ClCompile Include="..\..\..\src\lib\bitcoin\chain\script\conditional_stack.cpp" />
Expand Down Expand Up @@ -166,6 +167,7 @@
<ClCompile Include="..\..\..\src\lib\bitcoin\wallet\uri.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\..\include\metaverse\bitcoin\base_primary.hpp" />
<ClInclude Include="..\..\..\include\metaverse\bitcoin\chain\attachment\account\account.hpp" />
<ClInclude Include="..\..\..\include\metaverse\bitcoin\chain\attachment\account\account_address.hpp" />
<ClInclude Include="..\..\..\include\metaverse\bitcoin\chain\attachment\asset\asset.hpp" />
Expand Down Expand Up @@ -357,6 +359,7 @@
<ClInclude Include="..\..\..\src\lib\bitcoin\wallet\parse_encrypted_keys\parse_encrypted_token.hpp" />
</ItemGroup>
<ItemGroup>
<None Include="..\..\..\include\metaverse\bitcoin\impl\base_primary.ipp" />
<None Include="..\..\..\include\metaverse\bitcoin\impl\formats\base_16.ipp" />
<None Include="..\..\..\include\metaverse\bitcoin\impl\formats\base_58.ipp" />
<None Include="..\..\..\include\metaverse\bitcoin\impl\math\checksum.ipp" />
Expand Down
9 changes: 9 additions & 0 deletions builds/msvc-140/bitcoin/bitcoin.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,9 @@
<ClCompile Include="..\..\..\src\lib\bitcoin\chain\attachment\asset\asset_mit.cpp">
<Filter>Source Files\chain\attachment\asset</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\lib\bitcoin\chain\output_point.cpp">
<Filter>Source Files\chain</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\..\src\lib\bitcoin\math\secp256k1_initializer.hpp">
Expand Down Expand Up @@ -1147,6 +1150,9 @@
<ClInclude Include="..\..\..\include\metaverse\bitcoin\chain\attachment\asset\asset_mit.hpp">
<Filter>Header Files\chain\attachment\asset</Filter>
</ClInclude>
<ClInclude Include="..\..\..\include\metaverse\bitcoin\base_primary.hpp">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="..\..\..\src\lib\bitcoin\wallet\parse_encrypted_keys\parse_encrypted_key.ipp">
Expand Down Expand Up @@ -1203,5 +1209,8 @@
<None Include="..\..\..\include\metaverse\bitcoin\impl\utility\array_slice.ipp">
<Filter>Header Files\impl\utility</Filter>
</None>
<None Include="..\..\..\include\metaverse\bitcoin\impl\base_primary.ipp">
<Filter>Header Files\impl</Filter>
</None>
</ItemGroup>
</Project>
82 changes: 82 additions & 0 deletions include/metaverse/bitcoin/base_primary.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
/**
* Copyright (c) 2011-2015 metaverse developers (see AUTHORS)
*
* This file is part of mvs-node.
*
* metaverse 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)
* any later version. For more information see LICENSE.
*
* This program 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef MVS_BASE_PRIMARY_HPP
#define MVS_BASE_PRIMARY_HPP

#include <cstdint>
#include <istream>
#include <vector>
#include <metaverse/bitcoin/utility/reader.hpp>
#include <metaverse/bitcoin/utility/writer.hpp>
#include <metaverse/bitcoin/utility/container_sink.hpp>

namespace libbitcoin {

template<class T>
class base_primary
{
public:
T& Instance();
const T& Instance() const;
//
template <typename... Args>
static T factory_from_data(const data_chunk &data, Args... args);

template <typename... Args>
static T factory_from_data(std::istream& stream, Args... args);

template<typename... Args>
static T factory_from_data(reader& source, Args... args);

template<typename... Args>
bool from_data(const data_chunk& data, Args... args);

template<typename... Args>
bool from_data(std::istream& stream, Args... args);

template<typename... Args>
bool from_data(reader& source, Args... args);

data_chunk to_data() const;

template<typename T1_, typename T2_ = typename std::decay<T1_>::type,
typename std::enable_if< (!std::is_base_of<std::ostream, T2_>::value
&& !std::is_base_of<writer, T2_>::value )>::type* = nullptr, typename... Args>
data_chunk to_data(T1_&& t , Args... args) const;

template<typename... Args >
void to_data(std::ostream& stream, Args... args) const;

template<typename... Args>
void to_data(writer& sink, Args... args) const;

private:
base_primary(){}
friend T;
};



} // namespace libbitcoin

#include <metaverse/bitcoin/impl/base_primary.ipp>

#endif

13 changes: 4 additions & 9 deletions include/metaverse/bitcoin/chain/attachment/account/account.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include <metaverse/bitcoin/utility/reader.hpp>
#include <metaverse/bitcoin/utility/writer.hpp>
#include <metaverse/bitcoin/formats/base_16.hpp>
#include <metaverse/bitcoin/base_primary.hpp>

namespace libbitcoin {
namespace chain {
Expand Down Expand Up @@ -119,23 +120,17 @@ class BC_API account_multisig
};

class BC_API account
: public base_primary<account>
{
public:
account();
account(const std::string& name, const std::string& mnemonic, const hash_digest& passwd,
uint32_t hd_index, uint8_t priority, uint8_t status, uint8_t type);

static account factory_from_data(const data_chunk& data);
static account factory_from_data(std::istream& stream);
static account factory_from_data(reader& source);
static uint64_t satoshi_fixed_size();

bool from_data(const data_chunk& data);
bool from_data(std::istream& stream);
bool from_data(reader& source);
data_chunk to_data() const;
void to_data(std::ostream& stream) const;
void to_data(writer& sink) const;
bool from_data_t(reader& source);
void to_data_t(writer& sink) const;

bool is_valid() const;
void reset();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <metaverse/bitcoin/define.hpp>
#include <metaverse/bitcoin/utility/reader.hpp>
#include <metaverse/bitcoin/utility/writer.hpp>
#include <metaverse/bitcoin/base_primary.hpp>

namespace libbitcoin {
namespace chain {
Expand All @@ -50,7 +51,8 @@ enum account_address_status : uint8_t
stealth_addr = 3 // stealth address
};

class BC_API account_address
class BC_API account_address
: public base_primary<account_address>
{
public:
typedef std::vector<account_address> list;
Expand All @@ -59,17 +61,10 @@ class BC_API account_address
const std::string& pub_key, uint32_t hd_index, uint64_t balance,
const std::string& alias, const std::string& address, uint8_t status);
account_address(const account_address& other);
static account_address factory_from_data(const data_chunk& data);
static account_address factory_from_data(std::istream& stream);
static account_address factory_from_data(reader& source);
static uint64_t satoshi_fixed_size();

bool from_data(const data_chunk& data);
bool from_data(std::istream& stream);
bool from_data(reader& source);
data_chunk to_data() const;
void to_data(std::ostream& stream) const;
void to_data(writer& sink) const;
bool from_data_t(reader& source);
void to_data_t(writer& sink) const;
#ifdef MVS_DEBUG
std::string to_string() ;
#endif
Expand Down
13 changes: 4 additions & 9 deletions include/metaverse/bitcoin/chain/attachment/asset/asset.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include <boost/variant.hpp>
#include <metaverse/bitcoin/chain/attachment/asset/asset_detail.hpp>
#include <metaverse/bitcoin/chain/attachment/asset/asset_transfer.hpp>
#include <metaverse/bitcoin/base_primary.hpp>

using namespace libbitcoin::chain;

Expand All @@ -43,6 +44,7 @@ namespace libbitcoin {
namespace chain {

class BC_API asset
: public base_primary<asset>
{
public:
enum class asset_status : uint32_t
Expand All @@ -56,17 +58,10 @@ class BC_API asset
asset();
asset(uint32_t status, const asset_detail& detail);
asset(uint32_t status, const asset_transfer& detail);
static asset factory_from_data(const data_chunk& data);
static asset factory_from_data(std::istream& stream);
static asset factory_from_data(reader& source);
static uint64_t satoshi_fixed_size();

bool from_data(const data_chunk& data);
bool from_data(std::istream& stream);
bool from_data(reader& source);
data_chunk to_data() const;
void to_data(std::ostream& stream) const;
void to_data(writer& sink) const;
bool from_data_t(reader& source);
void to_data_t(writer& sink) const;
std::string to_string() const;
bool is_valid_type() const;
bool is_valid() const;
Expand Down
14 changes: 4 additions & 10 deletions include/metaverse/bitcoin/chain/attachment/asset/asset_cert.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <metaverse/bitcoin/error.hpp>
#include <metaverse/bitcoin/utility/reader.hpp>
#include <metaverse/bitcoin/utility/writer.hpp>
#include <metaverse/bitcoin/base_primary.hpp>

#define ASSET_CERT_STATUS2UINT32(kd) (static_cast<typename std::underlying_type<asset_cert::asset_cert_status>::type>(kd))

Expand Down Expand Up @@ -59,6 +60,7 @@ namespace asset_cert_ns {
}

class BC_API asset_cert
: public base_primary<asset_cert>
{
public:
typedef std::vector<asset_cert> list;
Expand All @@ -79,16 +81,8 @@ class BC_API asset_cert
bool is_valid() const;
bool operator< (const asset_cert& other) const;

static asset_cert factory_from_data(const data_chunk& data);
static asset_cert factory_from_data(std::istream& stream);
static asset_cert factory_from_data(reader& source);

bool from_data(const data_chunk& data);
bool from_data(std::istream& stream);
bool from_data(reader& source);
data_chunk to_data() const;
void to_data(std::ostream& stream) const;
void to_data(writer& sink) const;
bool from_data_t(reader& source);
void to_data_t(writer& sink) const;

std::string to_string() const;
uint64_t serialized_size() const;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <metaverse/bitcoin/define.hpp>
#include <metaverse/bitcoin/utility/reader.hpp>
#include <metaverse/bitcoin/utility/writer.hpp>
#include <metaverse/bitcoin/base_primary.hpp>
#include "asset_cert.hpp"

namespace libbitcoin {
Expand All @@ -48,6 +49,7 @@ BC_CONSTEXPR size_t ASSET_DETAIL_FIX_SIZE = ASSET_DETAIL_SYMBOL_FIX_SIZE
+ ASSET_DETAIL_DESCRIPTION_FIX_SIZE;

class BC_API asset_detail
: public base_primary<asset_detail>
{
public:
typedef std::vector<asset_detail> list;
Expand All @@ -61,16 +63,9 @@ class BC_API asset_detail
uint8_t decimal_number, uint8_t threshold, const std::string& issuer,
const std::string& address, const std::string& description);

static asset_detail factory_from_data(const data_chunk& data);
static asset_detail factory_from_data(std::istream& stream);
static asset_detail factory_from_data(reader& source);
static uint64_t satoshi_fixed_size();
bool from_data(const data_chunk& data);
bool from_data(std::istream& stream);
bool from_data(reader& source);
data_chunk to_data() const;
void to_data(std::ostream& stream) const;
void to_data(writer& sink) const;
bool from_data_t(reader& source);
void to_data_t(writer& sink) const;

bool operator< (const asset_detail& other) const;
std::string to_string() const;
Expand Down
14 changes: 4 additions & 10 deletions include/metaverse/bitcoin/chain/attachment/asset/asset_mit.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include <metaverse/bitcoin/error.hpp>
#include <metaverse/bitcoin/utility/reader.hpp>
#include <metaverse/bitcoin/utility/writer.hpp>
#include <metaverse/bitcoin/base_primary.hpp>

#define MIT_STATUS2UINT32(kd) (static_cast<typename std::underlying_type<asset_mit::mit_status>::type>(kd))

Expand Down Expand Up @@ -54,6 +55,7 @@ BC_CONSTEXPR size_t ASSET_MIT_TRANSFER_FIX_SIZE = (
BC_CONSTEXPR size_t ASSET_MIT_INFO_FIX_SIZE = 4 + 4 + 64 + ASSET_MIT_TRANSFER_FIX_SIZE;

class BC_API asset_mit
: public base_primary<asset_mit>
{
public:
typedef std::vector<asset_mit> list;
Expand All @@ -74,17 +76,9 @@ class BC_API asset_mit
bool is_valid() const;
bool operator< (const asset_mit& other) const;

static asset_mit factory_from_data(const data_chunk& data);
static asset_mit factory_from_data(std::istream& stream);
static asset_mit factory_from_data(reader& source);

bool from_data(const data_chunk& data);
bool from_data(std::istream& stream);
bool from_data(reader& source);
bool from_data_t(reader& source);
void to_data_t(writer& sink) const;
data_chunk to_short_data() const;
data_chunk to_data() const;
void to_data(std::ostream& stream) const;
void to_data(writer& sink) const;

std::string to_string() const;
uint64_t serialized_size() const;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#include <metaverse/bitcoin/define.hpp>
#include <metaverse/bitcoin/utility/reader.hpp>
#include <metaverse/bitcoin/utility/writer.hpp>
#include <metaverse/bitcoin/chain/history.hpp>
#include <metaverse/bitcoin/base_primary.hpp>

namespace libbitcoin {
namespace chain {
Expand Down Expand Up @@ -81,21 +81,15 @@ struct asset_deposited_balance {
};

class BC_API asset_transfer
: public base_primary<asset_transfer>
{
public:
asset_transfer();
asset_transfer(const std::string& symbol, uint64_t quantity);
static asset_transfer factory_from_data(const data_chunk& data);
static asset_transfer factory_from_data(std::istream& stream);
static asset_transfer factory_from_data(reader& source);
static uint64_t satoshi_fixed_size();

bool from_data(const data_chunk& data);
bool from_data(std::istream& stream);
bool from_data(reader& source);
data_chunk to_data() const;
void to_data(std::ostream& stream) const;
void to_data(writer& sink) const;
bool from_data_t(reader& source);
void to_data_t(writer& sink) const;

std::string to_string() const;

Expand Down
Loading

0 comments on commit db59e28

Please sign in to comment.