danicoin/src/cryptonote_protocol/cryptonote_protocol_defs.h

170 lines
5 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>
#include "serialization/keyvalue_serialization.h"
#include "cryptonote_core/cryptonote_basic.h"
#include "cryptonote_protocol/blobdatatype.h"
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
{
blobdata block;
std::list<blobdata> txs;
BEGIN_KV_SERIALIZE_MAP()
KV_SERIALIZE(block)
KV_SERIALIZE(txs)
END_KV_SERIALIZE_MAP()
};
struct BlockFullInfo : public block_complete_entry
{
crypto::hash block_id;
BEGIN_KV_SERIALIZE_MAP()
KV_SERIALIZE_VAL_POD_AS_BLOB(block_id)
KV_SERIALIZE(block)
KV_SERIALIZE(txs)
END_KV_SERIALIZE_MAP()
};
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;
uint64_t current_blockchain_height;
uint32_t hop;
2014-03-03 22:07:58 +00:00
2014-08-13 10:51:37 +00:00
BEGIN_KV_SERIALIZE_MAP()
KV_SERIALIZE(b)
KV_SERIALIZE(current_blockchain_height)
KV_SERIALIZE(hop)
END_KV_SERIALIZE_MAP()
};
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
{
2014-08-13 10:51:37 +00:00
std::list<blobdata> txs;
2014-03-03 22:07:58 +00:00
2014-08-13 10:51:37 +00:00
BEGIN_KV_SERIALIZE_MAP()
KV_SERIALIZE(txs)
END_KV_SERIALIZE_MAP()
};
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
{
std::list<crypto::hash> txs;
std::list<crypto::hash> blocks;
BEGIN_KV_SERIALIZE_MAP()
KV_SERIALIZE_CONTAINER_POD_AS_BLOB(txs)
KV_SERIALIZE_CONTAINER_POD_AS_BLOB(blocks)
END_KV_SERIALIZE_MAP()
};
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
{
std::list<blobdata> txs;
std::list<block_complete_entry> blocks;
std::list<crypto::hash> missed_ids;
uint64_t current_blockchain_height;
2014-03-03 22:07:58 +00:00
2014-08-13 10:51:37 +00:00
BEGIN_KV_SERIALIZE_MAP()
KV_SERIALIZE(txs)
KV_SERIALIZE(blocks)
KV_SERIALIZE_CONTAINER_POD_AS_BLOB(missed_ids)
KV_SERIALIZE(current_blockchain_height)
END_KV_SERIALIZE_MAP()
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
{
std::list<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 */
BEGIN_KV_SERIALIZE_MAP()
KV_SERIALIZE_CONTAINER_POD_AS_BLOB(block_ids)
END_KV_SERIALIZE_MAP()
};
};
2014-08-13 10:51:37 +00:00
struct NOTIFY_RESPONSE_CHAIN_ENTRY_request
2014-03-03 22:07:58 +00:00
{
2014-08-13 10:51:37 +00:00
uint64_t start_height;
uint64_t total_height;
std::list<crypto::hash> m_block_ids;
2014-03-03 22:07:58 +00:00
2014-08-13 10:51:37 +00:00
BEGIN_KV_SERIALIZE_MAP()
KV_SERIALIZE(start_height)
KV_SERIALIZE(total_height)
KV_SERIALIZE_CONTAINER_POD_AS_BLOB(m_block_ids)
END_KV_SERIALIZE_MAP()
};
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
};
}