Skip to content

Commit 0bfe2ea

Browse files
authored
Merge pull request #536 from evoskuil/master
Incorporate prevout table into store.
2 parents 6dc275f + 2e5da97 commit 0bfe2ea

File tree

24 files changed

+248
-154
lines changed

24 files changed

+248
-154
lines changed

include/bitcoin/database/impl/store.ipp

Lines changed: 51 additions & 40 deletions
Large diffs are not rendered by default.

include/bitcoin/database/settings.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,10 @@ struct BCD_API settings
8888
/// Caches.
8989
/// -----------------------------------------------------------------------
9090

91+
uint32_t prevout_buckets;
92+
uint64_t prevout_size;
93+
uint16_t prevout_rate;
94+
9195
uint32_t validated_bk_buckets;
9296
uint64_t validated_bk_size;
9397
uint16_t validated_bk_rate;
@@ -109,10 +113,6 @@ struct BCD_API settings
109113

110114
////uint32_t bootstrap_size;
111115
////uint16_t bootstrap_rate;
112-
113-
////uint32_t buffer_buckets;
114-
////uint64_t buffer_size;
115-
////uint16_t buffer_rate;
116116
};
117117

118118
} // namespace database

include/bitcoin/database/store.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -113,14 +113,14 @@ class store
113113
table::strong_tx strong_tx;
114114

115115
/// Caches.
116+
table::prevout prevout;
116117
table::validated_bk validated_bk;
117118
table::validated_tx validated_tx;
118119

119120
/// Optionals.
120121
table::address address;
121122
table::neutrino neutrino;
122123
////table::bootstrap bootstrap;
123-
////table::buffer buffer;
124124

125125
protected:
126126
code open_load(const event_handler& handler) NOEXCEPT;
@@ -185,6 +185,10 @@ class store
185185
/// Caches.
186186
/// -----------------------------------------------------------------------
187187

188+
// record arraymap
189+
Storage prevout_head_;
190+
Storage prevout_body_;
191+
188192
// record hashmap
189193
Storage validated_bk_head_;
190194
Storage validated_bk_body_;
@@ -208,10 +212,6 @@ class store
208212
////Storage bootstrap_head_;
209213
////Storage bootstrap_body_;
210214

211-
////// slab hashmap
212-
////Storage buffer_head_;
213-
////Storage buffer_body_;
214-
215215
/// Locks.
216216
/// -----------------------------------------------------------------------
217217

include/bitcoin/database/tables/archives/header.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ struct header
5050
bits = source.read_little_endian<uint32_t>();
5151
nonce = source.read_little_endian<uint32_t>();
5252
merkle_root = source.read_hash();
53-
BC_ASSERT(source.get_read_position() == minrow);
53+
BC_ASSERT(!source || source.get_read_position() == minrow);
5454
return source;
5555
}
5656

@@ -64,7 +64,7 @@ struct header
6464
sink.write_little_endian<uint32_t>(bits);
6565
sink.write_little_endian<uint32_t>(nonce);
6666
sink.write_bytes(merkle_root);
67-
BC_ASSERT(sink.get_write_position() == minrow);
67+
BC_ASSERT(!sink || sink.get_write_position() == minrow);
6868
return sink;
6969
}
7070

@@ -105,7 +105,7 @@ struct header
105105
sink.write_little_endian<uint32_t>(header->bits());
106106
sink.write_little_endian<uint32_t>(header->nonce());
107107
sink.write_bytes(header->merkle_root());
108-
BC_ASSERT(sink.get_write_position() == minrow);
108+
BC_ASSERT(!sink || sink.get_write_position() == minrow);
109109
return sink;
110110
}
111111

@@ -130,7 +130,7 @@ struct header
130130
sink.write_little_endian<uint32_t>(header.bits());
131131
sink.write_little_endian<uint32_t>(header.nonce());
132132
sink.write_bytes(header.merkle_root());
133-
BC_ASSERT(sink.get_write_position() == minrow);
133+
BC_ASSERT(!sink || sink.get_write_position() == minrow);
134134
return sink;
135135
}
136136

include/bitcoin/database/tables/archives/input.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,15 @@ struct input
5454
{
5555
script = system::chain::script{ source, true };
5656
witness = system::chain::witness{ source, true };
57-
BC_ASSERT(source.get_read_position() == count());
57+
BC_ASSERT(!source || source.get_read_position() == count());
5858
return source;
5959
}
6060

6161
inline bool to_data(flipper& sink) const NOEXCEPT
6262
{
6363
script.to_data(sink, true);
6464
witness.to_data(sink, true);
65-
BC_ASSERT(sink.get_write_position() == count());
65+
BC_ASSERT(!sink || sink.get_write_position() == count());
6666
return sink;
6767
}
6868

@@ -105,7 +105,7 @@ struct input
105105
{
106106
input.script().to_data(sink, true);
107107
input.witness().to_data(sink, true);
108-
BC_ASSERT(sink.get_write_position() == count());
108+
BC_ASSERT(!sink || sink.get_write_position() == count());
109109
return sink;
110110
}
111111

include/bitcoin/database/tables/archives/output.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ struct output
5757
parent_fk = source.read_little_endian<tx::integer, tx::size>();
5858
value = source.read_variable();
5959
script = chain::script{ source, true };
60-
BC_ASSERT(source.get_read_position() == count());
60+
BC_ASSERT(!source || source.get_read_position() == count());
6161
return source;
6262
}
6363

