p2p

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2020 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultPort = 6091
View Source
var P2PPrivateKeyKey = "p2pPrivKey"

Functions

This section is empty.

Types

type AccountsP2P

type AccountsP2P struct {
	Accounts map[string]blockchain.Account
}

AccountsP2P represents all the accounts from a peer

func (AccountsP2P) Marshal

func (a AccountsP2P) Marshal() []byte

Marshal serializes AccountsP2P

type MappingsP2P

type MappingsP2P struct {
	Mappings map[string]blockchain.DocumentMapping
}

MappingsP2P represents all the collection mappings (schemas) from a peer

func (MappingsP2P) Marshal

func (a MappingsP2P) Marshal() []byte

Marshal serializes MappingsP2P

type P2P

type P2P struct {
	Node *noise.Node
	// contains filtered or unexported fields
}

P2P is the main object to handle networking-related messages

func NewP2P

func NewP2P(bc *blockchain.Blockchain, bindHost string, bindPort uint16, advertiseAddress string, connectionAddresses ...string) *P2P

NewP2P initializes the P2P node with messages and handlers

func (*P2P) BroadcastObject

func (p *P2P) BroadcastObject(object noise.Serializable)

BroadcastObject sends a serializable object to all the known peers

func (*P2P) SyncAccountsFromPeers

func (p *P2P) SyncAccountsFromPeers()

SyncAccountsFromPeers sends rpc to peers to sync the accounts

func (*P2P) SyncMappingsFromPeers

func (p *P2P) SyncMappingsFromPeers()

SyncMappingsFromPeers sends rpc to peers to sync the mappings

type RequestP2P

type RequestP2P struct {
	RequestType       string
	RequestParameters map[string]string
}

RequestP2P represents common p2p request body

func (RequestP2P) Marshal

func (a RequestP2P) Marshal() []byte

Marshal serializes RequestP2P

Jump to

Keyboard shortcuts

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