libp2p-hs-0.1.0.0: Haskell implementation of the libp2p networking stack
Safe HaskellNone
LanguageGHC2021

LibP2P.DHT.Types

Description

Core types for the Kademlia DHT.

Defines the DHT keyspace (256-bit SHA-256 keys), routing table entry structure, and protocol constants (k=20, alpha=10).

Synopsis

Documentation

newtype DHTKey Source #

256-bit key in the DHT keyspace (always exactly 32 bytes, SHA-256 output).

Construct via keyToDHTKey (or peerIdToKey for peer IDs) — never wrap raw wire bytes directly. Per specs/kad-dht the distance metric is XOR over SHA-256 digests, while RPC messages carry the raw key.

Constructors

DHTKey ByteString 

Instances

Instances details
Show DHTKey Source # 
Instance details

Defined in LibP2P.DHT.Types

Eq DHTKey Source # 
Instance details

Defined in LibP2P.DHT.Types

Methods

(==) :: DHTKey -> DHTKey -> Bool #

(/=) :: DHTKey -> DHTKey -> Bool #

Ord DHTKey Source # 
Instance details

Defined in LibP2P.DHT.Types

data BucketEntry Source #

A single entry in a k-bucket.

Constructors

BucketEntry 

Fields

Instances

Instances details
Show BucketEntry Source # 
Instance details

Defined in LibP2P.DHT.Types

Eq BucketEntry Source # 
Instance details

Defined in LibP2P.DHT.Types

data ConnectionType Source #

Connection status of a peer (from DHT protobuf spec).

Constructors

NotConnected

0: no connection, no extra info

Connected

1: live connection

CanConnect

2: recently connected

CannotConnect

3: recently failed to connect

data InsertResult Source #

Result of attempting to insert a peer into the routing table.

Constructors

Inserted

Peer was added to the bucket

Updated

Existing peer was moved to tail (most recently seen)

BucketFull !PeerId

Bucket is full; returns LRS peer ID for pinging

Instances

Instances details
Show InsertResult Source # 
Instance details

Defined in LibP2P.DHT.Types

Eq InsertResult Source # 
Instance details

Defined in LibP2P.DHT.Types

kValue :: Int Source #

Replication parameter: each k-bucket holds up to k peers.

alphaValue :: Int Source #

Concurrency parameter for iterative lookups.

numBuckets :: Int Source #

Number of buckets (one per bit of the 256-bit keyspace).