network

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: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	KnownNodes = []string{"localhost:3000"}
)

Functions

func BytesToCmd

func BytesToCmd(bytes []byte) string

func CloseDB

func CloseDB(chain *blockchain.BlockChain)

func CmdToBytes

func CmdToBytes(cmd string) []byte

func ExtractCmd

func ExtractCmd(request []byte) []byte

func GetIP

func GetIP() string

func GobEncode

func GobEncode(data interface{}) []byte

func Handle

func Handle(err error)

func HandleAddr

func HandleAddr(request []byte)

func HandleBlock

func HandleBlock(request []byte, chain *blockchain.BlockChain)

func HandleConnection

func HandleConnection(conn net.Conn, chain *blockchain.BlockChain)

func HandleGetBlocks

func HandleGetBlocks(request []byte, chain *blockchain.BlockChain)

func HandleGetData

func HandleGetData(request []byte, chain *blockchain.BlockChain)

func HandleInv

func HandleInv(request []byte, chain *blockchain.BlockChain)

func HandleTx

func HandleTx(request []byte, chain *blockchain.BlockChain)

func HandleVersion

func HandleVersion(request []byte, chain *blockchain.BlockChain)

func MineTx

func MineTx(chain *blockchain.BlockChain)

func NodeIsKnown

func NodeIsKnown(addr string) bool

func RequestBlocks

func RequestBlocks()

func SendAddr

func SendAddr(address string)

func SendBlock

func SendBlock(addr string, b *blockchain.Block)

func SendData

func SendData(addr string, data []byte)

func SendGetBlocks

func SendGetBlocks(address string)

func SendGetData

func SendGetData(address, kind string, id []byte)

func SendInv

func SendInv(address, kind string, items [][]byte)

func SendTx

func SendTx(addr string, tnx *blockchain.Transaction)

func SendVersion

func SendVersion(addr string, chain *blockchain.BlockChain)

func StartServer

func StartServer(nodeID, minerAddress string)

Types

type Addr

type Addr struct {
	AddrList []string
}

type Block

type Block struct {
	AddrFrom string
	Block    []byte
}

type GetBlocks

type GetBlocks struct {
	AddrFrom string
}

type GetData

type GetData struct {
	AddrFrom string
	Type     string
	ID       []byte
}

type Inv

type Inv struct {
	AddrFrom string
	Type     string
	Items    [][]byte
}

type Tx

type Tx struct {
	AddrFrom    string
	Transaction []byte
}

type Version

type Version struct {
	Version    int
	BestHeight int
	AddrFrom   string
}

Jump to

Keyboard shortcuts

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