mirror of
https://github.com/luxfi/consensus.git
synced 2026-09-24 00:26:58 +00:00
Problem: Duplicate bag implementations across repos - node/utils/bag/ (183 lines, full featured) - consensus/utils/bag/ (95 lines, simplified) - node-fresh/utils/bag/ (another copy) Solution: Make consensus/utils/bag the canonical implementation Why consensus owns bag: 1. Consensus is lower-level (node depends on consensus) 2. Threshold tracking is consensus-critical (voting algorithms) 3. Avoids circular dependencies Changes: - Enhanced consensus bag with all node bag methods (203 lines) - Added SetThreshold() / Threshold() for consensus voting - Added Split(), Remove(), Clone(), String() utilities - Fixed nil map panic by initializing metThreshold in init() - Updated error_propagation_test.go to import consensus bag - Documented as canonical in LLM.md Features: - Threshold tracking for consensus voting - Vote counting and analysis - Lazy initialization (handles nil maps) - Full compatibility with node bag API Test status: - ✅ All chain engine tests pass (28 tests) - ✅ All integration tests pass (61s) - ✅ Error propagation test works with new import Next: Node should update to import github.com/luxfi/consensus/utils/bag