@@ -31,7 +31,7 @@ namespace table {
3131
3232// / prevout is an array map index of previous outputs by block link.
3333// / The coinbase flag is merged into the tx field, reducing it's domain.
34- // / Masking is from the right in order to accomodate non- integral domain.
34+ // / Masking is from the right in order to accomodate integral tx domain.
3535struct prevout
3636 : public array_map<schema::prevout>
3737{
@@ -44,12 +44,12 @@ struct prevout
4444 static_assert (tx::size == sizeof (uint32_t ), " sequence-tx overload error" );
4545
4646 // This supports only a single record (not too useful).
47- struct record
47+ struct slab
4848 : public schema::prevout
4949 {
5050 inline link count () const NOEXCEPT
5151 {
52- return one ;
52+ return tx::size ;
5353 }
5454
5555 inline bool coinbase () const NOEXCEPT
@@ -83,7 +83,7 @@ struct prevout
8383 return sink;
8484 }
8585
86- inline bool operator ==(const record & other) const NOEXCEPT
86+ inline bool operator ==(const slab & other) const NOEXCEPT
8787 {
8888 return coinbase () == other.coinbase ()
8989 && output_tx_fk () == other.output_tx_fk ();
@@ -92,15 +92,16 @@ struct prevout
9292 tx::integer prevout_tx{};
9393 };
9494
95- struct record_put_ref
95+ struct slab_put_ref
9696 : public schema::prevout
9797 {
9898 inline link count () const NOEXCEPT
9999 {
100100 // TODO: assert overflow.
101101 using namespace system ;
102- return add1 (possible_narrow_cast<tx::integer>(conflicts.size ())) +
103- two * possible_narrow_cast<tx::integer>(block.spends ());
102+ const auto conflicts_ = conflicts.size ();
103+ return variable_size (conflicts_) + (conflicts_ * tx::size) +
104+ (block.spends () * (tx::size + sizeof (uint32_t )));
104105 }
105106
106107 static constexpr tx::integer merge (bool coinbase,
@@ -140,7 +141,7 @@ struct prevout
140141 BC_ASSERT_MSG (txs.size () > one, " empty block" );
141142
142143 // Count is written as a tx link so the table can remain an array.
143- sink.write_little_endian <tx::integer, tx::size> (number);
144+ sink.write_variable (number);
144145 std::for_each (cons.begin (), cons.end (), write_con);
145146 std::for_each (std::next (txs.begin ()), txs.end (), write_tx);
146147
@@ -152,21 +153,22 @@ struct prevout
152153 const system::chain::block& block{};
153154 };
154155
155- struct record_get
156+ struct slab_get
156157 : public schema::prevout
157158 {
158159 inline link count () const NOEXCEPT
159160 {
160161 // TODO: assert overflow.
161162 using namespace system ;
162- return possible_narrow_cast<tx::integer>(add1 (conflicts.size ())) +
163- two * possible_narrow_cast<tx::integer>(spends.size ());
163+ const auto conflicts_ = conflicts.size ();
164+ return variable_size (conflicts_) + (conflicts_ * tx::size) +
165+ (spends.size () * (tx::size + sizeof (uint32_t )));
164166 }
165167
166168 inline bool from_data (reader& source) NOEXCEPT
167169 {
168170 auto & cons = conflicts;
169- cons.resize (source.read_little_endian <tx::integer, tx::size> ());
171+ cons.resize (source.read_variable ());
170172 std::for_each (cons.begin (), cons.end (), [&](auto & value) NOEXCEPT
171173 {
172174 value = source.read_little_endian <tx::integer, tx::size>();
0 commit comments