Liking cljdoc? Tell your friends :D

urd.consensus.network

Network abstraction for consensus protocols.

Provides both mock (in-memory) and real (kabel) implementations.

Network abstraction for consensus protocols.

Provides both mock (in-memory) and real (kabel) implementations.
raw docstring

ConsensusNetworkclj/sprotocol

Abstract network interface for consensus communication.

Abstract network interface for consensus communication.

broadcast!clj/s

(broadcast! this topic message)

Broadcast message to all peers on topic. Returns channel that completes when sent.

Broadcast message to all peers on topic.
Returns channel that completes when sent.

close-network!clj/s

(close-network! this)

Close all connections and cleanup. Returns channel that completes when closed.

Close all connections and cleanup.
Returns channel that completes when closed.

get-peer-countclj/s

(get-peer-count this)

Get number of connected peers. Returns channel yielding count.

Get number of connected peers.
Returns channel yielding count.

subscribe!clj/s

(subscribe! this topic handler)

Subscribe to messages on topic. Handler is (fn [message] ...) called for each message. Returns channel that yields subscription handle.

Subscribe to messages on topic.
Handler is (fn [message] ...) called for each message.
Returns channel that yields subscription handle.

unsubscribe!clj/s

(unsubscribe! this topic handle)

Unsubscribe from topic. Returns channel that completes when unsubscribed.

Unsubscribe from topic.
Returns channel that completes when unsubscribed.
sourceraw docstring

create-mock-clusterclj/s

(create-mock-cluster peer-ids)

Create a cluster of interconnected mock networks.

All peers share the same message bus, simulating perfect broadcast network (no partitions, no message loss).

Args: peer-ids - Collection of peer UUIDs

Returns: Map of {peer-id → MockNetwork}

Create a cluster of interconnected mock networks.

All peers share the same message bus, simulating perfect
broadcast network (no partitions, no message loss).

Args:
  peer-ids - Collection of peer UUIDs

Returns:
  Map of {peer-id → MockNetwork}
sourceraw docstring

create-mock-networkclj/s

(create-mock-network peer-id)
(create-mock-network peer-id shared-bus)

Create an in-memory mock network for testing.

Args: peer-id - UUID for this peer shared-bus - Optional shared bus for multi-peer simulation

Returns: MockNetwork instance

Create an in-memory mock network for testing.

Args:
  peer-id - UUID for this peer
  shared-bus - Optional shared bus for multi-peer simulation

Returns:
  MockNetwork instance
sourceraw docstring

find-partitionclj/s

(find-partition peer-id partitions)

Find which partition a peer belongs to.

Args: peer-id - UUID of peer partitions - Vector of peer-id sets

Returns: Set of peers in same partition, or nil if not found

Find which partition a peer belongs to.

Args:
  peer-id - UUID of peer
  partitions - Vector of peer-id sets

Returns:
  Set of peers in same partition, or nil if not found
sourceraw docstring

heal-partitionclj/s

(heal-partition networks)

Remove partition filter from networks, restoring full connectivity.

Args: networks - Map of {peer-id → MockNetwork}

Returns: Map of {peer-id → MockNetwork} (same instances, partition-filter atoms reset to nil)

Remove partition filter from networks, restoring full connectivity.

Args:
  networks - Map of {peer-id → MockNetwork}

Returns:
  Map of {peer-id → MockNetwork} (same instances, partition-filter atoms reset to nil)
sourceraw docstring

network-statsclj/s

(network-stats network)

Get statistics about network activity.

Args: network - MockNetwork instance

Returns: Map with :messages-sent, :messages-received, etc.

Get statistics about network activity.

Args:
  network - MockNetwork instance

Returns:
  Map with :messages-sent, :messages-received, etc.
sourceraw docstring

remove-message-delayclj/s

(remove-message-delay network)

Remove message delay from network, restoring instant delivery.

Args: network - MockNetwork

Returns: Network with delay removed

Remove message delay from network, restoring instant delivery.

Args:
  network - MockNetwork

Returns:
  Network with delay removed
sourceraw docstring

simulate-message-delayclj/s

(simulate-message-delay network min-ms max-ms)

Add random delays to messages (simulates network latency).

Adds delay-ms field to network that causes messages to be delivered after a random delay.

Args: network - MockNetwork min-ms - Minimum delay in milliseconds max-ms - Maximum delay in milliseconds

Returns: Network with delay configuration

Add random delays to messages (simulates network latency).

Adds delay-ms field to network that causes messages to be
delivered after a random delay.

Args:
  network - MockNetwork
  min-ms - Minimum delay in milliseconds
  max-ms - Maximum delay in milliseconds

Returns:
  Network with delay configuration
sourceraw docstring

simulate-network-partitionclj/s

(simulate-network-partition networks partitions)

Simulate network partition by filtering messages.

Creates partitions where peers can only communicate within their partition group. Messages between partitions are dropped.

Args: networks - Map of {peer-id → MockNetwork} partitions - Vector of peer-id sets, e.g. [#{p1 p2} #{p3 p4}]

Returns: Map of {peer-id → MockNetwork} (same instances, partition-filter atoms modified)

Simulate network partition by filtering messages.

Creates partitions where peers can only communicate
within their partition group. Messages between partitions are dropped.

Args:
  networks - Map of {peer-id → MockNetwork}
  partitions - Vector of peer-id sets, e.g. [#{p1 p2} #{p3 p4}]

Returns:
  Map of {peer-id → MockNetwork} (same instances, partition-filter atoms modified)
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
←Move to previous article
→Move to next article
Ctrl+/Jump to the search field
× close