p2p

package
v0.0.0-...-06056e5 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	WSURLformat = "ws://%s:%s/peers/upgrade?senderPort=%s"
)

Variables

View Source
var (
	Peers = &peers{
		v: make(map[string]*peer),
	}
)

Functions

func AddPeer

func AddPeer(ip, port string)

func BroadcastMinedBlock

func BroadcastMinedBlock(minedBlock *blockchain.Block)

func BroadcastNewTx

func BroadcastNewTx(newTx *blockchain.Tx)

func GetPeersList

func GetPeersList() []string

func PingForever

func PingForever()

func UpgradePeer

func UpgradePeer(rw http.ResponseWriter, r *http.Request)

Types

type Msg

type Msg struct {
	Kind    MsgKind
	Payload []byte
}

func (*Msg) KindToString

func (m *Msg) KindToString() string

func (Msg) String

func (m Msg) String() string

type MsgKind

type MsgKind int
const (
	MsgLastBlock MsgKind = iota
	MsgAllBlocksReq
	MsgAllBlocksResp
	MsgMinedBlock
	MsgNewTx
	MsgNewPeer
)

Jump to

Keyboard shortcuts

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