// Copyright (c) 2012-2015, The CryptoNote developers, The Bytecoin developers
//
// 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 .
#pragma once
#include
#include "cryptonote_core/cryptonote_basic.h"
#include "cryptonote_protocol/blobdatatype.h"
// ISerializer-based serialization
#include "serialization/ISerializer.h"
#include "serialization/SerializationOverloads.h"
#include "cryptonote_core/cryptonote_serialization.h"
namespace CryptoNote
{
#define BC_COMMANDS_POOL_BASE 2000
/************************************************************************/
/* */
/************************************************************************/
struct block_complete_entry
{
blobdata block;
std::list txs;
void serialize(ISerializer& s) {
KV_MEMBER(block);
KV_MEMBER(txs);
}
};
struct BlockFullInfo : public block_complete_entry
{
crypto::hash block_id;
void serialize(ISerializer& s) {
KV_MEMBER(block_id);
KV_MEMBER(block);
KV_MEMBER(txs);
}
};
/************************************************************************/
/* */
/************************************************************************/
struct NOTIFY_NEW_BLOCK_request
{
block_complete_entry b;
uint64_t current_blockchain_height;
uint32_t hop;
void serialize(ISerializer& s) {
KV_MEMBER(b)
KV_MEMBER(current_blockchain_height)
KV_MEMBER(hop)
}
};
struct NOTIFY_NEW_BLOCK
{
const static int ID = BC_COMMANDS_POOL_BASE + 1;
typedef NOTIFY_NEW_BLOCK_request request;
};
/************************************************************************/
/* */
/************************************************************************/
struct NOTIFY_NEW_TRANSACTIONS_request
{
std::list txs;
void serialize(ISerializer& s) {
KV_MEMBER(txs);
}
};
struct NOTIFY_NEW_TRANSACTIONS
{
const static int ID = BC_COMMANDS_POOL_BASE + 2;
typedef NOTIFY_NEW_TRANSACTIONS_request request;
};
/************************************************************************/
/* */
/************************************************************************/
struct NOTIFY_REQUEST_GET_OBJECTS_request
{
std::list txs;
std::list blocks;
void serialize(ISerializer& s) {
serializeAsBinary(txs, "txs", s);
serializeAsBinary(blocks, "blocks", s);
}
};
struct NOTIFY_REQUEST_GET_OBJECTS
{
const static int ID = BC_COMMANDS_POOL_BASE + 3;
typedef NOTIFY_REQUEST_GET_OBJECTS_request request;
};
struct NOTIFY_RESPONSE_GET_OBJECTS_request
{
std::list txs;
std::list blocks;
std::list missed_ids;
uint64_t current_blockchain_height;
void serialize(ISerializer& s) {
KV_MEMBER(txs)
KV_MEMBER(blocks)
serializeAsBinary(missed_ids, "missed_ids", s);
KV_MEMBER(current_blockchain_height)
}
};
struct NOTIFY_RESPONSE_GET_OBJECTS
{
const static int ID = BC_COMMANDS_POOL_BASE + 4;
typedef NOTIFY_RESPONSE_GET_OBJECTS_request request;
};
struct NOTIFY_REQUEST_CHAIN
{
const static int ID = BC_COMMANDS_POOL_BASE + 6;
struct request
{
std::list 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 */
void serialize(ISerializer& s) {
serializeAsBinary(block_ids, "block_ids", s);
}
};
};
struct NOTIFY_RESPONSE_CHAIN_ENTRY_request
{
uint64_t start_height;
uint64_t total_height;
std::list m_block_ids;
void serialize(ISerializer& s) {
KV_MEMBER(start_height)
KV_MEMBER(total_height)
serializeAsBinary(m_block_ids, "m_block_ids", s);
}
};
struct NOTIFY_RESPONSE_CHAIN_ENTRY
{
const static int ID = BC_COMMANDS_POOL_BASE + 7;
typedef NOTIFY_RESPONSE_CHAIN_ENTRY_request request;
};
/************************************************************************/
/* */
/************************************************************************/
struct NOTIFY_REQUEST_TX_POOL_request {
std::vector txs;
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;
};
}