Skip to content

Commit

Permalink
implement block differences after ringct, attempt 1
Browse files Browse the repository at this point in the history
  • Loading branch information
clintar committed Oct 4, 2016
1 parent bd693d4 commit 9025719
Show file tree
Hide file tree
Showing 3 changed files with 540 additions and 23 deletions.
2 changes: 1 addition & 1 deletion src/cryptonote_config.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once

#define CRYPTONOTE_PUBLIC_ADDRESS_TEXTBLOB_VER 0
#define CURRENT_TRANSACTION_VERSION 1
#define CURRENT_TRANSACTION_VERSION 2
#define CURRENT_BLOCK_MAJOR_VERSION 1
#define CURRENT_BLOCK_MINOR_VERSION 0

Expand Down
69 changes: 47 additions & 22 deletions src/cryptonote_core/cryptonote_basic.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "crypto/hash.h"
#include "misc_language.h"
#include "tx_extra.h"
#include "ringct/rctTypes.h"


namespace cryptonote
Expand Down Expand Up @@ -189,6 +190,7 @@ namespace cryptonote
{
public:
std::vector<std::vector<crypto::signature> > signatures; //count signatures always the same as inputs count
rct::rctSig rct_signatures;

transaction();
virtual ~transaction();
Expand All @@ -197,34 +199,57 @@ namespace cryptonote
BEGIN_SERIALIZE_OBJECT()
FIELDS(*static_cast<transaction_prefix *>(this))

ar.tag("signatures");
ar.begin_array();
PREPARE_CUSTOM_VECTOR_SERIALIZATION(vin.size(), signatures);
bool signatures_not_expected = signatures.empty();
if (!signatures_not_expected && vin.size() != signatures.size())
return false;

for (size_t i = 0; i < vin.size(); ++i)
if (version == 1)
{
size_t signature_size = get_signature_size(vin[i]);
if (signatures_not_expected)
ar.tag("signatures");
ar.begin_array();
PREPARE_CUSTOM_VECTOR_SERIALIZATION(vin.size(), signatures);
bool signatures_not_expected = signatures.empty();
if (!signatures_not_expected && vin.size() != signatures.size())
return false;

for (size_t i = 0; i < vin.size(); ++i)
{
if (0 == signature_size)
continue;
else
size_t signature_size = get_signature_size(vin[i]);
if (signatures_not_expected)
{
if (0 == signature_size)
continue;
else
return false;
}

PREPARE_CUSTOM_VECTOR_SERIALIZATION(signature_size, signatures[i]);
if (signature_size != signatures[i].size())
return false;
}

PREPARE_CUSTOM_VECTOR_SERIALIZATION(signature_size, signatures[i]);
if (signature_size != signatures[i].size())
return false;

FIELDS(signatures[i]);
FIELDS(signatures[i]);

if (vin.size() - i > 1)
ar.delimit_array();
if (vin.size() - i > 1)
ar.delimit_array();
}
ar.end_array();
}
else
{
ar.tag("rct_signatures");
if (!vin.empty())
{
ar.begin_object();
bool r = rct_signatures.serialize_rctsig_base(ar, vin.size(), vout.size());
if (!r || !ar.stream().good()) return false;
ar.end_object();
if (rct_signatures.type != rct::RCTTypeNull)
{
ar.tag("rctsig_prunable");
ar.begin_object();
r = rct_signatures.p.serialize_rctsig_prunable(ar, rct_signatures.type, vin.size(), vout.size(),
vin[0].type() == typeid(txin_to_key) ? boost::get<txin_to_key>(vin[0]).key_offsets.size() - 1 : 0);
if (!r || !ar.stream().good()) return false;
ar.end_object();
}
}
}
ar.end_array();
END_SERIALIZE()

private:
Expand Down
Loading

0 comments on commit 9025719

Please sign in to comment.