eth

package module
v0.5.22 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2014 License: MIT Imports: 22 Imported by: 0

README

Ethereum

Build Status

Ethereum Go Development package (C) Jeffrey Wilcke

Ethereum is currently in its testing phase. The current state is "Proof of Concept 0.5.20". For build instructions see the Wiki.

Ethereum Go is split up in several sub packages Please refer to each individual package for more information.

  1. eth
  2. ethchain
  3. ethwire
  4. ethdb
  5. ethutil

The eth is the top-level package of the Ethereum protocol. It functions as the Ethereum bootstrapping and peer communication layer. The ethchain contains the Ethereum blockchain, block manager, transaction and transaction handlers. The ethwire contains the Ethereum wire protocol which can be used to hook in to the Ethereum network. ethutil contains utility functions which are not Ethereum specific. The utility package contains the patricia trie, RLP Encoding and hex encoding helpers. The ethdb package contains the LevelDB interface and memory DB interface.

This is the bootstrap package. Eth-go contains all the necessary code to get a node and connectivity going.

Build

This is the Developer package. For the Ethereal client please see Ethereum(G).

go get -u github.com/ethereum/eth-go

Contribution

If you'd like to contribute to Eth please fork, fix, commit and send a pull request. Commits who do not comply with the coding standards are ignored. If you send pull requests make absolute sure that you commit on the develop branch and that you do not merge to master. Commits that are directly based on master are simply ignored.

To make life easier try git flow it sets this all up and streamlines your work flow.

Coding standards

Sources should be formatted according to the Go Formatting Style.

Unless structs fields are supposed to be directly accesible, provide Getters and hide the fields through Go's exporting facility.

When you comment put meaningfull comments. Describe in detail what you want to achieve.

wrong

// Check if the value at x is greater than y
if x > y {
    // It's greater!
}

Everyone reading the source probably know what you wanted to achieve with above code. Those are not meaningful comments.

