danicoin/tests/CoreTests/CryptoNoteBoostSerialization.h

124 lines
3.7 KiB
C
Raw Normal View History

// Copyright (c) 2011-2016 The Cryptonote developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
2014-03-03 22:07:58 +00:00
#pragma once
#include <boost/serialization/vector.hpp>
#include <boost/serialization/utility.hpp>
#include <boost/serialization/variant.hpp>
#include <boost/serialization/set.hpp>
#include <boost/serialization/map.hpp>
#include <boost/foreach.hpp>
#include <boost/serialization/is_bitwise_serializable.hpp>
2015-07-30 15:22:07 +00:00
#include "CryptoNoteCore/CryptoNoteBasic.h"
#include "UnorderedContainersBoostSerialization.h"
2014-03-03 22:07:58 +00:00
#include "crypto/crypto.h"
2015-05-27 12:08:46 +00:00
//namespace CryptoNote {
2014-03-03 22:07:58 +00:00
namespace boost
{
namespace serialization
{
//---------------------------------------------------
template <class Archive>
2015-07-30 15:22:07 +00:00
inline void serialize(Archive &a, Crypto::PublicKey &x, const boost::serialization::version_type ver)
2014-03-03 22:07:58 +00:00
{
2015-07-30 15:22:07 +00:00
a & reinterpret_cast<char (&)[sizeof(Crypto::PublicKey)]>(x);
2014-03-03 22:07:58 +00:00
}
template <class Archive>
2015-07-30 15:22:07 +00:00
inline void serialize(Archive &a, Crypto::SecretKey &x, const boost::serialization::version_type ver)
2014-03-03 22:07:58 +00:00
{
2015-07-30 15:22:07 +00:00
a & reinterpret_cast<char (&)[sizeof(Crypto::SecretKey)]>(x);
2014-03-03 22:07:58 +00:00
}
template <class Archive>
2015-07-30 15:22:07 +00:00
inline void serialize(Archive &a, Crypto::KeyDerivation &x, const boost::serialization::version_type ver)
2014-03-03 22:07:58 +00:00
{
2015-07-30 15:22:07 +00:00
a & reinterpret_cast<char (&)[sizeof(Crypto::KeyDerivation)]>(x);
2014-03-03 22:07:58 +00:00
}
template <class Archive>
2015-07-30 15:22:07 +00:00
inline void serialize(Archive &a, Crypto::KeyImage &x, const boost::serialization::version_type ver)
2014-03-03 22:07:58 +00:00
{
2015-07-30 15:22:07 +00:00
a & reinterpret_cast<char (&)[sizeof(Crypto::KeyImage)]>(x);
2014-03-03 22:07:58 +00:00
}
template <class Archive>
2015-07-30 15:22:07 +00:00
inline void serialize(Archive &a, Crypto::Signature &x, const boost::serialization::version_type ver)
2014-03-03 22:07:58 +00:00
{
2015-07-30 15:22:07 +00:00
a & reinterpret_cast<char (&)[sizeof(Crypto::Signature)]>(x);
2014-03-03 22:07:58 +00:00
}
template <class Archive>
2015-07-30 15:22:07 +00:00
inline void serialize(Archive &a, Crypto::Hash &x, const boost::serialization::version_type ver)
2014-03-03 22:07:58 +00:00
{
2015-07-30 15:22:07 +00:00
a & reinterpret_cast<char (&)[sizeof(Crypto::Hash)]>(x);
2014-03-03 22:07:58 +00:00
}
2015-07-30 15:22:07 +00:00
template <class Archive> void serialize(Archive& archive, CryptoNote::MultisignatureInput &output, unsigned int version) {
2014-08-13 10:51:37 +00:00
archive & output.amount;
2015-07-30 15:22:07 +00:00
archive & output.signatureCount;
2014-08-13 10:51:37 +00:00
archive & output.outputIndex;
}
2015-07-30 15:22:07 +00:00
template <class Archive> void serialize(Archive& archive, CryptoNote::MultisignatureOutput &output, unsigned int version) {
2014-08-13 10:51:37 +00:00
archive & output.keys;
2015-07-30 15:22:07 +00:00
archive & output.requiredSignatureCount;
2014-03-03 22:07:58 +00:00
}
template <class Archive>
2015-07-30 15:22:07 +00:00
inline void serialize(Archive &a, CryptoNote::KeyOutput &x, const boost::serialization::version_type ver)
2014-03-03 22:07:58 +00:00
{
2014-08-13 10:51:37 +00:00
a & x.key;
2014-03-03 22:07:58 +00:00
}
template <class Archive>
2015-07-30 15:22:07 +00:00
inline void serialize(Archive &a, CryptoNote::BaseInput &x, const boost::serialization::version_type ver)
2014-03-03 22:07:58 +00:00
{
2015-07-30 15:22:07 +00:00
a & x.blockIndex;
2014-03-03 22:07:58 +00:00
}
template <class Archive>
2015-07-30 15:22:07 +00:00
inline void serialize(Archive &a, CryptoNote::KeyInput &x, const boost::serialization::version_type ver)
2014-03-03 22:07:58 +00:00
{
a & x.amount;
2015-07-30 15:22:07 +00:00
a & x.outputIndexes;
2014-08-13 10:51:37 +00:00
a & x.keyImage;
2014-03-03 22:07:58 +00:00
}
template <class Archive>
2015-05-27 12:08:46 +00:00
inline void serialize(Archive &a, CryptoNote::TransactionOutput &x, const boost::serialization::version_type ver)
2014-03-03 22:07:58 +00:00
{
a & x.amount;
a & x.target;
}
template <class Archive>
2015-05-27 12:08:46 +00:00
inline void serialize(Archive &a, CryptoNote::Transaction &x, const boost::serialization::version_type ver)
2014-03-03 22:07:58 +00:00
{
a & x.version;
2014-08-13 10:51:37 +00:00
a & x.unlockTime;
2015-07-30 15:22:07 +00:00
a & x.inputs;
a & x.outputs;
2014-03-03 22:07:58 +00:00
a & x.extra;
a & x.signatures;
}
template <class Archive>
2015-05-27 12:08:46 +00:00
inline void serialize(Archive &a, CryptoNote::Block &b, const boost::serialization::version_type ver)
2014-03-03 22:07:58 +00:00
{
2014-08-13 10:51:37 +00:00
a & b.majorVersion;
a & b.minorVersion;
2014-03-03 22:07:58 +00:00
a & b.timestamp;
2015-07-30 15:22:07 +00:00
a & b.previousBlockHash;
2014-03-03 22:07:58 +00:00
a & b.nonce;
//------------------
2015-07-30 15:22:07 +00:00
a & b.baseTransaction;
a & b.transactionHashes;
2014-03-03 22:07:58 +00:00
}
}
}
//}