Expand description
SubtreePrefetch sync types (CIP Appendix B - Protocol Selection Matrix).
Types for subtree prefetch-based synchronization, optimized for deep trees with clustered changes.
§When to Use
max_depth > 3(deep trees)divergence < 20%- Changes are clustered in subtrees
§Trade-offs
| Aspect | HashComparison | SubtreePrefetch |
|---|---|---|
| Round trips | O(depth) | O(1) per subtree |
| Data transfer | Minimal | May over-fetch |
| Best for | Scattered changes | Clustered changes |
§Validation
All types have is_valid() methods that should be called after deserializing
from untrusted sources to prevent resource exhaustion attacks.
Structs§
- Subtree
Data - Data for a single subtree.
- Subtree
Prefetch Request - Request for subtree prefetch-based sync.
- Subtree
Prefetch Response - Response containing prefetched subtrees.
Constants§
- DEEP_
TREE_ THRESHOLD - Minimum tree depth to consider SubtreePrefetch over HashComparison.
- DEFAULT_
SUBTREE_ MAX_ DEPTH - Default maximum depth for subtree prefetch.
- MAX_
CLUSTERED_ SUBTREES - Maximum number of differing subtrees for changes to be “clustered”.
- MAX_
DIVERGENCE_ RATIO - Maximum divergence ratio for SubtreePrefetch to be efficient.
- MAX_
ENTITIES_ PER_ SUBTREE - Maximum number of entities per subtree.
- MAX_
SUBTREES_ PER_ REQUEST - Maximum number of subtree roots in a single request.
- MAX_
SUBTREE_ DEPTH - Maximum allowed depth for subtree traversal requests.
- MAX_
TOTAL_ ENTITIES - Maximum total entities across all subtrees in a response.
Functions§
- should_
use_ subtree_ prefetch - Compare HashComparison vs SubtreePrefetch for a given scenario.