neighborhood

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2022 License: Unlicense Imports: 6 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"

	NeighborFindingTimeoutSecond = 5
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AmountRequest

type AmountRequest struct {
	Address *string
}

func (*AmountRequest) IsInvalid

func (amountRequest *AmountRequest) IsInvalid() bool

type AmountResponse

type AmountResponse struct {
	Amount uint64
}

type BlockResponse

type BlockResponse struct {
	Timestamp           int64
	PreviousHash        [32]byte
	Transactions        []*TransactionResponse
	RegisteredAddresses []string
}

type Neighbor

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

func NewNeighbor

func NewNeighbor(ip string, port uint16, logger *log.Logger) *Neighbor

func (*Neighbor) AddTransaction

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

func (*Neighbor) GetAmount

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

func (*Neighbor) GetBlocks

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

func (*Neighbor) GetTransactions

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

func (*Neighbor) Ip

func (neighbor *Neighbor) Ip() string

func (*Neighbor) IsFound

func (neighbor *Neighbor) IsFound() bool

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 []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 TargetRequest

type TargetRequest struct {
	Ip   *string
	Port *uint16
}

func (*TargetRequest) IsInvalid

func (targetRequest *TargetRequest) IsInvalid() bool

type TransactionRequest

type TransactionRequest struct {
	RecipientAddress *string
	SenderAddress    *string
	SenderPublicKey  *string
	Signature        *string
	Timestamp        *int64
	Value            *uint64
	Fee              *uint64
}

func (*TransactionRequest) IsInvalid

func (transactionRequest *TransactionRequest) IsInvalid() bool

type TransactionResponse

type TransactionResponse struct {
	RecipientAddress string
	SenderAddress    string
	SenderPublicKey  string
	Signature        string
	Timestamp        int64
	Value            uint64
	Fee              uint64
}

Jump to

Keyboard shortcuts

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