network

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2018 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewAddBlock

func NewAddBlock(blockData []byte) *message.Msg

NewAddBlock creates a new Block message

func NewAddTXMessage

func NewAddTXMessage(txData []byte) *message.Msg

NewAddTXMessage creates a new TX message

Types

type Node

type Node struct {
	PeerManager *PeerManager
	MemPool     *mempool.MemPool
	Storage     blockchain.Storage
	Signer      transaction.Signer
	Validator   consensus.Validator
	Wallet      *wallet.Wallet
}

Node represents a single node that can send/relay/validate messages. It has access to the wallet for GetBalance command.

func (*Node) GetBalance

func (n *Node) GetBalance(ctx context.Context, in *cli.GetBalanceRequest) (*cli.GetBalanceResponse, error)

GetBalance returns sum of all UTXO of all addresses in the wallet

func (*Node) Message

func (n *Node) Message(msgStream message.MessageService_MessageServer) error

Message starts listening a given server stream

func (*Node) Send

func (n *Node) Send(ctx context.Context, r *cli.SendRequest) (*cli.SendResponse, error)

Send sends a TX message to the network

func (*Node) ServeClient

func (n *Node) ServeClient(stream message.MessageService_MessageClient)

ServeClient starts listening a given client stream

type PeerManager

type PeerManager struct {
	sync.Mutex
	// contains filtered or unexported fields
}

PeerManager represents a manager that knows all about the node connections

func NewPeerManager

func NewPeerManager() *PeerManager

NewPeerManager return a new peer manager

func (*PeerManager) AddClient

AddClient adds a client stream

func (*PeerManager) AddServer

AddServer adds a server stream

func (*PeerManager) RemoveClient

func (m *PeerManager) RemoveClient(addr string)

RemoveClient removes a client stream

func (*PeerManager) RemoveServer

func (m *PeerManager) RemoveServer(addr string)

RemoveServer removes a server stream

func (*PeerManager) Send

func (m *PeerManager) Send(ctx context.Context, msg *message.Msg)

Send sends a given message to all known peers except a peer that sent this message to the node.

Directories

Path Synopsis
Package cli is a generated protocol buffer package.
Package cli is a generated protocol buffer package.
Package message is a generated protocol buffer package.
Package message is a generated protocol buffer package.

Jump to

Keyboard shortcuts

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