p2p

package
v1.0.9 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2022 License: Unlicense Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GetBlocksRequest       = "GET BLOCKS REQUEST"
	GetTransactionsRequest = "GET TRANSACTIONS REQUEST"
	MineRequest            = "MINE REQUEST"
	StartMiningRequest     = "START MINING REQUEST"
	StopMiningRequest      = "STOP MINING REQUEST"
)
View Source
const (
	DefaultPort = 8106
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	Send(topic string, req gp2p.Data) (res gp2p.Data, err error)
}

type ClientFactory

type ClientFactory interface {
	CreateClient(ip string, port uint16, target string) (Client, error)
}

type Host

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

func NewHost

func NewHost(
	server Server,
	synchronizer network.Synchronizer,
	blockchain protocol.Blockchain,
	pool protocol.TransactionsPool,
	synchronizationEngine clock.Engine,
	validationEngine clock.Engine,
	verificationEngine clock.Engine,
	watch clock.Watch,
	logger log.Logger,
) *Host

func (*Host) Run

func (host *Host) Run() error

type Neighbor

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

func NewNeighbor

func NewNeighbor(target *Target, clientFactory ClientFactory) (*Neighbor, error)

func (*Neighbor) AddTransaction

func (neighbor *Neighbor) AddTransaction(request network.TransactionRequest) (err error)

func (*Neighbor) GetAmount

func (neighbor *Neighbor) GetAmount(request network.AmountRequest) (amountResponse *network.AmountResponse, err error)

func (*Neighbor) GetBlocks

func (neighbor *Neighbor) GetBlocks() (blockResponses []*network.BlockResponse, err error)

func (*Neighbor) GetTransactions

func (neighbor *Neighbor) GetTransactions() (transactionResponses []network.TransactionResponse, err error)

func (*Neighbor) Ip

func (neighbor *Neighbor) Ip() string

func (*Neighbor) Mine

func (neighbor *Neighbor) Mine() (err error)

func (*Neighbor) Port

func (neighbor *Neighbor) Port() uint16

func (*Neighbor) SendTargets

func (neighbor *Neighbor) SendTargets(request []network.TargetRequest) (err error)

func (*Neighbor) StartMining

func (neighbor *Neighbor) StartMining() (err error)

func (*Neighbor) StopMining

func (neighbor *Neighbor) StopMining() (err error)

func (*Neighbor) Target

func (neighbor *Neighbor) Target() string

type Server

type Server interface {
	SetHandle(topic string, handler gp2p.Handler)
	Serve() (err error)
}

type Synchronizer

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

func NewSynchronizer

func NewSynchronizer(hostPort uint16, watch clock.Watch, clientFactory ClientFactory, configurationPath string, logger log.Logger) (synchronizer *Synchronizer, err error)

func (*Synchronizer) AddTargets

func (synchronizer *Synchronizer) AddTargets(targetRequests []network.TargetRequest)

func (*Synchronizer) Neighbors

func (synchronizer *Synchronizer) Neighbors() []network.Neighbor

func (*Synchronizer) Synchronize

func (synchronizer *Synchronizer) Synchronize(int64)

type Target

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

func NewTarget

func NewTarget(ip string, port uint16) *Target

func (*Target) Ip

func (target *Target) Ip() string

func (*Target) Port

func (target *Target) Port() uint16

func (*Target) Value

func (target *Target) Value() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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