Skip to content

Commit

Permalink
style fix
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexanderSuprunenko committed May 28, 2019
1 parent bcaeed6 commit 01c763a
Show file tree
Hide file tree
Showing 4 changed files with 163 additions and 163 deletions.
174 changes: 87 additions & 87 deletions src/cryptonote_basic/cryptonote_format_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1158,64 +1158,64 @@ namespace cryptonote
//---------------------------------------------------------------
bool add_graft_tx_extra_to_extra(transaction &tx, const supernode::GraftTxExtra &graft_extra)
{
return add_graft_tx_extra_to_extra(tx.extra, graft_extra);
return add_graft_tx_extra_to_extra(tx.extra, graft_extra);
}
//---------------------------------------------------------------
bool add_graft_tx_extra_to_extra(std::vector<uint8_t>& extra, const supernode::GraftTxExtra &graft_extra)
{
std::string blob;
::serialization::dump_binary(const_cast<supernode::GraftTxExtra&>(graft_extra), blob);
tx_extra_graft_extra container;
container.data = blob;
blob.clear();
::serialization::dump_binary(container, blob);
extra.push_back(TX_EXTRA_GRAFT_EXTRA_TAG);
std::copy(blob.begin(), blob.end(), std::back_inserter(extra));
return true;
std::string blob;
::serialization::dump_binary(const_cast<supernode::GraftTxExtra&>(graft_extra), blob);
tx_extra_graft_extra container;
container.data = blob;
blob.clear();
::serialization::dump_binary(container, blob);
extra.push_back(TX_EXTRA_GRAFT_EXTRA_TAG);
std::copy(blob.begin(), blob.end(), std::back_inserter(extra));
return true;
}
//---------------------------------------------------------------
bool get_graft_tx_extra_from_extra(const transaction &tx, supernode::GraftTxExtra &graft_tx_extra)
{
std::vector<tx_extra_field> tx_extra_fields;
parse_tx_extra(tx.extra, tx_extra_fields);
tx_extra_graft_extra graft_extra;
if(!find_tx_extra_field_by_type(tx_extra_fields, graft_extra))
return false;
return ::serialization::parse_binary(graft_extra.data, graft_tx_extra);
std::vector<tx_extra_field> tx_extra_fields;
parse_tx_extra(tx.extra, tx_extra_fields);
tx_extra_graft_extra graft_extra;
if(!find_tx_extra_field_by_type(tx_extra_fields, graft_extra))
return false;
return ::serialization::parse_binary(graft_extra.data, graft_tx_extra);
}

namespace
{
struct GraftStakeTxExtra
{
std::string supernode_public_id;
cryptonote::account_public_address supernode_public_address;
crypto::signature supernode_signature;

GraftStakeTxExtra() = default;

GraftStakeTxExtra(const std::string &supernode_public_id,
const cryptonote::account_public_address& supernode_public_address,
const crypto::signature &supernode_signature) :
supernode_public_id(supernode_public_id),
supernode_public_address(supernode_public_address),
supernode_signature(supernode_signature)
{}

bool operator ==(const GraftStakeTxExtra &rhs) const {
return supernode_public_id == rhs.supernode_public_id &&
!memcmp(&supernode_public_address.m_view_public_key.data[0], &rhs.supernode_public_address.m_view_public_key.data[0],
sizeof(supernode_public_address.m_view_public_key.data)) &&
!memcmp(&supernode_signature.c.data[0], &rhs.supernode_signature.c.data[0], sizeof(supernode_signature.c.data)) &&
!memcmp(&supernode_signature.r.data[0], &rhs.supernode_signature.r.data[0], sizeof(supernode_signature.r.data));
}
struct GraftStakeTxExtra
{
std::string supernode_public_id;
cryptonote::account_public_address supernode_public_address;
crypto::signature supernode_signature;

GraftStakeTxExtra() = default;

GraftStakeTxExtra(const std::string &supernode_public_id,
const cryptonote::account_public_address& supernode_public_address,
const crypto::signature &supernode_signature) :
supernode_public_id(supernode_public_id),
supernode_public_address(supernode_public_address),
supernode_signature(supernode_signature)
{}

bool operator ==(const GraftStakeTxExtra &rhs) const {
return supernode_public_id == rhs.supernode_public_id &&
!memcmp(&supernode_public_address.m_view_public_key.data[0], &rhs.supernode_public_address.m_view_public_key.data[0],
sizeof(supernode_public_address.m_view_public_key.data)) &&
!memcmp(&supernode_signature.c.data[0], &rhs.supernode_signature.c.data[0], sizeof(supernode_signature.c.data)) &&
!memcmp(&supernode_signature.r.data[0], &rhs.supernode_signature.r.data[0], sizeof(supernode_signature.r.data));
}

BEGIN_SERIALIZE_OBJECT()
FIELD(supernode_public_id)
FIELD(supernode_public_address)
FIELD(supernode_signature)
END_SERIALIZE()
};
BEGIN_SERIALIZE_OBJECT()
FIELD(supernode_public_id)
FIELD(supernode_public_address)
FIELD(supernode_signature)
END_SERIALIZE()
};
}

