danicoin/src/cryptonote_core/cryptonote_boost_serialization.h

153 lines
4.8 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>
#include "cryptonote_basic.h"
2015-05-27 12:08:46 +00:00
#include "Common/unordered_containers_boost_serialization.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>
inline void serialize(Archive &a, crypto::public_key &x, const boost::serialization::version_type ver)
{
a & reinterpret_cast<char (&)[sizeof(crypto::public_key)]>(x);
}
template <class Archive>
inline void serialize(Archive &a, crypto::secret_key &x, const boost::serialization::version_type ver)
{
a & reinterpret_cast<char (&)[sizeof(crypto::secret_key)]>(x);
}
template <class Archive>
inline void serialize(Archive &a, crypto::key_derivation &x, const boost::serialization::version_type ver)
{
a & reinterpret_cast<char (&)[sizeof(crypto::key_derivation)]>(x);
}
template <class Archive>
inline void serialize(Archive &a, crypto::key_image &x, const boost::serialization::version_type ver)
{
a & reinterpret_cast<char (&)[sizeof(crypto::key_image)]>(x);
}
template <class Archive>
inline void serialize(Archive &a, crypto::signature &x, const boost::serialization::version_type ver)
{
a & reinterpret_cast<char (&)[sizeof(crypto::signature)]>(x);
}
template <class Archive>
inline void serialize(Archive &a, crypto::hash &x, const boost::serialization::version_type ver)
{
a & reinterpret_cast<char (&)[sizeof(crypto::hash)]>(x);
}
2015-05-27 12:08:46 +00:00
template <class Archive> void serialize(Archive& archive, CryptoNote::TransactionInputToScript&, unsigned int version) {
2014-08-13 10:51:37 +00:00
assert(false);
2014-03-03 22:07:58 +00:00
}
2015-05-27 12:08:46 +00:00
template <class Archive> void serialize(Archive& archive, CryptoNote::TransactionInputToScriptHash&, unsigned int version) {
2014-08-13 10:51:37 +00:00
assert(false);
}
2014-03-03 22:07:58 +00:00
2015-05-27 12:08:46 +00:00
template <class Archive> void serialize(Archive& archive, CryptoNote::TransactionOutputToScript&, unsigned int version) {
2014-08-13 10:51:37 +00:00
assert(false);
2014-03-03 22:07:58 +00:00
}
2015-05-27 12:08:46 +00:00
template <class Archive> void serialize(Archive& archive, CryptoNote::TransactionOutputToScriptHash&, unsigned int version) {
2014-08-13 10:51:37 +00:00
assert(false);
2014-03-03 22:07:58 +00:00
}
2015-05-27 12:08:46 +00:00
template <class Archive> void serialize(Archive& archive, CryptoNote::TransactionInputMultisignature &output, unsigned int version) {
2014-08-13 10:51:37 +00:00
archive & output.amount;
archive & output.signatures;
archive & output.outputIndex;
}
2015-05-27 12:08:46 +00:00
template <class Archive> void serialize(Archive& archive, CryptoNote::TransactionOutputMultisignature &output, unsigned int version) {
2014-08-13 10:51:37 +00:00
archive & output.keys;
archive & output.requiredSignatures;
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::TransactionOutputToKey &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-05-27 12:08:46 +00:00
inline void serialize(Archive &a, CryptoNote::TransactionInputGenerate &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.height;
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::TransactionInputToKey &x, const boost::serialization::version_type ver)
2014-03-03 22:07:58 +00:00
{
a & x.amount;
2014-08-13 10:51:37 +00:00
a & x.keyOffsets;
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;
2014-03-03 22:07:58 +00:00
a & x.vin;
a & x.vout;
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;
2014-08-13 10:51:37 +00:00
a & b.prevId;
2014-03-03 22:07:58 +00:00
a & b.nonce;
//------------------
2014-08-13 10:51:37 +00:00
a & b.minerTx;
a & b.txHashes;
2014-03-03 22:07:58 +00:00
}
}
}
//}