gateway

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2015 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxCatchUpBlocks = 50
)

Variables

View Source
var (
	ErrTimeout = errors.New("timeout")
)

Functions

This section is empty.

Types

type Gateway

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

Gateway implements the modules.Gateway interface.

func New

func New(addr string, s *consensus.State, saveDir string) (g *Gateway, err error)

New returns an initialized Gateway.

func (*Gateway) AddPeer

func (g *Gateway) AddPeer(peer modules.NetAddress) error

AddPeer adds a peer to the Gateway's peer list.

func (*Gateway) Address

func (g *Gateway) Address() modules.NetAddress

Address returns the NetAddress of the Gateway.

func (*Gateway) Bootstrap

func (g *Gateway) Bootstrap(bootstrapPeer modules.NetAddress) (err error)

Bootstrap joins the Sia network and establishes an initial peer list.

Bootstrap handles mutexes manually to avoid having a lock during network communication.

func (*Gateway) Close

func (g *Gateway) Close() error

Close stops the Gateway's listener process.

func (*Gateway) Info

func (g *Gateway) Info() (info modules.GatewayInfo)

Info returns metadata about the Gateway.

func (*Gateway) Ping

func (g *Gateway) Ping(addr modules.NetAddress) bool

Ping returns whether an Address is reachable and responds correctly to the ping request -- in other words, whether it is a potential peer.

func (*Gateway) RPC

func (g *Gateway) RPC(addr modules.NetAddress, name string, fn modules.RPCFunc) (err error)

RPC establishes a TCP connection to the NetAddress, writes the RPC identifier, and then hands off the connection to fn. When fn returns, the connection is closed.

func (*Gateway) RandomPeer

func (g *Gateway) RandomPeer() (modules.NetAddress, error)

RandomPeer returns a random peer from the Gateway's peer list.

func (*Gateway) RegisterRPC

func (g *Gateway) RegisterRPC(name string, fn modules.RPCFunc)

RegisterRPC registers a function as an RPC handler for a given identifier. To call an RPC, use gateway.RPC, supplying the same identifier given to RegisterRPC. Identifiers should always use PascalCase.

func (*Gateway) RelayBlock

func (g *Gateway) RelayBlock(b consensus.Block)

RelayBlock relays a block to the network.

func (*Gateway) RelayTransaction

func (g *Gateway) RelayTransaction(t consensus.Transaction)

RelayTransaction relays a transaction to the network.

func (*Gateway) RemovePeer

func (g *Gateway) RemovePeer(peer modules.NetAddress) error

RemovePeer removes a peer from the Gateway's peer list.

func (*Gateway) Synchronize

func (g *Gateway) Synchronize(peer modules.NetAddress) error

Synchronize synchronizes the local consensus set (i.e. the blockchain) with the network consensus set. The process is as follows: synchronize asks a peer for new blocks. The requester sends 32 block IDs, starting with the 12 most recent and then progressing exponentially backwards to the genesis block. The receiver uses these blocks to find the most recent block seen by both peers. From this starting height, it transmits blocks sequentially. The requester then integrates these blocks into its consensus set. Multiple such transmissions may be required to fully synchronize.

TODO: don't run two Synchronize threads at the same time

Jump to

Keyboard shortcuts

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