Introduce vpour to CTransaction.

Transactions of version 2 and above contain a `vpour` field which is a vector of `CPourTx`
objects that embody our protocol. We introduce serialization primitives for boost::array
(we intend for changing the amount of inputs and outputs in the circuit to be simple).

SIGHASH_* operations hash this field like any other for now.
This commit is contained in:
Sean Bowe
2015-12-29 17:56:05 -07:00
parent 74e519aa2d
commit 5884044ba9
7 changed files with 725 additions and 503 deletions

View File

@@ -20,6 +20,8 @@
#include <utility>
#include <vector>
#include <boost/array.hpp>
class CScript;
static const unsigned int MAX_SIZE = 0x02000000;
@@ -506,6 +508,13 @@ extern inline unsigned int GetSerializeSize(const CScript& v, int nType, int nVe
template<typename Stream> void Serialize(Stream& os, const CScript& v, int nType, int nVersion);
template<typename Stream> void Unserialize(Stream& is, CScript& v, int nType, int nVersion);
/**
* array
*/
template<typename T, std::size_t N> unsigned int GetSerializeSize(const boost::array<T, N> &item, int nType, int nVersion);
template<typename Stream, typename T, std::size_t N> void Serialize(Stream& os, const boost::array<T, N>& item, int nType, int nVersion);
template<typename Stream, typename T, std::size_t N> void Unserialize(Stream& is, boost::array<T, N>& item, int nType, int nVersion);
/**
* pair
*/
@@ -698,6 +707,35 @@ void Unserialize(Stream& is, CScript& v, int nType, int nVersion)
}
/**
* array
*/
template<typename T, std::size_t N>
unsigned int GetSerializeSize(const boost::array<T, N> &item, int nType, int nVersion)
{
unsigned int size = 0;
for (size_t i = 0; i < N; i++) {
size += GetSerializeSize(item[0], nType, nVersion);
}
return size;
}
template<typename Stream, typename T, std::size_t N>
void Serialize(Stream& os, const boost::array<T, N>& item, int nType, int nVersion)
{
for (size_t i = 0; i < N; i++) {
Serialize(os, item[i], nType, nVersion);
}
}
template<typename Stream, typename T, std::size_t N>
void Unserialize(Stream& is, boost::array<T, N>& item, int nType, int nVersion)
{
for (size_t i = 0; i < N; i++) {
Unserialize(is, item[i], nType, nVersion);
}
}
/**
* pair