bool add_graft_stake_tx_extra_to_extra
Expand All @@ -1224,16 +1224,16 @@ namespace cryptonote
const cryptonote::account_public_address &supernode_public_address,
const crypto::signature &supernode_signature)
{
GraftStakeTxExtra tx_extra(supernode_public_id, supernode_public_address, supernode_signature);
std::string blob;
::serialization::dump_binary(tx_extra, blob);
tx_extra_graft_stake_tx container;
container.data = blob;
blob.clear();
::serialization::dump_binary(container, blob);
extra.push_back(TX_EXTRA_GRAFT_STAKE_TX_TAG);
std::copy(blob.begin(), blob.end(), std::back_inserter(extra));
return true;
GraftStakeTxExtra tx_extra(supernode_public_id, supernode_public_address, supernode_signature);
std::string blob;
::serialization::dump_binary(tx_extra, blob);
tx_extra_graft_stake_tx container;
container.data = blob;
blob.clear();
::serialization::dump_binary(container, blob);
extra.push_back(TX_EXTRA_GRAFT_STAKE_TX_TAG);
std::copy(blob.begin(), blob.end(), std::back_inserter(extra));
return true;
}

bool add_graft_rta_header_to_extra(std::vector<uint8_t> &extra, const rta_header &rta_header)
Expand Down Expand Up @@ -1261,13 +1261,13 @@ namespace cryptonote

bool add_graft_tx_secret_key_to_extra(std::vector<uint8_t> &extra, const crypto::secret_key& secret_key)
{
tx_extra_graft_tx_secret_key container;
container.secret_key = secret_key;
std::string blob;
::serialization::dump_binary(container, blob);
extra.push_back(TX_EXTRA_GRAFT_TX_SECRET_KEY_TAG);
std::copy(blob.begin(), blob.end(), std::back_inserter(extra));
return true;
tx_extra_graft_tx_secret_key container;
container.secret_key = secret_key;
std::string blob;
::serialization::dump_binary(container, blob);
extra.push_back(TX_EXTRA_GRAFT_TX_SECRET_KEY_TAG);
std::copy(blob.begin(), blob.end(), std::back_inserter(extra));
return true;
}