While the project isn't 100% tested I want you to write tests non the less. I haven't got time to evaluate everyone's code in detail so I expect you to write tests for me so I don't have to test your code manually. (If you want to contribute by just writing tests that's fine too!)

Documentation

Index

Constants

View Source
const (
	// Values are given explicitly instead of by iota because these values are
	// defined by the wire protocol spec; it is easier for humans to ensure
	// correctness when values are explicit.
	DiscReRequested  = 0x00
	DiscReTcpSysErr  = 0x01
	DiscBadProto     = 0x02
	DiscBadPeer      = 0x03
	DiscTooManyPeers = 0x04
	DiscConnDup      = 0x05
	DiscGenesisErr   = 0x06
	DiscProtoErr     = 0x07
	DiscQuitting     = 0x08
)
View Source
const (
	CapPeerDiscTy = 1 << iota
	CapTxTy
	CapChainTy

	CapDefault = CapChainTy | CapTxTy | CapPeerDiscTy
)
View Source
const (

	// Current protocol version
	ProtocolVersion = 23
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Caps

type Caps byte

Peer capabilities

func (Caps) IsCap

func (c Caps) IsCap(cap Caps) bool

func (Caps) String

func (c Caps) String() string

type DiscReason

type DiscReason byte

func (DiscReason) String

func (d DiscReason) String() string

type Ethereum

type Ethereum struct {

	// Nonce
	Nonce uint64

	Addr net.Addr
	Port string

	// Specifies the desired amount of maximum peers
	MaxPeers int

	Mining bool

	RpcServer *ethrpc.JsonRpcServer
	// contains filtered or unexported fields
}

func New

func New(db ethutil.Database, clientIdentity ethwire.ClientIdentity, keyManager *ethcrypto.KeyManager, caps Caps, usePnp bool) (*Ethereum, error)

func (*Ethereum) AddPeer

func (s *Ethereum) AddPeer(conn net.Conn)

func (*Ethereum) BlockChain

func (s *Ethereum) BlockChain() *ethchain.BlockChain

func (*Ethereum) Broadcast

func (s *Ethereum) Broadcast(msgType ethwire.MsgType, data []interface{})

func (*Ethereum) BroadcastMsg

func (s *Ethereum) BroadcastMsg(msg *ethwire.Msg)

func (*Ethereum) ClientIdentity

func (s *Ethereum) ClientIdentity() ethwire.ClientIdentity

func (*Ethereum) ConnectToPeer

func (s *Ethereum) ConnectToPeer(addr string) error

func (*Ethereum) InOutPeers

func (s *Ethereum) InOutPeers() []*Peer

func (*Ethereum) InboundPeers

func (s *Ethereum) InboundPeers() []*Peer

func (*Ethereum) IsListening

func (s *Ethereum) IsListening() bool

func (*Ethereum) IsMining

func (s *Ethereum) IsMining() bool

func (*Ethereum) IsUpToDate

func (s *Ethereum) IsUpToDate() bool

func (*Ethereum) KeyManager

func (s *Ethereum) KeyManager() *ethcrypto.KeyManager

func (*Ethereum) OutboundPeers

func (s *Ethereum) OutboundPeers() []*Peer

func (*Ethereum) PeerCount

func (s *Ethereum) PeerCount() int

func (*Ethereum) Peers

func (s *Ethereum) Peers() *list.List

func (*Ethereum) ProcessPeerList

func (s *Ethereum) ProcessPeerList(addrs []string)

func (*Ethereum) PushPeer

func (s *Ethereum) PushPeer(peer *Peer)

func (*Ethereum) Reactor

func (s *Ethereum) Reactor() *ethutil.ReactorEngine

func (*Ethereum) ReapDeadPeerHandler

func (s *Ethereum) ReapDeadPeerHandler()

func (*Ethereum) RemovePeer

func (s *Ethereum) RemovePeer(p *Peer)

func (*Ethereum) Seed

func (s *Ethereum) Seed()

func (*Ethereum) ServerCaps

func (s *Ethereum) ServerCaps() Caps

func (*Ethereum) Start

func (s *Ethereum) Start(seed bool)

Start the ethereum

func (*Ethereum) StateManager

func (s *Ethereum) StateManager() *ethchain.StateManager

func (*Ethereum) Stop

func (s *Ethereum) Stop()

func (*Ethereum) TxPool

func (s *Ethereum) TxPool() *ethchain.TxPool

func (*Ethereum) WaitForShutdown

func (s *Ethereum) WaitForShutdown()

This function will wait for a shutdown and resumes main thread execution

type NAT

type NAT interface {
	GetExternalAddress() (addr net.IP, err error)
	AddPortMapping(protocol string, externalPort, internalPort int, description string, timeout int) (mappedExternalPort int, err error)
	DeletePortMapping(protocol string, externalPort, internalPort int) (err error)
}

protocol is either "udp" or "tcp"

func Discover

func Discover() (nat NAT, err error)

func NewNatPMP

func NewNatPMP(gateway net.IP) (nat NAT)

type Peer

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

func NewOutboundPeer

func NewOutboundPeer(addr string, ethereum *Ethereum, caps Caps) *Peer

func NewPeer

func NewPeer(conn net.Conn, ethereum *Ethereum, inbound bool) *Peer

func (*Peer) CatchupWithPeer

func (p *Peer) CatchupWithPeer(blockHash []byte)

func (*Peer) Connected

func (p *Peer) Connected() *int32

func (*Peer) FindCommonParentBlock

func (p *Peer) FindCommonParentBlock()

func (*Peer) HandleInbound

func (p *Peer) HandleInbound()

Inbound handler. Inbound messages are received here and passed to the appropriate methods

func (*Peer) HandleOutbound

func (p *Peer) HandleOutbound()

Outbound message handler. Outbound messages are handled here

func (*Peer) Host

func (p *Peer) Host() []byte

func (*Peer) Inbound

func (p *Peer) Inbound() bool

func (*Peer) LastPong

func (p *Peer) LastPong() int64

func (*Peer) LastSend

func (p *Peer) LastSend() time.Time

func (*Peer) PingTime

func (p *Peer) PingTime() string

Getters

func (*Peer) Port

func (p *Peer) Port() uint16

func (*Peer) QueueMessage

func (p *Peer) QueueMessage(msg *ethwire.Msg)

Outputs any RLP encoded data to the peer

func (*Peer) RlpData

func (p *Peer) RlpData() []interface{}

func (*Peer) SetVersion

func (p *Peer) SetVersion(version string)

Setters

func (*Peer) Start

func (p *Peer) Start()

func (*Peer) Stop

func (p *Peer) Stop()

func (*Peer) String

func (p *Peer) String() string

func (*Peer) SyncWithPeerToLastKnown

func (p *Peer) SyncWithPeerToLastKnown()

func (*Peer) Version

func (p *Peer) Version() string

Directories

Path Synopsis
Package ethwire provides low level access to the Ethereum network and allows you to broadcast data over the network.
Package ethwire provides low level access to the Ethereum network and allows you to broadcast data over the network.

Jump to

Keyboard shortcuts

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