feat(core): implement infosync#495
Conversation
|
@claude review this PR |
|
Claude finished @iamquang95's task in 2m 5s —— View job Review:
|
|
For 1, keep the current implementation for parity, and it's low enhancement |
varex83
left a comment
There was a problem hiding this comment.
LGTM overall! Only a few improvements could be made
| results.push(result); | ||
|
|
||
| if results.len() >= MAX_RESULTS { | ||
| results.remove(0); |
There was a problem hiding this comment.
This is O(n) operation, better to use deque here
| .expect("infosync results mutex poisoned"); | ||
|
|
||
| let mut resp = self.local_protocols.clone(); | ||
| for result in results.iter() { |
There was a problem hiding this comment.
Since slots in the results are in increasing order, we can make this search using binary search, which gives us O(n) -> O(log(n))
| .expect("infosync results mutex poisoned"); | ||
|
|
||
| let mut resp = vec![ProposalType::Full]; | ||
| for result in results.iter() { |
| } | ||
|
|
||
| /// Returns the versions as their string representations. | ||
| fn versions_to_strings(versions: &[SemVer]) -> Vec<String> { |
| } | ||
|
|
||
| /// Returns the proposal types as their wire-format strings. | ||
| fn proposals_to_strings(proposals: &[ProposalType]) -> Vec<String> { |
Fix #173
Stack on: #489
crates/infosync/src/lib.rs(+506)new/trigger/protocols(slot)/proposals(slot), aResultStore(dedup, history cap, slot-selection), and the priority subscribe callback.crates/infosync/tests/infosync_integration.rs(+356)TestInfoSync): all nodes converge on the same agreed priorities.crates/core/src/types.rs(+89)ProposalType→ open enum (Unknown(String)),as_str/From/ serde-via-String; dropsCopy.crates/infosync/src/lib.rs— self-contained. Check the store dedup/cap (>=⇒ caps at 99, matches charon),protocols/proposalsslot-selection + defaults (local/[Full]),handle_resultstopic routing,build_request(3 topics + InfoSync duty).crates/core/src/types.rs— the only shared-type change. Design call to confirm:ProposalTypeopen enum + loss ofCopy, to preserve forward-compat values from newer peers (charon's type is an open string). Only users are core's def + infosync.app.Run(infosync isn't wired into the app yet).