OpenPay (3 crates, ~13k LOC, 175 tests) op-connect sub-merchant onboarding + KYB + split-payments + payouts + 1099-K op-3ds2 3DS2.3 SCA processor (AReq/ARes/CReq/CRes/RReq/RRes + exemptions) op-tax US/EU/UK/AU/CA/IN tax with Avalara/Stripe/CCH/Vertex/TaxJar adapters Smart Byte (3 crates, ~7k LOC, 57 tests) smart-byte-libp2p libp2p transport (kad/gossipsub/mdns/autonat/relay/dcutr/identify/ping/req_resp) smart-byte-crdt LWW/GCounter/PnCounter/OrSet/LwwMap/RgaList/2P-Set + HLC + vector clock + Automerge/Yjs interop smart-byte-keri-witness KERI key-rotation cycle + witness layer + watchers + recovery + delegation EOC (3 crates, ~8k LOC, 108 tests) eoc-tools function-calling across Anthropic/OpenAI/Google/Mistral/Cohere + parallel exec + sandbox eoc-multimodal vision (CLIP/SigLIP/ColPali) + audio (Whisper/MMS) + video sampling + modality router eoc-spec-decode vanilla + SpS-with-temp + lookahead speculative decoding + EAGLE/Medusa stubs All three workspaces compile cleanly. Forbidden-unsafe, no unwrap outside tests. Co-Authored-By: Claude Opus 4.7 <[email protected]>
38 lines
1.3 KiB
Rust
38 lines
1.3 KiB
Rust
//! Bootstrap and content-advertisement helpers built on Kademlia.
|
|
|
|
use libp2p::{Multiaddr, PeerId, kad};
|
|
use smart_byte_core::Said;
|
|
|
|
use crate::error::{Error, Result};
|
|
use crate::node::Libp2pNode;
|
|
|
|
/// Seed the Kademlia routing table from a list of known peers and
|
|
/// trigger a bootstrap. Caller is expected to drive the swarm so the
|
|
/// bootstrap can make progress.
|
|
pub fn bootstrap(node: &mut Libp2pNode, peers: &[(PeerId, Multiaddr)]) -> Result<()> {
|
|
let kad = &mut node.swarm.behaviour_mut().kad;
|
|
for (peer, addr) in peers {
|
|
kad.add_address(peer, addr.clone());
|
|
}
|
|
kad.bootstrap()
|
|
.map(|_| ())
|
|
.map_err(|e| Error::Kademlia(format!("{e:?}")))
|
|
}
|
|
|
|
/// Advertise this node as a provider of the envelope identified by
|
|
/// `said` on the Kademlia content-providers ring.
|
|
pub fn announce_said(node: &mut Libp2pNode, said: Said) -> Result<()> {
|
|
let key = kad::RecordKey::new(&said.as_bytes().to_vec());
|
|
node.swarm
|
|
.behaviour_mut()
|
|
.kad
|
|
.start_providing(key)
|
|
.map(|_| ())
|
|
.map_err(|e| Error::Kademlia(format!("{e:?}")))
|
|
}
|
|
|
|
/// Stop advertising `said`.
|
|
pub fn stop_announcing(node: &mut Libp2pNode, said: Said) {
|
|
let key = kad::RecordKey::new(&said.as_bytes().to_vec());
|
|
node.swarm.behaviour_mut().kad.stop_providing(&key);
|
|
}
|