コード例 #1
0
ファイル: pipe.go プロジェクト: vmatekole/eth-go
package ethpipe

import (
	"strings"

	"github.com/ethereum/eth-go/ethchain"
	"github.com/ethereum/eth-go/ethcrypto"
	"github.com/ethereum/eth-go/ethlog"
	"github.com/ethereum/eth-go/ethstate"
	"github.com/ethereum/eth-go/ethutil"
	"github.com/ethereum/eth-go/ethvm"
)

var logger = ethlog.NewLogger("PIPE")

type VmVars struct {
	State *ethstate.State
}

type Pipe struct {
	obj          ethchain.EthManager
	stateManager *ethchain.StateManager
	blockChain   *ethchain.BlockChain
	world        *World

	Vm VmVars
}

func New(obj ethchain.EthManager) *Pipe {
	pipe := &Pipe{
		obj:          obj,
コード例 #2
0
ファイル: ethereum.go プロジェクト: vmatekole/eth-go
	"github.com/ethereum/eth-go/ethchain"
	"github.com/ethereum/eth-go/ethcrypto"
	"github.com/ethereum/eth-go/ethlog"
	"github.com/ethereum/eth-go/ethreact"
	"github.com/ethereum/eth-go/ethrpc"
	"github.com/ethereum/eth-go/ethutil"
	"github.com/ethereum/eth-go/ethwire"
)

const (
	seedTextFileUri string = "http://www.ethereum.org/servers.poc3.txt"
	seedNodeAddress        = "54.76.56.74:30303"
)

var ethlogger = ethlog.NewLogger("SERV")

func eachPeer(peers *list.List, callback func(*Peer, *list.Element)) {
	// Loop thru the peers and close them (if we had them)
	for e := peers.Front(); e != nil; e = e.Next() {
		if peer, ok := e.Value.(*Peer); ok {
			callback(peer, e)
		}
	}
}

const (
	processReapingTimeout = 60 // TODO increase
)

type Ethereum struct {
コード例 #3
0
ファイル: repl.go プロジェクト: JustinDrake/go-ethereum
package ethrepl

import (
	"bufio"
	"fmt"
	"github.com/ethereum/eth-go"
	"github.com/ethereum/eth-go/ethlog"
	"github.com/ethereum/eth-go/ethutil"
	"io"
	"os"
	"path"
)

var logger = ethlog.NewLogger("REPL")

type Repl interface {
	Start()
	Stop()
}

type JSRepl struct {
	re *JSRE

	prompt string

	history *os.File

	running bool
}

func NewJSRepl(ethereum *eth.Ethereum) *JSRepl {
コード例 #4
0
ファイル: common.go プロジェクト: vmatekole/eth-go
package ethvm

import (
	"github.com/ethereum/eth-go/ethlog"
	"github.com/ethereum/eth-go/ethutil"
	"math/big"
)

var vmlogger = ethlog.NewLogger("VM")

var (
	GasStep    = big.NewInt(1)
	GasSha     = big.NewInt(20)
	GasSLoad   = big.NewInt(20)
	GasSStore  = big.NewInt(100)
	GasBalance = big.NewInt(20)
	GasCreate  = big.NewInt(100)
	GasCall    = big.NewInt(20)
	GasMemory  = big.NewInt(1)
	GasData    = big.NewInt(5)
	GasTx      = big.NewInt(500)

	Pow256 = ethutil.BigPow(2, 256)

	LogTyPretty byte = 0x1
	LogTyDiff   byte = 0x2
)
コード例 #5
0
ファイル: transaction_pool.go プロジェクト: vmatekole/eth-go
package ethchain

import (
	"bytes"
	"container/list"
	"fmt"
	"math/big"
	"sync"

	"github.com/ethereum/eth-go/ethlog"
	"github.com/ethereum/eth-go/ethstate"
	"github.com/ethereum/eth-go/ethwire"
)

var txplogger = ethlog.NewLogger("TXP")

const (
	txPoolQueueSize = 50
)

type TxPoolHook chan *Transaction
type TxMsgTy byte

const (
	TxPre = iota
	TxPost
	minGasPrice = 1000000
)

type TxMsg struct {
	Tx   *Transaction
コード例 #6
0
ファイル: server.go プロジェクト: vmatekole/eth-go
package ethrpc

import (
	"fmt"
	"net"
	"net/rpc"
	"net/rpc/jsonrpc"

	"github.com/ethereum/eth-go/ethlog"
	"github.com/ethereum/eth-go/ethpipe"
)

var logger = ethlog.NewLogger("JSON")

type JsonRpcServer struct {
	quit     chan bool
	listener net.Listener
	pipe     *ethpipe.JSPipe
}

func (s *JsonRpcServer) exitHandler() {
out:
	for {
		select {
		case <-s.quit:
			s.listener.Close()
			break out
		}
	}

	logger.Infoln("Shutdown JSON-RPC server")
コード例 #7
0
ファイル: gui.go プロジェクト: JustinDrake/go-ethereum
	"github.com/ethereum/eth-go/ethchain"
	"github.com/ethereum/eth-go/ethdb"
	"github.com/ethereum/eth-go/ethlog"
	"github.com/ethereum/eth-go/ethminer"
	"github.com/ethereum/eth-go/ethpub"
	"github.com/ethereum/eth-go/ethutil"
	"github.com/ethereum/eth-go/ethwire"
	"github.com/ethereum/go-ethereum/utils"
	"github.com/go-qml/qml"
	"math/big"
	"strconv"
	"strings"
	"time"
)

var logger = ethlog.NewLogger("GUI")

type Gui struct {
	// The main application window
	win *qml.Window
	// QML Engine
	engine    *qml.Engine
	component *qml.Common
	// The ethereum interface
	eth *eth.Ethereum

	// The public Ethereum library
	uiLib *UiLib

	txDb *ethdb.LDBDatabase
コード例 #8
0
ファイル: miner.go プロジェクト: vmatekole/eth-go
package ethminer

import (
	"bytes"
	"sort"

	"github.com/ethereum/eth-go/ethchain"
	"github.com/ethereum/eth-go/ethlog"
	"github.com/ethereum/eth-go/ethreact"
	"github.com/ethereum/eth-go/ethwire"
)

var logger = ethlog.NewLogger("MINER")

type Miner struct {
	pow         ethchain.PoW
	ethereum    ethchain.EthManager
	coinbase    []byte
	reactChan   chan ethreact.Event
	txs         ethchain.Transactions
	uncles      []*ethchain.Block
	block       *ethchain.Block
	powChan     chan []byte
	powQuitChan chan ethreact.Event
	quitChan    chan chan error

	turbo bool
}

func (self *Miner) GetPow() ethchain.PoW {
	return self.pow
コード例 #9
0
ファイル: main.go プロジェクト: R15T3/go-ethereum
package main

import (
	"github.com/ethereum/eth-go/ethlog"
	"github.com/ethereum/eth-go/ethutil"
	"github.com/ethereum/go-ethereum/utils"
	"runtime"
)

const (
	ClientIdentifier = "Ethereum(G)"
	Version          = "0.5.17"
)

var logger = ethlog.NewLogger("CLI")

func main() {
	runtime.GOMAXPROCS(runtime.NumCPU())

	utils.HandleInterrupt()

	// precedence: code-internal flag default < config file < environment variables < command line
	Init() // parsing command line

	// If the difftool option is selected ignore all other log output
	if DiffTool {
		LogLevel = 0
	}

	utils.InitConfig(ConfigFile, Datadir, "ETH")
	ethutil.Config.Diff = DiffTool
コード例 #10
0
ファイル: state_manager.go プロジェクト: vmatekole/eth-go
	"bytes"
	"container/list"
	"fmt"
	"math/big"
	"sync"
	"time"

	"github.com/ethereum/eth-go/ethcrypto"
	"github.com/ethereum/eth-go/ethlog"
	"github.com/ethereum/eth-go/ethreact"
	"github.com/ethereum/eth-go/ethstate"
	"github.com/ethereum/eth-go/ethutil"
	"github.com/ethereum/eth-go/ethwire"
)

var statelogger = ethlog.NewLogger("STATE")

type BlockProcessor interface {
	ProcessBlock(block *Block)
}

type Peer interface {
	Inbound() bool
	LastSend() time.Time
	LastPong() int64
	Host() []byte
	Port() uint16
	Version() string
	PingTime() string
	Connected() *int32
}
コード例 #11
0
import (
	"fmt"
	"github.com/ethereum/eth-go"
	"github.com/ethereum/eth-go/ethchain"
	"github.com/ethereum/eth-go/ethlog"
	"github.com/ethereum/eth-go/ethpub"
	"github.com/ethereum/eth-go/ethutil"
	"github.com/ethereum/go-ethereum/utils"
	"github.com/obscuren/otto"
	"io/ioutil"
	"os"
	"path"
	"path/filepath"
)

var jsrelogger = ethlog.NewLogger("JSRE")

type JSRE struct {
	ethereum *eth.Ethereum
	vm       *otto.Otto
	lib      *ethpub.PEthereum

	blockChan  chan ethutil.React
	changeChan chan ethutil.React
	quitChan   chan bool

	objectCb map[string][]otto.Value
}

func (jsre *JSRE) LoadExtFile(path string) {
	result, err := ioutil.ReadFile(path)
コード例 #12
0
ファイル: reactor.go プロジェクト: vmatekole/eth-go
package ethreact

import (
	"github.com/ethereum/eth-go/ethlog"
	"sync"
)

var logger = ethlog.NewLogger("REACTOR")

const (
	eventBufferSize int = 10
)

type EventHandler struct {
	lock  sync.RWMutex
	name  string
	chans []chan Event
}

// Post the Event with the reactor resource on the channels
// currently subscribed to the event
func (e *EventHandler) Post(event Event) {
	e.lock.RLock()
	defer e.lock.RUnlock()

	// if we want to preserve order pushing to subscibed channels
	// dispatching should be syncrounous
	// this means if subscribed event channel is blocked
	// the reactor dispatch will be blocked, so we need to mitigate by skipping
	// rogue blocking subscribers
	for i, ch := range e.chans {
コード例 #13
0
ファイル: peer.go プロジェクト: vmatekole/eth-go
	"fmt"
	"math"
	"math/big"
	"net"
	"strconv"
	"strings"
	"sync/atomic"
	"time"

	"github.com/ethereum/eth-go/ethchain"
	"github.com/ethereum/eth-go/ethlog"
	"github.com/ethereum/eth-go/ethutil"
	"github.com/ethereum/eth-go/ethwire"
)

var peerlogger = ethlog.NewLogger("PEER")

const (
	// The size of the output buffer for writing messages
	outputBufferSize = 50
	// Current protocol version
	ProtocolVersion = 28
	// Interval for ping/pong message
	pingPongTimer = 2 * time.Second
)

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
コード例 #14
0
ファイル: dagger.go プロジェクト: vmatekole/eth-go
package ethchain

import (
	"hash"
	"math/big"
	"math/rand"
	"time"

	"github.com/ethereum/eth-go/ethcrypto"
	"github.com/ethereum/eth-go/ethlog"
	"github.com/ethereum/eth-go/ethreact"
	"github.com/ethereum/eth-go/ethutil"
	"github.com/obscuren/sha3"
)

var powlogger = ethlog.NewLogger("POW")

type PoW interface {
	Search(block *Block, reactChan chan ethreact.Event) []byte
	Verify(hash []byte, diff *big.Int, nonce []byte) bool
	GetHashrate() int64
	Turbo(bool)
}

type EasyPow struct {
	hash     *big.Int
	HashRate int64
	turbo    bool
}

func (pow *EasyPow) GetHashrate() int64 {
コード例 #15
0
ファイル: block_chain.go プロジェクト: vmatekole/eth-go
package ethchain

import (
	"bytes"
	"math"
	"math/big"

	"github.com/ethereum/eth-go/ethlog"
	"github.com/ethereum/eth-go/ethutil"
	"github.com/ethereum/eth-go/ethwire"
)

var chainlogger = ethlog.NewLogger("CHAIN")

type BlockChain struct {
	Ethereum EthManager
	// The famous, the fabulous Mister GENESIIIIIIS (block)
	genesisBlock *Block
	// Last known total difficulty
	TD *big.Int

	LastBlockNumber uint64

	CurrentBlock  *Block
	LastBlockHash []byte
}

func NewBlockChain(ethereum EthManager) *BlockChain {
	bc := &BlockChain{}
	bc.genesisBlock = NewBlockFromBytes(ethutil.Encode(Genesis))
	bc.Ethereum = ethereum