@@ -66,7 +66,7 @@ struct output
6666
sink.write_little_endian<tx::integer, tx::size>(parent_fk);
6767
sink.write_variable(value);
6868
script.to_data(sink, true);
69-
BC_ASSERT(sink.get_write_position() == count());
69+
BC_ASSERT(!sink || sink.get_write_position() == count());
7070
return sink;
7171
}
7272

@@ -143,7 +143,7 @@ struct output
143143
sink.write_little_endian<tx::integer, tx::size>(parent_fk);
144144
sink.write_variable(output.value());
145145
output.script().to_data(sink, true);
146-
BC_ASSERT(sink.get_write_position() == count());
146+
BC_ASSERT(!sink || sink.get_write_position() == count());
147147
return sink;
148148
}
149149

include/bitcoin/database/tables/archives/puts.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ struct puts
6767
fk = source.read_little_endian<out::integer, out::size>();
6868
});
6969

70-
BC_ASSERT(source.get_read_position() == count());
70+
BC_ASSERT(!source || source.get_read_position() == count());
7171
return source;
7272
}
7373

@@ -83,7 +83,7 @@ struct puts
8383
sink.write_little_endian<out::integer, out::size>(fk);
8484
});
8585

86-
BC_ASSERT(sink.get_write_position() == count());
86+
BC_ASSERT(!sink || sink.get_write_position() == count());
8787
return sink;
8888
}
8989

include/bitcoin/database/tables/archives/spend.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ struct spend
6666
parent_fk = source.read_little_endian<tx::integer, tx::size>();
6767
sequence = source.read_little_endian<uint32_t>();
6868
input_fk = source.read_little_endian<in::integer, in::size>();
69-
BC_ASSERT(source.get_read_position() == minrow);
69+
BC_ASSERT(!source || source.get_read_position() == minrow);
7070
return source;
7171
}
7272

@@ -75,7 +75,7 @@ struct spend
7575
sink.write_little_endian<tx::integer, tx::size>(parent_fk);
7676
sink.write_little_endian<uint32_t>(sequence);
7777
sink.write_little_endian<in::integer, in::size>(input_fk);
78-
BC_ASSERT(sink.get_write_position() == minrow);
78+
BC_ASSERT(!sink || sink.get_write_position() == minrow);
7979
return sink;
8080
}
8181

@@ -106,7 +106,7 @@ struct spend
106106
source.skip_bytes(tx::size);
107107
sequence = source.read_little_endian<uint32_t>();
108108
input_fk = source.read_little_endian<in::integer, in::size>();
109-
BC_ASSERT(source.get_read_position() == minrow);
109+
BC_ASSERT(!source || source.get_read_position() == minrow);
110110
return source;
111111
}
112112

include/bitcoin/database/tables/archives/transaction.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ struct transaction
6969
ins_count = source.read_little_endian<ix::integer, ix::size>();
7070
outs_count = source.read_little_endian<ix::integer, ix::size>();
7171
puts_fk = source.read_little_endian<puts::integer, puts::size>();
72-
BC_ASSERT(source.get_read_position() == minrow);
72+
BC_ASSERT(!source || source.get_read_position() == minrow);
7373
return source;
7474
}
7575

@@ -83,7 +83,7 @@ struct transaction
8383
sink.write_little_endian<ix::integer, ix::size>(ins_count);
8484
sink.write_little_endian<ix::integer, ix::size>(outs_count);
8585
sink.write_little_endian<puts::integer, puts::size>(puts_fk);
86-
BC_ASSERT(sink.get_write_position() == minrow);
86+
BC_ASSERT(!sink || sink.get_write_position() == minrow);
8787
return sink;
8888
}
8989

@@ -125,7 +125,7 @@ struct transaction
125125
ins_count = source.read_little_endian<ix::integer, ix::size>();
126126
outs_count = source.read_little_endian<ix::integer, ix::size>();
127127
puts_fk = source.read_little_endian<puts::integer, puts::size>();
128-
BC_ASSERT(source.get_read_position() == minrow);
128+
BC_ASSERT(!source || source.get_read_position() == minrow);
129129
return source;
130130
}
131131

@@ -152,7 +152,7 @@ struct transaction
152152
sink.write_little_endian<ix::integer, ix::size>(ins_count);
153153
sink.write_little_endian<ix::integer, ix::size>(outs_count);
154154
sink.write_little_endian<puts::integer, puts::size>(puts_fk);
155-
BC_ASSERT(sink.get_write_position() == minrow);
155+
BC_ASSERT(!sink || sink.get_write_position() == minrow);
156156
return sink;
157157
}
158158

include/bitcoin/database/tables/archives/txs.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ struct txs
5858
fk = source.read_little_endian<tx::integer, tx::size>();
5959
});
6060

61-
BC_ASSERT(source.get_read_position() == count());
61+
BC_ASSERT(!source || source.get_read_position() == count());
6262
return source;
6363
}
6464

@@ -74,7 +74,7 @@ struct txs
7474
sink.write_little_endian<tx::integer, tx::size>(fk);
7575
});
7676

77-
BC_ASSERT(sink.get_write_position() == count());
77+
BC_ASSERT(!sink || sink.get_write_position() == count());
7878
return sink;
7979
}
8080

0 commit comments

Comments
 (0)