haskoin-node-0.17.1: P2P library for Bitcoin and Bitcoin Cash
Safe HaskellNone
LanguageHaskell2010

Haskoin.Node

Synopsis

Documentation

type WithConnection = (Conduits -> IO ()) -> IO () Source #

data Peer Source #

Mailbox for a peer.

Instances

Instances details
Eq Peer Source # 
Instance details

Defined in Haskoin.Node.Peer

Methods

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

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

Show Peer Source # 
Instance details

Defined in Haskoin.Node.Peer

Methods

showsPrec :: Int -> Peer -> ShowS #

show :: Peer -> String #

showList :: [Peer] -> ShowS #

peer :: (MonadUnliftIO m, MonadLoggerIO m) => PeerConfig -> TVar Bool -> Inbox PeerMessage -> m () Source #

Run peer process in current thread.

wrapPeer :: MonadIO m => PeerConfig -> TVar Bool -> Mailbox PeerMessage -> m Peer Source #

sendMessage :: MonadIO m => Message -> Peer -> m () Source #

Send a network message to peer.

killPeer :: MonadIO m => PeerException -> Peer -> m () Source #

Kill a peer with the provided exception.

getBlocks :: MonadUnliftIO m => Network -> Int -> Peer -> [BlockHash] -> m (Maybe [Block]) Source #

Request full blocks from peer. Will return Nothing if the list of blocks returned by the peer is incomplete, comes out of order, or a timeout is reached.

getTxs :: MonadUnliftIO m => Network -> Int -> Peer -> [TxHash] -> m (Maybe [Tx]) Source #

Request transactions from peer. Will return Nothing if the list of transactions returned by the peer is incomplete, comes out of order, or a timeout is reached.

getData :: MonadUnliftIO m => Int -> Peer -> GetData -> m (Maybe [Either Tx Block]) Source #

Request transactions and/or blocks from peer. Return Nothing if any single inventory fails to be retrieved, if they come out of order, or if timeout is reached.

pingPeer :: MonadUnliftIO m => Int -> Peer -> m Bool Source #

Ping a peer and await response. Return False if response not received before timeout.

setFree :: MonadIO m => Peer -> m () Source #

data PeerEvent Source #

Instances

Instances details
Eq PeerEvent Source # 
Instance details

Defined in Haskoin.Node.Manager

type Port = Int Source #

data ChainConfig Source #

Configuration for chain syncing process.

Constructors

ChainConfig 

Fields

data ChainEvent Source #

Events originating from chain syncing process.

Constructors

ChainBestBlock !BlockNode

chain has new best block

ChainSynced !BlockNode

chain is in sync with the network

Instances

Instances details
Eq ChainEvent Source # 
Instance details

Defined in Haskoin.Node.Chain

Show ChainEvent Source # 
Instance details

Defined in Haskoin.Node.Chain

data Chain Source #

Mailbox for chain header syncing process.

chainGetBlock :: MonadIO m => BlockHash -> Chain -> m (Maybe BlockNode) Source #

Get a block header from Chain process.

chainGetBest :: MonadIO m => Chain -> m BlockNode Source #

Get best block header from chain process.

chainGetAncestor :: MonadIO m => BlockHeight -> BlockNode -> Chain -> m (Maybe BlockNode) Source #

Get ancestor of BlockNode at BlockHeight from chain process.

chainGetParents :: MonadIO m => BlockHeight -> BlockNode -> Chain -> m [BlockNode] Source #

Get parents of BlockNode starting at BlockHeight from chain process.

chainGetSplitBlock :: MonadIO m => BlockNode -> BlockNode -> Chain -> m BlockNode Source #

Get last common block from chain process.

chainPeerConnected :: MonadIO m => Peer -> Chain -> m () Source #

Notify chain that a new peer is connected.

chainPeerDisconnected :: MonadIO m => Peer -> Chain -> m () Source #

Notify chain that a peer has disconnected.

chainIsSynced :: MonadIO m => Chain -> m Bool Source #

Is chain in sync with network?

chainBlockMain :: MonadIO m => BlockHash -> Chain -> m Bool Source #

Is given BlockHash in the main chain?

chainHeaders :: MonadIO m => Peer -> [BlockHeader] -> Chain -> m () Source #

Peer sends a bunch of headers to the chain process.

data NodeConfig Source #

General node configuration.

Constructors

NodeConfig 

Fields

data NodeEvent Source #

Instances

Instances details
Eq NodeEvent Source # 
Instance details

Defined in Haskoin.Node

data Node Source #

Constructors

Node 

withNode :: (MonadLoggerIO m, MonadUnliftIO m) => NodeConfig -> (Node -> m a) -> m a Source #

Launch node process in the foreground.