bool get_graft_stake_tx_extra_from_extra
Expand All @@ -1277,30 +1277,30 @@ namespace cryptonote
crypto::signature &supernode_signature,
crypto::secret_key &tx_secret_key)
{
std::vector<tx_extra_field> tx_extra_fields;
parse_tx_extra(tx.extra, tx_extra_fields);
std::vector<tx_extra_field> tx_extra_fields;
parse_tx_extra(tx.extra, tx_extra_fields);

tx_extra_graft_stake_tx stake_tx_extra;
tx_extra_graft_stake_tx stake_tx_extra;

if(!find_tx_extra_field_by_type(tx_extra_fields, stake_tx_extra))
return false;
if(!find_tx_extra_field_by_type(tx_extra_fields, stake_tx_extra))
return false;

GraftStakeTxExtra stake_tx;
GraftStakeTxExtra stake_tx;

if (!::serialization::parse_binary(stake_tx_extra.data, stake_tx))
return false;
if (!::serialization::parse_binary(stake_tx_extra.data, stake_tx))
return false;

tx_extra_graft_tx_secret_key stake_tx_secret_key_extra;
tx_extra_graft_tx_secret_key stake_tx_secret_key_extra;

if(!find_tx_extra_field_by_type(tx_extra_fields, stake_tx_secret_key_extra))
return false;
if(!find_tx_extra_field_by_type(tx_extra_fields, stake_tx_secret_key_extra))
return false;

supernode_public_id = stake_tx.supernode_public_id;
supernode_public_address = stake_tx.supernode_public_address;
supernode_signature = stake_tx.supernode_signature;
tx_secret_key = stake_tx_secret_key_extra.secret_key;
supernode_public_id = stake_tx.supernode_public_id;
supernode_public_address = stake_tx.supernode_public_address;
supernode_signature = stake_tx.supernode_signature;
tx_secret_key = stake_tx_secret_key_extra.secret_key;

return true;
return true;
}

bool add_graft_rta_signatures_to_extra2(std::vector<uint8_t> &extra, const std::vector<rta_signature> &rta_signatures)
Expand Down Expand Up @@ -1328,15 +1328,15 @@ namespace cryptonote

bool graft_get_disqualification(const transaction &tx, tx_extra_graft_disqualification& disq)
{
if(tx.version != 123)
return false;
if(!tx.vin.empty() || !tx.vout.empty() || tx.rct_signatures.txnFee !=0)
return false;
std::vector<tx_extra_field> tx_extra_fields;
parse_tx_extra(tx.extra, tx_extra_fields);
if(!find_tx_extra_field_by_type(tx_extra_fields, disq))
return false;
return true;
if(tx.version != 123)
return false;
if(!tx.vin.empty() || !tx.vout.empty() || tx.rct_signatures.txnFee !=0)
return false;
std::vector<tx_extra_field> tx_extra_fields;
parse_tx_extra(tx.extra, tx_extra_fields);
if(!find_tx_extra_field_by_type(tx_extra_fields, disq))
return false;
return true;
}

bool graft_is_disqualification(const transaction &tx)
Expand Down
42 changes: 21 additions & 21 deletions src/cryptonote_basic/tx_extra.h
Original file line number Diff line number Diff line change
Expand Up @@ -244,27 +244,27 @@ namespace cryptonote

struct tx_extra_graft_disqualification
{
struct disqualification_item
{
uint64_t block_height;
crypto::hash block_hash;
crypto::public_key id;
BEGIN_SERIALIZE()
FIELD(block_height)
FIELD(block_hash)
FIELD(id)
END_SERIALIZE()
};

struct signer_item
{
crypto::public_key signer_id;
crypto::signature sign;
BEGIN_SERIALIZE()
FIELD(signer_id)
FIELD(sign)
END_SERIALIZE()
};
struct disqualification_item
{
uint64_t block_height;
crypto::hash block_hash;
crypto::public_key id;
BEGIN_SERIALIZE()
FIELD(block_height)
FIELD(block_hash)
FIELD(id)
END_SERIALIZE()
};

struct signer_item
{
crypto::public_key signer_id;
crypto::signature sign;
BEGIN_SERIALIZE()
FIELD(signer_id)
FIELD(sign)
END_SERIALIZE()
};

disqualification_item item;
std::vector<signer_item> signers;
Expand Down
Loading

0 comments on commit 01c763a

Please sign in to comment.