eth

package module
v0.7.11 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2014 License: LGPL-2.1-or-later Imports: 28 Imported by: 0

README

Bugs Stories in Ready ![Stories in Progress](https://badge.waffle.io/ethereum/go-ethereum.svg?label=in%20progress&title=In Progress)

Ethereum

Build Status master Build Status develop

Ethereum Go Client © 2014 Jeffrey Wilcke.

Current state: Proof of Concept 0.7

Ethereum is currently in its testing phase.

Build

To build Mist (GUI):

go get github.com/ethereum/go-ethereum/cmd/mist

To build the node (CLI):

go get github.com/ethereum/go-ethereum/cmd/ethereum

For further, detailed, build instruction please see the Wiki

Automated (dev) builds

  • [OS X]
  • [Windows] Coming soon™
  • [Linux] Coming soon™

Binaries

Go Ethereum comes with several binaries found in cmd:

  • mist Official Ethereum Browser
  • ethereum Ethereum CLI
  • ethtest test tool which runs with the tests suit: ethtest "cat myfile.json".
  • evm is a generic Ethereum Virtual Machine: evm -code 60ff60ff -gas 10000 -price 0 -dump. See -h for a detailed description.

General command line options

== Shared between ethereum and Mist ==

= Settings
-id      Set the custom identifier of the client (shows up on other clients)
-port    Port on which the server will accept incomming connections
-upnp    Enable UPnP
-maxpeer Desired amount of peers
-rpc     Start JSON RPC
-dir     Data directory used to store configs and databases

= Utility 
-h         This
-import    Import a private key
-genaddr   Generates a new address and private key (destructive action)
-dump      Dump a specific state of a block to stdout given the -number or -hash
-difftool  Supress all output and prints VM output to stdout
-diff      vm=only vm output, all=all output including state storage

Ethereum only
ethereum [options] [filename]
-js        Start the JavaScript REPL
filename   Load the given file and interpret as JavaScript
-m       Start mining blocks

== Mist only ==

-asset_path    absolute path to GUI assets directory

Contribution

If you'd like to contribute to Ethereum please fork, fix, commit and send a pull request. Commits who do not comply with the coding standards are ignored (use gofmt!). 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 (

	// Current protocol version
	ProtocolVersion = 49
	// Current P2P version
	P2PVersion = 2
	// Ethereum network version
	NetVersion = 0
)

Variables

This section is empty.

Functions

func PastPeers

func PastPeers() []string

Types

type BlockPool

type BlockPool struct {
	ChainLength, BlocksProcessed int
	// contains filtered or unexported fields
}

func NewBlockPool

func NewBlockPool(eth *Ethereum) *BlockPool

func (*BlockPool) Add

func (self *BlockPool) Add(b *types.Block, peer *Peer)

func (*BlockPool) AddHash

func (self *BlockPool) AddHash(hash []byte, peer *Peer)

func (*BlockPool) AddNew

func (self *BlockPool) AddNew(b *types.Block, peer *Peer)

func (*BlockPool) Blocks

func (self *BlockPool) Blocks() (blocks types.Blocks)

func (*BlockPool) DistributeHashes

func (self *BlockPool) DistributeHashes()

func (*BlockPool) FetchHashes

func (self *BlockPool) FetchHashes(peer *Peer) bool

func (*BlockPool) HasCommonHash

func (self *BlockPool) HasCommonHash(hash []byte) bool

func (*BlockPool) HasLatestHash

func (self *BlockPool) HasLatestHash() bool

func (*BlockPool) Len

func (self *BlockPool) Len() int

func (*BlockPool) Remove

func (self *BlockPool) Remove(hash []byte)

func (*BlockPool) Reset

func (self *BlockPool) Reset()

func (*BlockPool) Start

func (self *BlockPool) Start()

func (*BlockPool) Stop

func (self *BlockPool) Stop()

type Caps

type Caps byte

Peer capabilities

const (
	CapPeerDiscTy Caps = 1 << iota
	CapTxTy
	CapChainTy

	CapDefault = CapChainTy | CapTxTy | CapPeerDiscTy
)

func (Caps) IsCap

func (c Caps) IsCap(cap Caps) bool

func (Caps) String

func (c Caps) String() string

type ChainSyncEvent

type ChainSyncEvent struct {
	InSync bool
}

type DiscReason

type DiscReason byte
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.
	DiscRequested DiscReason = iota
	DiscReTcpSysErr
	DiscBadProto
	DiscBadPeer
	DiscTooManyPeers
	DiscConnDup
	DiscGenesisErr
	DiscProtoErr
	DiscQuitting
)

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 *rpc.JsonRpcServer
	// contains filtered or unexported fields
}

func New

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

func (*Ethereum) AddPeer

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

func (*Ethereum) BlacklistPeer

func (self *Ethereum) BlacklistPeer(peer *Peer)

func (*Ethereum) BlockManager

func (s *Ethereum) BlockManager() *core.BlockManager

func (*Ethereum) BlockPool

func (s *Ethereum) BlockPool() *BlockPool

func (*Ethereum) Broadcast

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

func (*Ethereum) BroadcastMsg

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

func (*Ethereum) ChainManager

func (s *Ethereum) ChainManager() *core.ChainManager

func (*Ethereum) ClientIdentity

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

func (*Ethereum) ConnectToPeer

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

func (*Ethereum) Db

func (self *Ethereum) Db() ethutil.Database

func (*Ethereum) EventMux

func (s *Ethereum) EventMux() *event.TypeMux

func (*Ethereum) GetFilter

func (self *Ethereum) GetFilter(id int) *core.Filter

GetFilter retrieves a filter installed using InstallFilter. The filter may not be modified.

func (*Ethereum) HighestTDPeer

func (s *Ethereum) HighestTDPeer() (td *big.Int)

func (*Ethereum) InOutPeers

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

func (*Ethereum) InboundPeers

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

func (*Ethereum) InstallFilter

func (self *Ethereum) InstallFilter(filter *core.Filter) (id int)

InstallFilter adds filter for blockchain events. The filter's callbacks will run for matching blocks and messages. The filter should not be modified after it has been installed.

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() *crypto.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) 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) Stop

func (s *Ethereum) Stop()

func (*Ethereum) TxPool

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

func (*Ethereum) UninstallFilter

func (self *Ethereum) UninstallFilter(id int)

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) Caps

func (self *Peer) Caps() *ethutil.Value

func (*Peer) Connect

func (self *Peer) Connect(addr string) (conn net.Conn, err error)

func (*Peer) Connected

func (p *Peer) Connected() *int32

func (*Peer) FetchBlocks

func (self *Peer) FetchBlocks(hashes [][]byte)

func (*Peer) FetchHashes

func (self *Peer) FetchHashes() bool

func (*Peer) FetchingHashes

func (self *Peer) FetchingHashes() bool

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) IsCap

func (self *Peer) IsCap(cap string) 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 *wire.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) StopWithReason

func (p *Peer) StopWithReason(reason DiscReason)

func (*Peer) String

func (p *Peer) String() string

func (*Peer) Version

func (p *Peer) Version() string

type PeerListEvent

type PeerListEvent struct {
	Peers *list.List
}

Directories

Path Synopsis
cmd
evm
compression
rle
Package event implements an event multiplexer.
Package event implements an event multiplexer.
Package logger implements a multi-output leveled logger.
Package logger implements a multi-output leveled logger.
pow
ar
ezp
Package rlp implements the RLP serialization format.
Package rlp implements the RLP serialization format.
tests
ui
qt
Package wire provides low level access to the Ethereum network and allows you to broadcast data over the network.
Package wire 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