iotex-core: github.com/iotexproject/iotex-core/dispatcher Index | Files

package dispatcher

import "github.com/iotexproject/iotex-core/dispatcher"

Index

Package Files

dispatcher.go

type Dispatcher Uses

type Dispatcher interface {
    lifecycle.StartStopper

    // AddSubscriber adds to dispatcher
    AddSubscriber(uint32, Subscriber)
    // HandleBroadcast handles the incoming broadcast message. The transportation layer semantics is at least once.
    // That said, the handler is likely to receive duplicate messages.
    HandleBroadcast(context.Context, uint32, proto.Message)
    // HandleTell handles the incoming tell message. The transportation layer semantics is exact once. The sender is
    // given for the sake of replying the message
    HandleTell(context.Context, uint32, peerstore.PeerInfo, proto.Message)
}

Dispatcher is used by peers, handles incoming block and header notifications and relays announcements of new blocks.

func NewDispatcher Uses

func NewDispatcher(cfg config.Config) (Dispatcher, error)

NewDispatcher creates a new Dispatcher

type IotxDispatcher Uses

type IotxDispatcher struct {
    // contains filtered or unexported fields
}

IotxDispatcher is the request and event dispatcher for iotx node.

func (*IotxDispatcher) AddSubscriber Uses

func (d *IotxDispatcher) AddSubscriber(
    chainID uint32,
    subscriber Subscriber,
)

AddSubscriber adds a subscriber to dispatcher

func (*IotxDispatcher) EventAudit Uses

func (d *IotxDispatcher) EventAudit() map[iotexrpc.MessageType]int

EventAudit returns the event audit map

func (*IotxDispatcher) EventChan Uses

func (d *IotxDispatcher) EventChan() *chan interface{}

EventChan returns the event chan

func (*IotxDispatcher) HandleBroadcast Uses

func (d *IotxDispatcher) HandleBroadcast(ctx context.Context, chainID uint32, message proto.Message)

HandleBroadcast handles incoming broadcast message

func (*IotxDispatcher) HandleTell Uses

func (d *IotxDispatcher) HandleTell(ctx context.Context, chainID uint32, peer peerstore.PeerInfo, message proto.Message)

HandleTell handles incoming unicast message

func (*IotxDispatcher) Start Uses

func (d *IotxDispatcher) Start(ctx context.Context) error

Start starts the dispatcher.

func (*IotxDispatcher) Stop Uses

func (d *IotxDispatcher) Stop(ctx context.Context) error

Stop gracefully shuts down the dispatcher by stopping all handlers and waiting for them to finish.

type Subscriber Uses

type Subscriber interface {
    HandleAction(context.Context, *iotextypes.Action) error
    HandleBlock(context.Context, *iotextypes.Block) error
    HandleBlockSync(context.Context, *iotextypes.Block) error
    HandleSyncRequest(context.Context, peerstore.PeerInfo, *iotexrpc.BlockSync) error
    HandleConsensusMsg(*iotextypes.ConsensusMessage) error
}

Subscriber is the dispatcher subscriber interface

Package dispatcher imports 15 packages (graph) and is imported by 3 packages. Updated 2019-12-02. Refresh now. Tools for package owners.