cardano-wallet-core-2022.7.1: The Wallet Backend for a Cardano node.
Safe Haskell None
Language Haskell2010

Cardano.Wallet.Network

Synopsis

Interface

data NetworkLayer m block Source #

Interface for network capabilities.

Constructors

NetworkLayer

Fields

Errors

Chain following

data ChainFollower m point tip blocks Source #

A collection of callbacks to use with the chainSync function.

Constructors

ChainFollower

Fields

  • checkpointPolicy :: Integer -> CheckpointPolicy

    The policy for creating and pruning checkpoints that is used by the ChainFollower . The argument of this field is the epochStability .

    Exposing this policy here enables any chain synchronizer which does not retrieve full blocks, such as lightSync , to specifically target those block heights at which the ChainFollower intends to create checkpoints.

  • readChainPoints :: m [point]

    Callback for reading the local tip. Used to negotiate the intersection with the node.

    A response of [] is interpreted as Origin -- i.e. the chain will be served from genesis.

  • rollForward :: blocks -> tip -> m ()

    Callback for rolling forward.

    Implementors _may_ delete old checkpoints while rolling forward.

  • rollBackward :: point -> m point

    Roll back to the requested slot, or further, and return the point actually rolled back to.

    Example 1:

    If the follower stores checkpoints for all blocks, we can always roll back to the requested point exactly.

    -- If
    knownSlots follower shouldReturn [0,1,2,3]
    let requested = SlotNo 2
    -- Then
    actual <- rollBackward follower requested
    knownSlots follower shouldReturn` [0,1,2]
    actual shouldBe SlotNo 2
    

    Note that the slotNos are unlikely to be consecutive in real life, but this doesn't matter, as ouroboros-network asks us to rollback to points, corresponding to blocks.

    Example 2:

    -- If
    knownSlots follower shouldReturn [0,9,10]
    let requested = SlotNo 2
    -- Then
    actual <- rollBackward follower requested
    knownSlots follower shouldReturn` [0]
    actual shouldBe SlotNo 0
    

mapChainFollower Source #

Arguments

:: Functor m
=> (point1 -> point2)

Covariant

-> (point2 -> point1)

Contravariant

-> (tip2 -> tip1)

Contravariant

-> (blocks2 -> blocks1)

Contravariant

-> ChainFollower m point1 tip1 blocks1
-> ChainFollower m point2 tip2 blocks2

data ChainFollowLog Source #

Higher level log of a chain follower. Includes computed statistics about synchronization progress.

Instances

Instances details
Eq ChainFollowLog Source #
Instance details

Defined in Cardano.Wallet.Network

Show ChainFollowLog Source #
Instance details

Defined in Cardano.Wallet.Network

Generic ChainFollowLog Source #
Instance details

Defined in Cardano.Wallet.Network

ToText ChainFollowLog Source #
Instance details

Defined in Cardano.Wallet.Network

HasPrivacyAnnotation ChainFollowLog Source #
Instance details

Defined in Cardano.Wallet.Network

Methods

getPrivacyAnnotation :: ChainFollowLog -> PrivacyAnnotation

HasSeverityAnnotation ChainFollowLog Source #
Instance details

Defined in Cardano.Wallet.Network

type Rep ChainFollowLog Source #
Instance details

Defined in Cardano.Wallet.Network

data ChainSyncLog block point Source #

Low-level logs of the ChainSync mini-protocol

Instances

Instances details
( Eq point, Eq block) => Eq ( ChainSyncLog block point) Source #
Instance details

Defined in Cardano.Wallet.Network

( Show point, Show block) => Show ( ChainSyncLog block point) Source #
Instance details

Defined in Cardano.Wallet.Network

Generic ( ChainSyncLog block point) Source #
Instance details

Defined in Cardano.Wallet.Network

Associated Types

type Rep ( ChainSyncLog block point) :: Type -> Type Source #

Methods

from :: ChainSyncLog block point -> Rep ( ChainSyncLog block point) x Source #

to :: Rep ( ChainSyncLog block point) x -> ChainSyncLog block point Source #

ToText ( ChainSyncLog BlockHeader ChainPoint ) Source #
Instance details

Defined in Cardano.Wallet.Network

HasPrivacyAnnotation ( ChainSyncLog block point) Source #
Instance details

Defined in Cardano.Wallet.Network

Methods

getPrivacyAnnotation :: ChainSyncLog block point -> PrivacyAnnotation

