haskoin-node-0.4.2: Implementation of a Bitoin node.

Safe HaskellNone
LanguageHaskell98

Network.Haskoin.Node.HeaderTree

Synopsis

Documentation

data NodeBlock Source #

Instances

Eq NodeBlock Source # 
Show NodeBlock Source # 
PersistField NodeBlock Source # 
PersistEntity NodeBlock Source # 
PersistFieldSql NodeBlock Source # 
ToBackendKey SqlBackend NodeBlock Source # 
Eq (Key NodeBlock) Source # 
Ord (Key NodeBlock) Source # 
Read (Key NodeBlock) Source # 
Show (Key NodeBlock) Source # 
ToJSON (Key NodeBlock) Source # 
FromJSON (Key NodeBlock) Source # 
PersistField (Key NodeBlock) Source # 
PersistFieldSql (Key NodeBlock) Source # 
ToHttpApiData (Key NodeBlock) Source # 
FromHttpApiData (Key NodeBlock) Source # 
PathPiece (Key NodeBlock) Source # 
data EntityField NodeBlock Source # 
type PersistEntityBackend NodeBlock Source # 
data Key NodeBlock Source # 
data Unique NodeBlock Source # 

initHeaderTree :: MonadIO m => SqlPersistT m () Source #

Initialize the block header chain by inserting the genesis block if it doesn't already exist.

getParentBlock :: MonadIO m => NodeBlock -> SqlPersistT m (Maybe NodeBlock) Source #

Finds the parent of a block.

getBlockWindow Source #

Arguments

:: MonadIO m 
=> NodeBlock

Best block

-> NodeBlock

Start of window

-> Word32

Window count

-> SqlPersistT m BlockChainAction 

Return blockchain action to connect given block with best block. Count will limit the amount of blocks building up from split point towards the best block.

getBlockAfterTime :: MonadIO m => Timestamp -> SqlPersistT m (Maybe NodeBlock) Source #

Get node immediately at or after timestamp in main chain.

getChildBlocks :: MonadIO m => BlockHash -> SqlPersistT m [NodeBlock] Source #

Get all children for a block

getBlockByHeight Source #

Arguments

:: MonadIO m 
=> NodeBlock

Best block

-> BlockHeight 
-> SqlPersistT m (Maybe NodeBlock) 

Get ancestor of specified block at given height.

getBlocksByHeight Source #

Arguments

:: MonadIO m 
=> NodeBlock

Best block

-> [BlockHeight] 
-> SqlPersistT m [NodeBlock] 

Get ancestors for specified block at given heights.

getBlocksFromHeight Source #

Arguments

:: MonadIO m 
=> NodeBlock

Best block

-> Word32

Count (0 for all)

-> BlockHeight

Height from (including)

-> SqlPersistT m [NodeBlock] 

Get a range of block headers building up to specified block. If specified height is too large, an empty list will be returned.

getBlocksAtHeight :: MonadIO m => BlockHeight -> SqlPersistT m [NodeBlock] Source #

Get blocks at specified height in all chains.

putBlock :: MonadIO m => NodeBlock -> SqlPersistT m () Source #

Put single block in database.

putBlocks :: MonadIO m => [NodeBlock] -> SqlPersistT m () Source #

Put multiple blocks in database.

genesisBlock :: NodeBlock Source #

Genesis block.

splitBlock :: MonadIO m => NodeBlock -> NodeBlock -> SqlPersistT m NodeBlock Source #

Get node height and chain common to both given.

splitChains :: MonadIO m => (NodeBlock, Word32) -> (NodeBlock, Word32) -> SqlPersistT m (NodeBlock, [NodeBlock], [NodeBlock]) Source #

Find the split point between two nodes. It also returns the two partial chains leading from the split point to the respective nodes. Tuples must contain a block node and the count of nodes that should be returned from the split towards that block. 0 means all.

nodeBlock Source #

Arguments

:: NodeBlock

Parent block node

-> Word32

Chain number for new node

-> BlockHeader 
-> NodeBlock 

Create a block node data structure from a block header.

isBestChain :: BlockChainAction -> Bool Source #

Returns True if the action is a best chain.

isChainReorg :: BlockChainAction -> Bool Source #

Returns True if the action is a chain reorg.

isSideChain :: BlockChainAction -> Bool Source #

Returns True if the action is a side chain.

isKnownChain :: BlockChainAction -> Bool Source #

Returns True if the action is a known chain.

connectHeader :: MonadIO m => NodeBlock -> BlockHeader -> Timestamp -> SqlPersistT m (Either String BlockChainAction) Source #

Connect a block header to this block header chain. Corresponds to bitcoind function ProcessBlockHeader and AcceptBlockHeader in main.cpp.

connectHeaders :: MonadIO m => NodeBlock -> [BlockHeader] -> Timestamp -> SqlPersistT m (Either String BlockChainAction) Source #

A more efficient way of connecting a list of block headers than connecting them individually. The list of block headers have must form a valid chain.

blockLocator :: MonadIO m => NodeBlock -> SqlPersistT m BlockLocator Source #

Returns a BlockLocator object for a given block hash.

pruneChain :: MonadIO m => NodeBlock -> SqlPersistT m NodeBlock Source #

Remove all other chains from database and return updated best block node.