haskoin-node-0.18.1: P2P library for Bitcoin and Bitcoin Cash
Safe HaskellSafe-Inferred
LanguageHaskell2010

Haskoin.Node

Synopsis

Documentation

data PeerConfig Source #

Constructors

PeerConfig 

Fields

data Conduits Source #

Constructors

Conduits 

Fields

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

data Peer Source #

Mailbox for a peer.

Instances

Instances details
Show Peer Source # 
Instance details

Defined in Haskoin.Node.Peer

Methods

showsPrec :: Int -> Peer -> ShowS #

show :: Peer -> String #

showList :: [Peer] -> ShowS #

Eq Peer Source # 
Instance details

Defined in Haskoin.Node.Peer

Methods

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

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

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 #

peerPublisher :: Peer -> Publisher (Peer, Message) 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

withPeerManager :: (MonadUnliftIO m, MonadLoggerIO m) => PeerManagerConfig -> (PeerManager -> m a) -> m a Source #

managerBest :: MonadIO m => BlockHeight -> PeerManager -> m () Source #

managerVersion :: MonadIO m => Peer -> Version -> PeerManager -> m () Source #

managerAddrs :: MonadIO m => Peer -> [NetworkAddress] -> PeerManager -> m () Source #

buildVersion :: Network -> Word64 -> BlockHeight -> NetworkAddress -> NetworkAddress -> Word64 -> Version Source #

toSockAddr :: MonadUnliftIO m => Network -> String -> m [SockAddr] Source #

data ChainConfig Source #

Configuration for chain syncing process.

Constructors

ChainConfig 

Fields

Instances

Instances details
MonadIO m => BlockHeaders (ReaderT ChainConfig m) Source # 
Instance details

Defined in Haskoin.Node.Chain

Methods

addBlockHeader :: BlockNode -> ReaderT ChainConfig m ()

getBlockHeader :: BlockHash -> ReaderT ChainConfig m (Maybe BlockNode)

getBestBlockHeader :: ReaderT ChainConfig m BlockNode

setBestBlockHeader :: BlockNode -> ReaderT ChainConfig m ()

addBlockHeaders :: [BlockNode] -> ReaderT ChainConfig m ()

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
Show ChainEvent Source # 
Instance details

Defined in Haskoin.Node.Chain

Eq ChainEvent Source # 
Instance details

Defined in Haskoin.Node.Chain

data Chain Source #

Mailbox for chain header syncing process.

Instances

Instances details
Eq Chain Source # 
Instance details

Defined in Haskoin.Node.Chain

Methods

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

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

MonadIO m => BlockHeaders (ReaderT Chain m) Source # 
Instance details

Defined in Haskoin.Node.Chain

Methods

addBlockHeader :: BlockNode -> ReaderT Chain m ()

getBlockHeader :: BlockHash -> ReaderT Chain m (Maybe BlockNode)

getBestBlockHeader :: ReaderT Chain m BlockNode

setBestBlockHeader :: BlockNode -> ReaderT Chain m ()

addBlockHeaders :: [BlockNode] -> ReaderT Chain m ()

withChain :: (MonadUnliftIO m, MonadLoggerIO m) => ChainConfig -> (Chain -> m a) -> m a Source #

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.