HasSeverityAnnotation ( ChainSyncLog block point) Source #
Instance details

Defined in Cardano.Wallet.Network

Methods

getSeverityAnnotation :: ChainSyncLog block point -> Severity

type Rep ( ChainSyncLog block point) Source #
Instance details

Defined in Cardano.Wallet.Network

mapChainSyncLog :: (b1 -> b2) -> (p1 -> p2) -> ChainSyncLog b1 p1 -> ChainSyncLog b2 p2 Source #

withFollowStatsMonitoring :: Tracer IO ChainFollowLog -> ( SlotNo -> IO SyncProgress ) -> ( Tracer IO ( ChainSyncLog BlockHeader ChainPoint ) -> IO ()) -> IO () Source #

Monitors health and statistics by inspecting the messages submitted to a ChainSyncLog tracer.

Statistics are computed in regular time intervals. In order to do that, the monitor runs in separate thread. The results are submitted to the outer ChainFollowLog tracer.

Logging (for testing)

data FollowStats f Source #

Statistics of interest from the follow-function.

The f allows us to use Rearview to keep track of both current and previously logged stats, and perform operations over it in a nice way.

Constructors

FollowStats

Fields

Instances

Instances details
Eq ( FollowStats Rearview ) Source #
Instance details

Defined in Cardano.Wallet.Network

Show ( FollowStats Rearview ) Source #
Instance details

Defined in Cardano.Wallet.Network

Generic ( FollowStats f) Source #
Instance details

Defined in Cardano.Wallet.Network

Associated Types

type Rep ( FollowStats f) :: Type -> Type Source #

NoThunks ( FollowStats Rearview ) Source #
Instance details

Defined in Cardano.Wallet.Network

ToText ( FollowStats Rearview ) Source #
Instance details

Defined in Cardano.Wallet.Network

HasSeverityAnnotation ( FollowStats Rearview ) Source #
Instance details

Defined in Cardano.Wallet.Network

type Rep ( FollowStats f) Source #
Instance details

Defined in Cardano.Wallet.Network

data Rearview a Source #

A Rearview consists of a past value and a present value. Useful for keeping track of past logs.

The idea is to 1. Reconstruct a model of the current state using a Trace 2. Sometimes log the difference between the current state and the most recently logged one.

Constructors

Rearview

Fields

  • past :: !a

    Most previously logged state

  • current :: !a

    Not-yet logged state

Instances

Instances details
Functor Rearview Source #
Instance details

Defined in Cardano.Wallet.Network

Eq a => Eq ( Rearview a) Source #
Instance details

Defined in Cardano.Wallet.Network

Eq ( FollowStats Rearview ) Source #
Instance details

Defined in Cardano.Wallet.Network

Show a => Show ( Rearview a) Source #
Instance details

Defined in Cardano.Wallet.Network

Show ( FollowStats Rearview ) Source #
Instance details

Defined in Cardano.Wallet.Network

Generic ( Rearview a) Source #
Instance details

Defined in Cardano.Wallet.Network

Associated Types

type Rep ( Rearview a) :: Type -> Type Source #

NoThunks a => NoThunks ( Rearview a) Source #
Instance details

Defined in Cardano.Wallet.Network

NoThunks ( FollowStats Rearview ) Source #
Instance details

Defined in Cardano.Wallet.Network

ToText ( FollowStats Rearview ) Source #
Instance details

Defined in Cardano.Wallet.Network

HasSeverityAnnotation ( FollowStats Rearview ) Source #
Instance details

Defined in Cardano.Wallet.Network

type Rep ( Rearview a) Source #
Instance details

Defined in Cardano.Wallet.Network

type Rep ( Rearview a) = D1 (' MetaData "Rearview" "Cardano.Wallet.Network" "cardano-wallet-core-2022.7.1-AGKhlyz9liLKN3QqZD1gj" ' False ) ( C1 (' MetaCons "Rearview" ' PrefixI ' True ) ( S1 (' MetaSel (' Just "past") ' NoSourceUnpackedness ' SourceStrict ' DecidedStrict ) ( Rec0 a) :*: S1 (' MetaSel (' Just "current") ' NoSourceUnpackedness ' SourceStrict ' DecidedStrict ) ( Rec0 a)))

updateStats :: ChainSyncLog block ChainPoint -> FollowStats Rearview -> FollowStats Rearview Source #

Update the current statistics based on a new log message.