@@ -36,6 +36,7 @@ struct txs
3636 : public hash_map<schema::txs>
3737{
3838 using tx = linkage<schema::tx>;
39+ using ct = linkage<schema::count_>;
3940 using keys = std::vector<tx::integer>;
4041 using bytes = linkage<schema::size>;
4142 using hash_map<schema::txs>::hashmap;
@@ -46,12 +47,12 @@ struct txs
4647 link count () const NOEXCEPT
4748 {
4849 return system::possible_narrow_cast<link::integer>(pk + sk +
49- schema::count_ + bytes::size + tx::size * tx_fks.size ());
50+ ct::size + bytes::size + tx::size * tx_fks.size ());
5051 }
5152
5253 inline bool from_data (reader& source) NOEXCEPT
5354 {
54- tx_fks.resize (source.read_little_endian <tx ::integer, schema::count_ >());
55+ tx_fks.resize (source.read_little_endian <ct ::integer, ct::size >());
5556 wire = source.read_little_endian <bytes::integer, bytes::size>();
5657 std::for_each (tx_fks.begin (), tx_fks.end (), [&](auto & fk) NOEXCEPT
5758 {
@@ -64,10 +65,10 @@ struct txs
6465
6566 inline bool to_data (finalizer& sink) const NOEXCEPT
6667 {
67- BC_ASSERT (tx_fks.size () < system::power2<uint64_t >(to_bits (schema::count_ )));
68- const auto fks = system::possible_narrow_cast<tx ::integer>(tx_fks.size ());
68+ BC_ASSERT (tx_fks.size () < system::power2<uint64_t >(to_bits (ct::size )));
69+ const auto fks = system::possible_narrow_cast<ct ::integer>(tx_fks.size ());
6970
70- sink.write_little_endian <tx ::integer, schema::count_ >(fks);
71+ sink.write_little_endian <ct ::integer, ct::size >(fks);
7172 sink.write_little_endian <bytes::integer, bytes::size>(wire);
7273 std::for_each (tx_fks.begin (), tx_fks.end (), [&](const auto & fk) NOEXCEPT
7374 {
@@ -88,6 +89,37 @@ struct txs
8889 keys tx_fks{};
8990 };
9091
92+ // put a contiguous set of tx identifiers.
93+ // TODO: this could be collapsed to a count and first using a sentinel.
94+ struct put_group
95+ : public schema::txs
96+ {
97+ link count () const NOEXCEPT
98+ {
99+ return system::possible_narrow_cast<link::integer>(pk + sk +
100+ ct::size + bytes::size + tx::size * number);
101+ }
102+
103+ inline bool to_data (finalizer& sink) const NOEXCEPT
104+ {
105+ BC_ASSERT (number < system::power2<uint64_t >(to_bits (ct::size)));
106+
107+ sink.write_little_endian <ct::integer, ct::size>(number);
108+ sink.write_little_endian <bytes::integer, bytes::size>(wire);
109+
110+ for (auto fk = tx_fk; fk < (tx_fk + number); ++fk)
111+ sink.write_little_endian <tx::integer, tx::size>(fk);
112+
113+ BC_ASSERT (!sink || sink.get_write_position () == count ());
114+ return sink;
115+ }
116+
117+ // block.serialized_size(true)
118+ bytes::integer wire{};
119+ ct::integer number{};
120+ tx::integer tx_fk{};
121+ };
122+
91123 struct get_position
92124 : public schema::txs
93125 {
@@ -99,7 +131,7 @@ struct txs
99131
100132 inline bool from_data (reader& source) NOEXCEPT
101133 {
102- const auto number = source.read_little_endian <tx ::integer, schema::count_ >();
134+ const auto number = source.read_little_endian <ct ::integer, ct::size >();
103135 source.skip_bytes (bytes::size);
104136 for (position = zero; position < number; ++position)
105137 if (source.read_little_endian <tx::integer, tx::size>() == tx_fk)
@@ -124,7 +156,7 @@ struct txs
124156
125157 inline bool from_data (reader& source) NOEXCEPT
126158 {
127- const auto number = source.read_little_endian <tx ::integer, schema::count_ >();
159+ const auto number = source.read_little_endian <ct ::integer, ct::size >();
128160 source.skip_bytes (bytes::size);
129161 if (is_nonzero (number))
130162 {
@@ -150,7 +182,7 @@ struct txs
150182
151183 inline bool from_data (reader& source) NOEXCEPT
152184 {
153- source.skip_bytes (schema::count_ );
185+ source.skip_bytes (ct::size );
154186 wire = source.read_little_endian <bytes::integer, bytes::size>();
155187 return source;
156188 }
@@ -169,7 +201,7 @@ struct txs
169201
170202 inline bool from_data (reader& source) NOEXCEPT
171203 {
172- associated = to_bool (source.read_little_endian <tx ::integer, schema::count_ >());
204+ associated = to_bool (source.read_little_endian <ct ::integer, ct::size >());
173205 return source;
174206 }
175207
@@ -187,7 +219,7 @@ struct txs
187219
188220 inline bool from_data (reader& source) NOEXCEPT
189221 {
190- tx_fks.resize (source.read_little_endian <tx ::integer, schema::count_ >());
222+ tx_fks.resize (source.read_little_endian <ct ::integer, ct::size >());
191223 source.skip_bytes (bytes::size);
192224 std::for_each (tx_fks.begin (), tx_fks.end (), [&](auto & fk) NOEXCEPT
193225 {
@@ -211,7 +243,7 @@ struct txs
211243
212244 inline bool from_data (reader& source) NOEXCEPT
213245 {
214- const auto number = source.read_little_endian <tx ::integer, schema::count_ >();
246+ const auto number = source.read_little_endian <ct ::integer, ct::size >();
215247 if (number <= one)
216248 return source;
217249
@@ -239,11 +271,11 @@ struct txs
239271
240272 inline bool from_data (reader& source) NOEXCEPT
241273 {
242- quantity = source.read_little_endian <tx ::integer, schema::count_ >();
274+ number = source.read_little_endian <ct ::integer, ct::size >();
243275 return source;
244276 }
245277
246- size_t quantity {};
278+ size_t number {};
247279 };
248280};
249281
0 commit comments