pub struct ChaincraftNode {
pub id: PeerId,
pub registry: Arc<RwLock<SharedObjectRegistry>>,
pub app_objects: Arc<RwLock<ApplicationObjectRegistry>>,
pub discovery: Option<DiscoveryManager>,
pub storage: Arc<dyn Storage>,
pub peers: Arc<RwLock<HashMap<PeerId, PeerInfo>>>,
pub config: NodeConfig,
pub running: Arc<RwLock<bool>>,
}
Expand description
Main node structure for Chaincraft network
Fields§
§id: PeerId
Unique identifier for this node
registry: Arc<RwLock<SharedObjectRegistry>>
Registry of shared objects
app_objects: Arc<RwLock<ApplicationObjectRegistry>>
Registry of application objects
discovery: Option<DiscoveryManager>
Discovery manager
storage: Arc<dyn Storage>
Storage backend
peers: Arc<RwLock<HashMap<PeerId, PeerInfo>>>
Connected peers
config: NodeConfig
Node configuration
running: Arc<RwLock<bool>>
Running flag
Implementations§
Source§impl ChaincraftNode
impl ChaincraftNode
Sourcepub fn new_default() -> Self
pub fn new_default() -> Self
Create a new Chaincraft node with default settings (alias for compatibility with examples)
Sourcepub fn builder() -> ChaincraftNodeBuilder
pub fn builder() -> ChaincraftNodeBuilder
Create a new node builder
Sourcepub async fn is_running_async(&self) -> bool
pub async fn is_running_async(&self) -> bool
Check if the node is running (async version)
Sourcepub async fn remove_peer(&self, peer_id: &PeerId) -> Result<()>
pub async fn remove_peer(&self, peer_id: &PeerId) -> Result<()>
Remove a peer from the node’s peer list
Sourcepub async fn connect_to_peer(&mut self, peer_addr: &str) -> Result<()>
pub async fn connect_to_peer(&mut self, peer_addr: &str) -> Result<()>
Connect to a peer
Sourcepub async fn connect_to_peer_with_discovery(
&mut self,
peer_addr: &str,
_discovery: bool,
) -> Result<()>
pub async fn connect_to_peer_with_discovery( &mut self, peer_addr: &str, _discovery: bool, ) -> Result<()>
Connect to a peer with optional discovery
Create a shared message
Sourcepub fn has_object(&self, _hash: &str) -> bool
pub fn has_object(&self, _hash: &str) -> bool
Check if the node has a specific object
Sourcepub async fn get_object(&self, hash: &str) -> Result<String>
pub async fn get_object(&self, hash: &str) -> Result<String>
Get an object by hash
Add a shared object (application object)
Get shared objects (for compatibility with Python tests)
Get shared object count
Create shared message with application object processing
Sourcepub async fn get_discovery_info(&self) -> Value
pub async fn get_discovery_info(&self) -> Value
Get discovery info for testing
Sourcepub fn is_running(&self) -> bool
pub fn is_running(&self) -> bool
Check if node is running (sync version for compatibility)