danicoin/src/CryptoNoteProtocol/CryptoNoteProtocolDefinitions.h

213 lines
5.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 <list>
2015-07-30 15:22:07 +00:00
#include "CryptoNoteCore/CryptoNoteBasic.h"
2014-03-03 22:07:58 +00:00
2015-07-15 12:23:00 +00:00
// ISerializer-based serialization
2015-07-30 15:22:07 +00:00
#include "Serialization/ISerializer.h"
#include "Serialization/SerializationOverloads.h"
#include "CryptoNoteCore/CryptoNoteSerialization.h"
2014-03-03 22:07:58 +00:00
2015-05-27 12:08:46 +00:00
namespace CryptoNote
{
2014-03-03 22:07:58 +00:00
2015-05-27 12:08:46 +00:00
#define BC_COMMANDS_POOL_BASE 2000
2014-03-03 22:07:58 +00:00
/************************************************************************/
/* */
/************************************************************************/
struct block_complete_entry
{
2015-07-30 15:22:07 +00:00
std::string block;
std::vector<std::string> txs;
2015-07-15 12:23:00 +00:00
void serialize(ISerializer& s) {
KV_MEMBER(block);
KV_MEMBER(txs);
}
2014-03-03 22:07:58 +00:00
};
struct BlockFullInfo : public block_complete_entry
{
2015-07-30 15:22:07 +00:00
Crypto::Hash block_id;
2015-07-15 12:23:00 +00:00
void serialize(ISerializer& s) {
KV_MEMBER(block_id);
KV_MEMBER(block);
KV_MEMBER(txs);
}
2015-07-30 15:22:07 +00:00
};
struct TransactionPrefixInfo {
Crypto::Hash txHash;
TransactionPrefix txPrefix;
void serialize(ISerializer& s) {
KV_MEMBER(txHash);
KV_MEMBER(txPrefix);
}
};
struct BlockShortInfo {
Crypto::Hash blockId;
std::string block;
std::vector<TransactionPrefixInfo> txPrefixes;
2015-07-15 12:23:00 +00:00
2015-07-30 15:22:07 +00:00
void serialize(ISerializer& s) {
KV_MEMBER(blockId);
KV_MEMBER(block);
KV_MEMBER(txPrefixes);
}
};
2014-03-03 22:07:58 +00:00
/************************************************************************/
/* */
/************************************************************************/
2014-08-13 10:51:37 +00:00
struct NOTIFY_NEW_BLOCK_request
2014-03-03 22:07:58 +00:00
{
2014-08-13 10:51:37 +00:00
block_complete_entry b;
2015-07-30 15:22:07 +00:00
uint32_t current_blockchain_height;
2014-08-13 10:51:37 +00:00
uint32_t hop;
2014-03-03 22:07:58 +00:00
2015-07-15 12:23:00 +00:00
void serialize(ISerializer& s) {
KV_MEMBER(b)
KV_MEMBER(current_blockchain_height)
KV_MEMBER(hop)
}
2014-08-13 10:51:37 +00:00
};
2014-03-03 22:07:58 +00:00
2014-08-13 10:51:37 +00:00
struct NOTIFY_NEW_BLOCK
{
const static int ID = BC_COMMANDS_POOL_BASE + 1;
typedef NOTIFY_NEW_BLOCK_request request;
2014-03-03 22:07:58 +00:00
};
/************************************************************************/
/* */
/************************************************************************/
2014-08-13 10:51:37 +00:00
struct NOTIFY_NEW_TRANSACTIONS_request
2014-03-03 22:07:58 +00:00
{
2015-07-30 15:22:07 +00:00
std::vector<std::string> txs;
2014-03-03 22:07:58 +00:00
2015-07-15 12:23:00 +00:00
void serialize(ISerializer& s) {
KV_MEMBER(txs);
}
2014-08-13 10:51:37 +00:00
};
2014-03-03 22:07:58 +00:00
2014-08-13 10:51:37 +00:00
struct NOTIFY_NEW_TRANSACTIONS
{
const static int ID = BC_COMMANDS_POOL_BASE + 2;
typedef NOTIFY_NEW_TRANSACTIONS_request request;
2014-03-03 22:07:58 +00:00
};
2014-08-13 10:51:37 +00:00
2014-03-03 22:07:58 +00:00
/************************************************************************/
/* */
/************************************************************************/
2014-08-13 10:51:37 +00:00
struct NOTIFY_REQUEST_GET_OBJECTS_request
{
2015-07-30 15:22:07 +00:00
std::vector<Crypto::Hash> txs;
std::vector<Crypto::Hash> blocks;
2014-08-13 10:51:37 +00:00
2015-07-15 12:23:00 +00:00
void serialize(ISerializer& s) {
serializeAsBinary(txs, "txs", s);
serializeAsBinary(blocks, "blocks", s);
}
2014-08-13 10:51:37 +00:00
};
2014-03-03 22:07:58 +00:00
struct NOTIFY_REQUEST_GET_OBJECTS
{
const static int ID = BC_COMMANDS_POOL_BASE + 3;
2014-08-13 10:51:37 +00:00
typedef NOTIFY_REQUEST_GET_OBJECTS_request request;
};
2014-03-03 22:07:58 +00:00
2014-08-13 10:51:37 +00:00
struct NOTIFY_RESPONSE_GET_OBJECTS_request
{
2015-07-30 15:22:07 +00:00
std::vector<std::string> txs;
std::vector<block_complete_entry> blocks;
std::vector<Crypto::Hash> missed_ids;
uint32_t current_blockchain_height;
2015-07-15 12:23:00 +00:00
void serialize(ISerializer& s) {
KV_MEMBER(txs)
KV_MEMBER(blocks)
serializeAsBinary(missed_ids, "missed_ids", s);
KV_MEMBER(current_blockchain_height)
}
2014-03-03 22:07:58 +00:00
};
struct NOTIFY_RESPONSE_GET_OBJECTS
{
const static int ID = BC_COMMANDS_POOL_BASE + 4;
2014-08-13 10:51:37 +00:00
typedef NOTIFY_RESPONSE_GET_OBJECTS_request request;
2014-03-03 22:07:58 +00:00
};
struct NOTIFY_REQUEST_CHAIN
{
const static int ID = BC_COMMANDS_POOL_BASE + 6;
struct request
{
2015-07-30 15:22:07 +00:00
std::vector<Crypto::Hash> block_ids; /*IDs of the first 10 blocks are sequential, next goes with pow(2,n) offset, like 2, 4, 8, 16, 32, 64 and so on, and the last one is always genesis block */
2014-03-03 22:07:58 +00:00
2015-07-15 12:23:00 +00:00
void serialize(ISerializer& s) {
serializeAsBinary(block_ids, "block_ids", s);
}
2014-03-03 22:07:58 +00:00
};
};
2014-08-13 10:51:37 +00:00
struct NOTIFY_RESPONSE_CHAIN_ENTRY_request
2014-03-03 22:07:58 +00:00
{
2015-07-30 15:22:07 +00:00
uint32_t start_height;
uint32_t total_height;
std::vector<Crypto::Hash> m_block_ids;
2014-03-03 22:07:58 +00:00
2015-07-15 12:23:00 +00:00
void serialize(ISerializer& s) {
KV_MEMBER(start_height)
KV_MEMBER(total_height)
serializeAsBinary(m_block_ids, "m_block_ids", s);
}
2014-08-13 10:51:37 +00:00
};
2014-03-03 22:07:58 +00:00
2014-08-13 10:51:37 +00:00
struct NOTIFY_RESPONSE_CHAIN_ENTRY
{
const static int ID = BC_COMMANDS_POOL_BASE + 7;
typedef NOTIFY_RESPONSE_CHAIN_ENTRY_request request;
2014-03-03 22:07:58 +00:00
};
2015-07-15 12:23:00 +00:00
/************************************************************************/
/* */
/************************************************************************/
struct NOTIFY_REQUEST_TX_POOL_request {
2015-07-30 15:22:07 +00:00
std::vector<Crypto::Hash> txs;
2015-07-15 12:23:00 +00:00
void serialize(ISerializer& s) {
serializeAsBinary(txs, "txs", s);
}
};
struct NOTIFY_REQUEST_TX_POOL {
const static int ID = BC_COMMANDS_POOL_BASE + 8;
typedef NOTIFY_REQUEST_TX_POOL_request request;
};
2014-03-03 22:07:58 +00:00
}