sigil-node · ws
Source declarations, signatures and documentation for ws.
Source: sigil/node/sigil-node/src/ws.rs. SHA-256: 447f928444a41a8f618d616faf200d6abd801ce50049a89c422369a17fe5f9c9.
This reference follows declared source modules, retains conditional attributes, and includes public declarations and implementation methods. Private-module re-exports and trait resolution require the compiler; this is a source reference, not a claim that every listed item is a root import. Function bodies and constant values are omitted.
ws::BlockHeaderEvent
A finalized block header — the event broadcast to newBlock.
#[derive(Debug, Clone, Serialize)]
pub struct BlockHeaderEvent {
pub height: u64,
pub hash: String,
pub parent_hash: String,
pub proposer_did: String,
pub tx_count: usize,
pub finalized_at: u64
}Source line: 79.
ws::TxAdmittedEvent
A mempool-admitted transaction header — newTx event.
#[derive(Debug, Clone, Serialize)]
pub struct TxAdmittedEvent {
pub hash: String,
pub kind: String,
pub fee: u64,
pub accepted_at: u64
}Source line: 90.
ws::ConsensusEvent
A redacted consensus event — consensus topic.
#[derive(Debug, Clone, Serialize)]
pub struct ConsensusEvent {
pub event: String,
pub round: Option<u64>,
pub at: u64
}Source line: 99.
ws::AccountDeltaEvent
Identity-bound receipt summary delivered only on /ws-private.
#[derive(Debug, Clone, Serialize)]
pub struct AccountDeltaEvent {
pub did: String,
pub tx_hash: String,
pub block_height: u64,
pub tx_index: u32,
pub status: String,
pub topics: Vec<String>,
pub state_partitions: Vec<String>
}Source line: 107.
ws::ContractWsEvent
Contract event envelope delivered only on /ws-private.
#[derive(Debug, Clone, Serialize)]
pub struct ContractWsEvent {
pub contract: String,
pub tx_hash: String,
pub block_height: u64,
pub tx_index: u32,
pub source: String,
pub topic: String,
pub data_hash: String
}Source line: 119.
ws::WsBroadcaster
Shared broadcaster the node uses to fan events out to WebSocket
subscribers. Cloned cheaply via Arc.
#[derive(Clone)]
pub struct WsBroadcaster {
pub new_block: broadcast::Sender<BlockHeaderEvent>,
pub new_tx: broadcast::Sender<TxAdmittedEvent>,
pub consensus: broadcast::Sender<ConsensusEvent>,
pub account_delta: broadcast::Sender<AccountDeltaEvent>,
pub contract_event: broadcast::Sender<ContractWsEvent>
}Source line: 136.
ws::WsBroadcaster::publish_block
Publish a finalized block. Called from the engine when a block reaches finality. No-op if no subscribers are connected.
pub fn publish_block(&self, ev: BlockHeaderEvent);Source line: 157.
ws::WsBroadcaster::publish_tx
Publish a mempool-admit event. Called from
handle_send_transaction after admission.
pub fn publish_tx(&self, ev: TxAdmittedEvent);Source line: 163.
ws::WsBroadcaster::publish_consensus
Publish a (redacted) consensus event.
pub fn publish_consensus(&self, ev: ConsensusEvent);Source line: 168.
ws::WsBroadcaster::publish_account_delta
Publish a private account delta. Called after a block has been persisted so subscribers never see events for uncommitted state.
pub fn publish_account_delta(&self, ev: AccountDeltaEvent);Source line: 174.
ws::WsBroadcaster::publish_contract_event
Publish a private contract event envelope.
pub fn publish_contract_event(&self, ev: ContractWsEvent);Source line: 179.
ws::BROADCASTER
Process-wide broadcaster. Built lazily so tests and headless boot phases do not pay the cost.
pub static BROADCASTER: Lazy<Arc<WsBroadcaster>>;Source line: 186.
ws::public_ws_handler
GET /ws — public read-only subscription endpoint.
pub async fn public_ws_handler(
State(_state): State<crate::rpc_server::RpcState>,
ws: WebSocketUpgrade,
) -> impl IntoResponse;Source line: 224.
ws::private_ws_handler
GET /ws-private — identity-bound subscriptions (validator profile,
bearer-token authenticated).
Per CA-3, identity-bound subscriptions live on a separate endpoint
from the public read-only /ws. Authentication is a bearer token
matched against the SIGIL_WS_PRIVATE_TOKEN env var.
Caveat — token vs. mTLS: the dispatched D9 prompt called for mTLS or OAS DID-signed handshake. Bearer-token auth ships now because mTLS in the Sigil k8s cluster requires a validator-cert bootstrap pipeline that is not yet operational. When that lands (Phase C), the bearer check gets replaced — the endpoint surface stays the same so wallets and operators do not break.
pub async fn private_ws_handler(
State(state): State<crate::rpc_server::RpcState>,
headers: axum::http::HeaderMap,
ws: WebSocketUpgrade,
) -> axum::response::Response;Source line: 245.
ws::publish_private_receipt_events
Publish identity-bound and contract-bound events from committed receipts.
This is called after block persistence succeeds. The public /ws
endpoint never sees these messages; only /ws-private subscribers with a
valid operator token can subscribe to account.<did> or
contract.<address>.
pub fn publish_private_receipt_events(receipts: &[Receipt]);Source line: 307.