File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -156,4 +156,26 @@ struct FeeFrac
156
156
*/
157
157
std::partial_ordering CompareChunks (std::span<const FeeFrac> chunks0, std::span<const FeeFrac> chunks1);
158
158
159
+ /* * Tagged wrapper around FeeFrac to avoid unit confusion. */
160
+ template <typename Tag>
161
+ struct FeePerUnit : public FeeFrac
162
+ {
163
+ // Inherit FeeFrac constructors.
164
+ using FeeFrac::FeeFrac;
165
+
166
+ /* * Convert a FeeFrac to a FeePerUnit. */
167
+ static FeePerUnit FromFeeFrac (const FeeFrac& feefrac) noexcept
168
+ {
169
+ return {feefrac.fee , feefrac.size };
170
+ }
171
+ };
172
+
173
+ // FeePerUnit instance for satoshi / vbyte.
174
+ struct VSizeTag {};
175
+ using FeePerVSize = FeePerUnit<VSizeTag>;
176
+
177
+ // FeePerUnit instance for satoshi / WU.
178
+ struct WeightTag {};
179
+ using FeePerWeight = FeePerUnit<WeightTag>;
180
+
159
181
#endif // BITCOIN_UTIL_FEEFRAC_H
You can’t perform that action at this time.
0 commit comments