service

package
v0.0.0-...-aa76b34 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 3, 2024 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewGatewayClient

func NewGatewayClient(endpoint string, logger *zap.SugaredLogger) *gatewayClient

func NewNetworkManager

func NewNetworkManager(listenAddress string, logger *zap.SugaredLogger) *networkManager

func NewPeersMap

func NewPeersMap() *peersMap

Types

type Api

type Api interface {
	Chain() *chain.Chain
	Gate() *gatewayClient
}

type ConsulService

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

func NewConsulService

func NewConsulService(logger *zap.SugaredLogger, consulListenAddr string) *ConsulService

func (*ConsulService) Start

func (cs *ConsulService) Start() error

func (*ConsulService) String

func (cs *ConsulService) String() string

type KafkaMessageProducer

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

func (*KafkaMessageProducer) ProduceMessage

func (p *KafkaMessageProducer) ProduceMessage(msg any) error

message should a type from message package in common module

type Mempool

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

func NewMempool

func NewMempool() *Mempool

func (*Mempool) Add

func (m *Mempool) Add(tx *proto.Transaction)

func (*Mempool) Clear

func (m *Mempool) Clear()

func (*Mempool) Contains

func (m *Mempool) Contains(tx *proto.Transaction) bool

func (*Mempool) List

func (m *Mempool) List() []*proto.Transaction

func (*Mempool) Remove

func (m *Mempool) Remove(tx *proto.Transaction)

type MessageProducer

type MessageProducer interface {
	ProduceMessage(request any) error
}

func NewKafkaMessageProducer

func NewKafkaMessageProducer() (MessageProducer, error)

type Node

type Node struct {
	ServerConfig

	PrivateKey *crypto.PrivateKey
	// contains filtered or unexported fields
}

func New

func New(conf ServerConfig) *Node

func (*Node) Address

func (n *Node) Address() string

func (*Node) Chain

func (n *Node) Chain() *chain.Chain

func (*Node) Gate

func (n *Node) Gate() *gatewayClient

func (*Node) GetBlocks

func (n *Node) GetBlocks(ctx context.Context, v *proto.Version) (*proto.Blocks, error)

func (*Node) Handshake

func (n *Node) Handshake(
	ctx context.Context,
	v *proto.Version,
) (*proto.Version, error)

func (*Node) Mempool

func (r *Node) Mempool() *Mempool

func (*Node) NewBlock

func (n *Node) NewBlock(ctx context.Context, b *proto.Block) (*proto.Block, error)

func (*Node) NewTransaction

func (n *Node) NewTransaction(
	ctx context.Context,
	t *proto.Transaction,
) (*proto.Transaction, error)

func (*Node) Start

func (n *Node) Start(opts NodeOpts) error

func (*Node) Stop

func (n *Node) Stop() error

func (*Node) String

func (n *Node) String() string

type NodeOpts

type NodeOpts struct {
	BootstrapNodes []string
	IsMiner        bool
}

type Noder

type Noder interface {
	Handshake(ctx context.Context, v *proto.Version) (*proto.Version, error)
	NewTransaction(ctx context.Context, t *proto.Transaction) (*proto.Transaction, error)
	NewBlock(ctx context.Context, b *proto.Block) (*proto.Block, error)
	GetBlocks(ctx context.Context, v *proto.Version) (*proto.Blocks, error)
}

type ServerConfig

type ServerConfig struct {
	Version              string
	NodeListenAddress    string
	ApiListenAddr        string
	GatewayAddress       string
	ConsulServiceAddress string
	StoreType            string
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL