@@ -142,23 +142,6 @@ code CLASS::set_code(const tx_link& tx_fk, const transaction& tx) NOEXCEPT
142142
143143 // Commit points (hashmap).
144144 {
145- // //if (!tx.is_coinbase())
146- // //{
147- // // const auto ptr = store_.point.get_memory();
148- // // for (const auto& in: *ins)
149- // // {
150- // // // Extract integer and modulo to get % of points.
151- // // // Simulates bloom filtering false positive duplicate confirm.
152- // // if (to_bool(unique_hash(in->point().hash()) % 1_size))
153- // // continue;
154- // //
155- // // // In a normal test run it will not exist (cb excluded above).
156- // // // Return failure to ensure this is not elided by the compiler.
157- // // if (store_.point.exists(ptr, in->point()))
158- // // return error::confirmed_double_spend;
159- // // }
160- // //}
161-
162145 // Expand synchronizes keys with ins_fk, entries dropped into same offset.
163146 // Allocate contiguous points (at sequential keys matching ins_fk).
164147 if (!store_.point .expand (ins_fk + inputs))
@@ -167,12 +150,27 @@ code CLASS::set_code(const tx_link& tx_fk, const transaction& tx) NOEXCEPT
167150 // This must be set after tx.set and before tx.commit, since searchable and
168151 // produces an association to tx.link, and is also an integral part of tx.
169152 const auto ptr = store_.point .get_memory ();
153+
154+ // Collect duplicates to store in duplicate table.
155+ std::vector<chain::cref_point> twins{};
170156 for (const auto & in: *ins)
171157 {
172- if (!store_.point .put (ptr, ins_fk++, in->point (),
158+ // /////////////////////////////////////////////////////////////////
159+ // TODO: add filter to hashmap and use method here to detect and
160+ // TODO: return prior existence (dup) here (insert succeeds).
161+ // /////////////////////////////////////////////////////////////////
162+ bool twin{};
163+ if (!store_.point .put (/* twin,*/ ptr, ins_fk++, in->point (),
173164 table::point::record{}))
174165 return error::tx_point_put;
166+
167+ if (twin)
168+ twins.emplace_back (in->point ().hash (), in->point ().index ());
175169 }
170+
171+ // /////////////////////////////////////////////////////////////////////
172+ // TODO: if (!twins.empty()) ... store to duplicate table here.
173+ // /////////////////////////////////////////////////////////////////////
176174 }
177175
178176 // Commit address index records (hashmap).
0 commit comments