You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The `grin_util` crate provides several macros for working with array newtypes - wrapper types around fixed-size arrays. These macros help implement common traits and functionality for these types.
4
+
5
+
## Available Macros
6
+
7
+
### `impl_array_newtype`
8
+
9
+
Implements standard array traits and behavior for newtype wrappers around fixed-size arrays. This includes:
10
+
11
+
- Methods like `as_ptr()`, `as_mut_ptr()`, `len()`, etc.
Implements serialization and deserialization support via Serde for newtype wrappers.
19
+
20
+
### `impl_array_newtype_show`
21
+
22
+
Implements the `Debug` trait for pretty-printing the array newtype.
23
+
24
+
### `impl_index_newtype`
25
+
26
+
Implements various indexing operations for the newtype. This is automatically called by `impl_array_newtype`.
27
+
28
+
## Usage Examples
29
+
30
+
```rust
31
+
// Define a newtype for a 32-byte array
32
+
pubstructChainCode([u8; 32]);
33
+
34
+
// Implement standard array traits
35
+
impl_array_newtype!(ChainCode, u8, 32);
36
+
37
+
// Implement Debug formatting
38
+
impl_array_newtype_show!(ChainCode);
39
+
40
+
// Implement Serde serialization/deserialization
41
+
impl_array_newtype_encodable!(ChainCode, u8, 32);
42
+
```
43
+
44
+
## Notes on Feature Flags
45
+
46
+
With recent Rust versions, conditional compilation within macros is handled differently. The `serde` and other features are now defined at the crate level rather than inside the macros themselves, which prevents warnings about unexpected `cfg` conditions.
Grin's transaction pool is designed to hold all transactions that are not yet included in a block.
4
+
5
+
The transaction pool is split into a stempool and a txpool. The stempool contains "stem" transactions, which are less actively propagated to the rest of the network, as well as txs received via Dandelion "stem" phase. The txpool contains transactions that may be directly propagated to the network, as well as txs received via Dandelion "fluff" phase.
6
+
7
+
### Reconciliation
8
+
9
+
The `Pool::reconcile` function validates transactions in the stempool or txpool against a given block header and removes invalid or duplicated transactions (present in txpool). The optimized implementation filters entries in-place, reducing validations from O(n² + n*m) to O(n + m), where n is the number of transactions in the pool being reconciled and m is the number of transactions in txpool.
10
+
11
+
Reconciliation logs include:
12
+
- Number of entries before/after reconciliation
13
+
- Count of invalid or duplicated transactions removed
14
+
15
+
Example:
16
+
```
17
+
INFO: Starting transaction pool reconciliation with 200 entries
0 commit comments