network

package
v0.0.0-...-8f01991 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ProtocolID            = "/confirmix/1.0.0"
	BlockchainSync        = "/blockchain/sync"
	BlockAnnouncement     = "/block/announcement"
	ValidatorAnnouncement = "/validator/announcement"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Message

type Message struct {
	Type    string      `json:"type"`
	Payload interface{} `json:"payload"`
}

Message represents a network message

type Node

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

Node represents a P2P network node

func NewNode

func NewNode(listenPort int, bc *blockchain.Blockchain) (*Node, error)

NewNode creates a new P2P node

func (*Node) Broadcast

func (n *Node) Broadcast(ctx context.Context, msgType string, payload interface{}) error

Broadcast broadcasts a message to all peers

func (*Node) Close

func (n *Node) Close() error

Close closes the node

func (*Node) Connect

func (n *Node) Connect(ctx context.Context, peerAddr string) error

Connect connects to a peer

func (*Node) GetMultiaddr

func (n *Node) GetMultiaddr() string

GetMultiaddr returns the node's multiaddress

Jump to

Keyboard shortcuts

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