forked from lthn/blockchain
fixed linux serialization
This commit is contained in:
parent
afea59a25a
commit
6f3c2fcbcc
5 changed files with 46 additions and 24 deletions
|
|
@ -61,7 +61,7 @@ namespace currency
|
|||
typedef boost::multiprecision::uint128_t uint128_tl;
|
||||
struct tx_source_entry
|
||||
{
|
||||
typedef std::pair<txout_v, crypto::public_key> output_entry; // txout_v is either global output index or ref_by_id; public_key - is output ephemeral pub key
|
||||
typedef serializable_pair<txout_v, crypto::public_key> output_entry; // txout_v is either global output index or ref_by_id; public_key - is output ephemeral pub key
|
||||
|
||||
std::vector<output_entry> outputs; //index + key
|
||||
uint64_t real_output; //index in outputs vector of real output_entry
|
||||
|
|
|
|||
|
|
@ -110,6 +110,31 @@ do { \
|
|||
if (!r || !ar.stream().good()) return false; \
|
||||
} while (0);
|
||||
|
||||
template<typename first_type, typename second_type>
|
||||
class serializable_pair : public std::pair<first_type, second_type>
|
||||
{
|
||||
typedef std::pair<first_type, second_type> base;
|
||||
public:
|
||||
serializable_pair()
|
||||
{}
|
||||
serializable_pair(const first_type& a, const second_type& b) :std::pair<first_type, second_type>(a, b)
|
||||
{}
|
||||
serializable_pair(const serializable_pair& sp) :std::pair<first_type, second_type>(sp.first, sp.second)
|
||||
{}
|
||||
|
||||
BEGIN_SERIALIZE_OBJECT()
|
||||
FIELD(base::first)
|
||||
FIELD(base::second)
|
||||
END_SERIALIZE()
|
||||
};
|
||||
|
||||
template<typename first_type, typename second_type>
|
||||
serializable_pair<first_type, second_type> make_serializable_pair(const first_type& first_value, const second_type& second_value)
|
||||
{
|
||||
return serializable_pair<first_type, second_type>(first_value, second_value);
|
||||
}
|
||||
|
||||
|
||||
namespace serialization {
|
||||
namespace detail
|
||||
{
|
||||
|
|
|
|||
|
|
@ -9,12 +9,28 @@
|
|||
#include <vector>
|
||||
#include <list>
|
||||
|
||||
//#include "serialization.h"
|
||||
template <template <bool> class Archive, class T>
|
||||
bool do_serialize(Archive<false> &ar, std::vector<T> &v);
|
||||
template <template <bool> class Archive, class T>
|
||||
bool do_serialize(Archive<true> &ar, std::vector<T> &v);
|
||||
|
||||
namespace serialization
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
template <typename Archive, class T>
|
||||
bool serialize_container_element(Archive& ar, T& e);
|
||||
bool serialize_container_element(Archive& ar, T& e)
|
||||
{
|
||||
return ::do_serialize(ar, e);
|
||||
}
|
||||
|
||||
template <typename Archive>
|
||||
bool serialize_container_element(Archive& ar, uint64_t& e)
|
||||
{
|
||||
ar.serialize_varint(e);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -249,23 +265,4 @@ bool do_serialize(Archive<true> &ar, std::vector<bool> &v)
|
|||
}
|
||||
ar.end_array();
|
||||
return true;
|
||||
}
|
||||
|
||||
namespace serialization
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
template <typename Archive, class T>
|
||||
bool serialize_container_element(Archive& ar, T& e)
|
||||
{
|
||||
return ::do_serialize(ar, e);
|
||||
}
|
||||
|
||||
template <typename Archive>
|
||||
bool serialize_container_element(Archive& ar, uint64_t& e)
|
||||
{
|
||||
ar.serialize_varint(e);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2272,7 +2272,7 @@ void wallet2::sign_transfer(const std::string& tx_sources_blob, std::string& sig
|
|||
crypto::key_image ki = AUTO_VAL_INIT(ki);
|
||||
crypto::generate_key_image(ephemeral_pub, ephemeral_sec, ki);
|
||||
|
||||
ft.outs_key_images.push_back(std::make_pair(static_cast<uint64_t>(i), ki));
|
||||
ft.outs_key_images.push_back(make_serializable_pair(static_cast<uint64_t>(i), ki));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -293,7 +293,7 @@ namespace tools
|
|||
currency::transaction tx;
|
||||
crypto::secret_key one_time_key;
|
||||
finalize_tx_param ftp;
|
||||
std::vector<std::pair<uint64_t, crypto::key_image>> outs_key_images; // pairs (out_index, key_image) for each change output
|
||||
std::vector<serializable_pair<uint64_t, crypto::key_image>> outs_key_images; // pairs (out_index, key_image) for each change output
|
||||
|
||||
BEGIN_SERIALIZE_OBJECT()
|
||||
FIELD(tx)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue