p2p

package
v0.0.0-...-5fb01ef Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2018 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BlockProto         protocol.ID = protocolsPrefix + "block/1.0.0"
	TransactionProto               = protocolsPrefix + "transaction/1.0.0"
	BlockAnnounceProto             = protocolsPrefix + "blockAnnounce/1.0.0"
	DiscoverProto                  = protocolsPrefix + "discover/1.0.0"
	VoteAnnounceProto              = protocolsPrefix + "vote/1.0.0"
)
View Source
const DefaultPort = 9765
View Source
const HostsInfoPath = "/tmp/akhhosts.info"

Variables

This section is empty.

Functions

This section is empty.

Types

type AkhHost

type AkhHost struct {
	bhost.BasicHost
}

func StartHost

func StartHost(port int, privateKey []byte, withDiscovery bool) AkhHost

func (*AkhHost) AddPeerManually

func (h *AkhHost) AddPeerManually(remotePeerAddr string, remotePeerID string) (err error)

remotePeerAddr format: <dot-separated IPv4>:<post>, for example: 127.0.0.1:9000 remotePeerID - unprettyfied ID TODO validation and error handling

func (*AkhHost) AddStreamHandler

func (h *AkhHost) AddStreamHandler(handler StreamHandler)

func (*AkhHost) DiscoverPeers

func (h *AkhHost) DiscoverPeers()

func (*AkhHost) GetBlock

func (h *AkhHost) GetBlock(peerID peer.ID, blockHash string) (bd blockchain.BlockData, err error)

func (*AkhHost) PublishBlock

func (h *AkhHost) PublishBlock(b *blockchain.Block)

func (*AkhHost) PublishTransaction

func (h *AkhHost) PublishTransaction(t *blockchain.Transaction)

func (*AkhHost) PublishVote

func (h *AkhHost) PublishVote(v *blockchain.Vote)

func (*AkhHost) SendMessage

func (h *AkhHost) SendMessage(msg interface{}, peerID peer.ID, proto protocol.ID) (ws *WrappedStream, err error)

type AnnouncedBlockStreamHandler

type AnnouncedBlockStreamHandler struct {
	ProcessResult func(bd blockchain.BlockData, peerId peer.ID)
}

type BlockStreamHandler

type BlockStreamHandler struct {
	Head **blockchain.Block
}

type DiscoverStreamHandler

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

type DiscoveryNotifee

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

func (*DiscoveryNotifee) HandlePeerFound

func (n *DiscoveryNotifee) HandlePeerFound(peerInfo ps.PeerInfo)

type GetBlockMessage

type GetBlockMessage struct {
	Message
	BlockHash string
}

type GetPeersMessage

type GetPeersMessage struct {
	Message
}

type Message

type Message interface {
	fmt.Stringer
	MsgText() string
}

type StreamHandler

type StreamHandler interface {
	// contains filtered or unexported methods
}

type TestedPeer

type TestedPeer struct {
	ps.PeerInfo
	// contains filtered or unexported fields
}

type TransactionStreamHandler

type TransactionStreamHandler struct {
	ProcessResult func(t blockchain.Transaction)
}

type VoteStreamHandler

type VoteStreamHandler struct {
	ProcessResult func(v blockchain.Vote)
}

type WrappedStream

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

func WrapStream

func WrapStream(s inet.Stream) *WrappedStream

Jump to

Keyboard shortcuts

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