node

package
v0.0.0-...-2c02b6f Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2022 License: LGPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultHTTPort = 8080
View Source
const DefaultIP = "127.0.0.1"
View Source
const DefaultMiner = ""

Variables

This section is empty.

Functions

func Mine

Types

type AddPeerRes

type AddPeerRes struct {
	Success bool   `json:"success"`
	Error   string `json:"error"`
}

type BalancesRes

type BalancesRes struct {
	Hash     database.Hash             `json:"block_hash"`
	Balances map[database.Account]uint `json:"balances"`
}

type ErrRes

type ErrRes struct {
	Error string `json:"error"`
}

type Node

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

func New

func New(dataDir string, ip string, port uint64, acc database.Account, bootstrap PeerNode) *Node

func (*Node) AddPeer

func (n *Node) AddPeer(peer PeerNode)

func (*Node) AddPendingTX

func (n *Node) AddPendingTX(tx database.Tx, fromPeer PeerNode) error

func (*Node) IsKnownPeer

func (n *Node) IsKnownPeer(peer PeerNode) bool

func (*Node) LatestBlockHash

func (n *Node) LatestBlockHash() database.Hash

func (*Node) RemovePeer

func (n *Node) RemovePeer(peer PeerNode)

func (*Node) Run

func (n *Node) Run(ctx context.Context) error

type PeerNode

type PeerNode struct {
	IP          string           `json:"ip"`
	Port        uint64           `json:"port"`
	IsBootstrap bool             `json:"is_bootstrap"`
	Account     database.Account `json:"account"`
	// contains filtered or unexported fields
}

func NewPeerNode

func NewPeerNode(ip string, port uint64, isBootstrap bool, acc database.Account, connected bool) PeerNode

func (PeerNode) TcpAddress

func (pn PeerNode) TcpAddress() string

type PendingBlock

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

func NewPendingBlock

func NewPendingBlock(parent database.Hash, number uint64, miner database.Account, txs []database.Tx) PendingBlock

type StatusRes

type StatusRes struct {
	Hash       database.Hash       `json:"block_hash"`
	Number     uint64              `json:"block_number"`
	KnownPeers map[string]PeerNode `json:"peers_known"`
	PendingTXs []database.Tx       `json:"pending_txs"`
}

type SyncRes

type SyncRes struct {
	Blocks []database.Block `json:"blocks"`
}

type TxAddReq

type TxAddReq struct {
	From  string `json:"from"`
	To    string `json:"to"`
	Value uint   `json:"value"`
	Data  string `json:"data"`
}

type TxAddRes

type TxAddRes struct {
	Success bool `json:"success"`
}

Jump to

Keyboard shortcuts

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