p2p

package
v0.0.0-...-3df7063 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2022 License: LGPL-2.1 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GobEncode

func GobEncode(data interface{}) []byte

func InitMDNS

func InitMDNS(peerhost host.Host, rendezvous string) chan peer.AddrInfo

Initialize the MDNS service

Types

type InventoryProtocol

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

func NewInvenotryProtocol

func NewInvenotryProtocol(node *Node, done chan bool) *InventoryProtocol

func (*InventoryProtocol) SendBlock

func (p *InventoryProtocol) SendBlock(hostId peer.ID, block *blockchain.Block) bool

func (*InventoryProtocol) SendTransaction

func (p *InventoryProtocol) SendTransaction(hostId peer.ID, tx *blockchain.Transaction) bool

type Node

type Node struct {
	host.Host
	*PingProtocol
	*InventoryProtocol
	*blockchain.BlockChain
	MineAddress            string
	BlocksInTransit        [][]byte
	TransactionsMemoryPool map[string]blockchain.Transaction
}

func NewNode

func NewNode(host host.Host, done chan bool) *Node

Create a new node with its implemented protocols

func (*Node) AddTransaction

func (n *Node) AddTransaction(tx *blockchain.Transaction)

add transaction to memory pool

func (*Node) MineTxs

func (n *Node) MineTxs()

mine transactions of memory pool

func (*Node) NewMessageData

func (n *Node) NewMessageData(messageId string, gossip bool) *pb.MessageData

helper method - generate message data shared between all node's pb protocols

type PingProtocol

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

PingProtocol type

func NewPingProtocol

func NewPingProtocol(node *Node, done chan bool) *PingProtocol

func (*PingProtocol) Ping

func (p *PingProtocol) Ping(hostId peer.ID) bool

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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