danicoin/tests/CoreTests/CryptoNoteBoostSerialization.h

137 lines
4.2 KiB
C
Raw Normal View History

2015-05-27 12:08:46 +00:00
// Copyright (c) 2012-2015, The CryptoNote developers, The Bytecoin developers
2014-08-13 10:38:35 +00:00
//
// This file is part of Bytecoin.
//
// Bytecoin is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Bytecoin 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 Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with Bytecoin. If not, see <http://www.gnu.org/licenses/>.
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
}
}
}
//}