Struct rings_node::processor::Processor
source · pub struct Processor {
pub swarm: Arc<Swarm>,
pub stabilization: Arc<Stabilization>,
}Expand description
Processor for rings-node jsonrpc server
Fields§
§swarm: Arc<Swarm>a swarm instance
stabilization: Arc<Stabilization>a stabilization instance,
Implementations§
source§impl Processor
impl Processor
sourcepub fn generate_signature(secret_key: &SecretKey) -> String
pub fn generate_signature(secret_key: &SecretKey) -> String
Generate Signature for Authorization
sourcepub fn verify_signature(signature: &[u8], public_key: &PublicKey) -> Result<bool>
pub fn verify_signature(signature: &[u8], public_key: &PublicKey) -> Result<bool>
verify signature will throw error when signature is illegal
sourcepub async fn create_offer(&self) -> Result<(Arc<Transport>, Encoded)>
pub async fn create_offer(&self) -> Result<(Arc<Transport>, Encoded)>
Create an Offer and waiting for connection. The process of manually handshake is:
- PeerA: create_offer
- PeerA: send the handshake info to PeerB.
- PeerB: answer_offer
- PeerB: send the handshake info to PeerA.
- PeerA: accept_answer.
sourcepub async fn connect_peer_via_http(
&self,
peer_url: &str
) -> Result<Arc<Transport>>
pub async fn connect_peer_via_http(
&self,
peer_url: &str
) -> Result<Arc<Transport>>
Connect peer with remote rings-node jsonrpc server.
- peer_url: the remote rings-node jsonrpc server url.
sourcepub async fn answer_offer(
&self,
ice_info: &str
) -> Result<(Arc<Transport>, Encoded)>
pub async fn answer_offer(
&self,
ice_info: &str
) -> Result<(Arc<Transport>, Encoded)>
Answer an Offer. The process of manually handshake is:
- PeerA: create_offer
- PeerA: send the handshake info to PeerB.
- PeerB: answer_offer
- PeerB: send the handshake info to PeerA.
- PeerA: accept_answer.
sourcepub async fn connect_with_did(
&self,
did: Did,
wait_for_open: bool
) -> Result<Peer>
pub async fn connect_with_did(
&self,
did: Did,
wait_for_open: bool
) -> Result<Peer>
Connect peer with web3 did. There are 3 peers: PeerA, PeerB, PeerC.
- PeerA has a connection with PeerB.
- PeerC has a connection with PeerB.
- PeerC can connect PeerA with PeerA’s web3 address.
sourcepub async fn accept_answer(&self, transport_id: &str, ice: &str) -> Result<Peer>
pub async fn accept_answer(&self, transport_id: &str, ice: &str) -> Result<Peer>
Accept an answer of a connection. The process of manually handshake is:
- PeerA: create_offer
- PeerA: send the handshake info to PeerB.
- PeerB: answer_offer
- PeerB: send the handshake info to PeerA.
- PeerA: accept_answer.
sourcepub async fn list_peers(&self) -> Result<Vec<Peer>>
pub async fn list_peers(&self) -> Result<Vec<Peer>>
List all peers.
sourcepub async fn disconnect(&self, did: Did) -> Result<()>
pub async fn disconnect(&self, did: Did) -> Result<()>
Disconnect a peer with web3 did.
sourcepub async fn close_pending_transport(&self, transport_id: &str) -> Result<()>
pub async fn close_pending_transport(&self, transport_id: &str) -> Result<()>
Close pending transport
sourcepub async fn send_message(&self, destination: &str, msg: &[u8]) -> Result<Uuid>
pub async fn send_message(&self, destination: &str, msg: &[u8]) -> Result<Uuid>
Send custom message to a did.
sourcepub async fn send_http_request_message<U, T>(
&self,
destination: &str,
name: U,
method: Method,
url: U,
timeout: T,
headers: &[(U, U)],
body: Option<Bytes>
) -> Result<Uuid>where
U: ToString,
T: Into<Timeout>,
pub async fn send_http_request_message<U, T>(
&self,
destination: &str,
name: U,
method: Method,
url: U,
timeout: T,
headers: &[(U, U)],
body: Option<Bytes>
) -> Result<Uuid>where
U: ToString,
T: Into<Timeout>,
send http request message to node
- destination: did of destination
- url: ipfs url
- timeout: timeout in millisecond
sourcepub async fn send_simple_text_message(
&self,
destination: &str,
text: &str
) -> Result<Uuid>
pub async fn send_simple_text_message(
&self,
destination: &str,
text: &str
) -> Result<Uuid>
send simple text message
- destination: did of destination
- text: text message
sourcepub async fn storage_check_cache(&self, did: Did) -> Option<VirtualNode>
pub async fn storage_check_cache(&self, did: Did) -> Option<VirtualNode>
check local cache of dht
sourcepub async fn storage_fetch(&self, did: Did) -> Result<()>
pub async fn storage_fetch(&self, did: Did) -> Result<()>
fetch virtual node from DHT
sourcepub async fn storage_store(&self, vnode: VirtualNode) -> Result<()>
pub async fn storage_store(&self, vnode: VirtualNode) -> Result<()>
store virtual node on DHT
sourcepub async fn storage_append_data(&self, topic: &str, data: Encoded) -> Result<()>
pub async fn storage_append_data(&self, topic: &str, data: Encoded) -> Result<()>
append data to a virtual node on DHT
sourcepub async fn register_service(&self, name: &str) -> Result<()>
pub async fn register_service(&self, name: &str) -> Result<()>
register service