This commit is contained in:
zelig 2014-06-26 18:45:57 +01:00
parent da38faa8f7
commit 853053a3b2
14 changed files with 204 additions and 205 deletions

View File

@ -2,9 +2,9 @@ package ethchain
import ( import (
"bytes" "bytes"
"github.com/ethereum/eth-go/ethlog"
"github.com/ethereum/eth-go/ethutil" "github.com/ethereum/eth-go/ethutil"
"github.com/ethereum/eth-go/ethwire" "github.com/ethereum/eth-go/ethwire"
"github.com/ethereum/eth-go/ethlog"
"math" "math"
"math/big" "math/big"
) )

View File

@ -1,8 +1,8 @@
package ethchain package ethchain
import ( import (
"github.com/ethereum/eth-go/ethutil"
"github.com/ethereum/eth-go/ethlog" "github.com/ethereum/eth-go/ethlog"
"github.com/ethereum/eth-go/ethutil"
"github.com/obscuren/sha3" "github.com/obscuren/sha3"
"hash" "hash"
"math/big" "math/big"
@ -31,7 +31,6 @@ func (pow *EasyPow) Search(block *Block, reactChan chan ethutil.React) []byte {
for { for {
select { select {
case <-reactChan: case <-reactChan:
//powlogger.Infoln("Received reactor event; breaking out.")
return nil return nil
default: default:
i++ i++

View File

@ -3,9 +3,9 @@ package ethchain
import ( import (
"bytes" "bytes"
"container/list" "container/list"
"github.com/ethereum/eth-go/ethlog"
"github.com/ethereum/eth-go/ethutil" "github.com/ethereum/eth-go/ethutil"
"github.com/ethereum/eth-go/ethwire" "github.com/ethereum/eth-go/ethwire"
"github.com/ethereum/eth-go/ethlog"
"math/big" "math/big"
"sync" "sync"
"time" "time"

View File

@ -4,8 +4,8 @@ import (
"bytes" "bytes"
"container/list" "container/list"
"fmt" "fmt"
"github.com/ethereum/eth-go/ethwire"
"github.com/ethereum/eth-go/ethlog" "github.com/ethereum/eth-go/ethlog"
"github.com/ethereum/eth-go/ethwire"
"math/big" "math/big"
"sync" "sync"
) )

View File

@ -2,8 +2,8 @@ package ethchain
import ( import (
"fmt" "fmt"
"github.com/ethereum/eth-go/ethutil"
"github.com/ethereum/eth-go/ethlog" "github.com/ethereum/eth-go/ethlog"
"github.com/ethereum/eth-go/ethutil"
"math" "math"
"math/big" "math/big"
) )

View File

@ -5,10 +5,10 @@ import (
"fmt" "fmt"
"github.com/ethereum/eth-go/ethchain" "github.com/ethereum/eth-go/ethchain"
"github.com/ethereum/eth-go/ethdb" "github.com/ethereum/eth-go/ethdb"
"github.com/ethereum/eth-go/ethlog"
"github.com/ethereum/eth-go/ethrpc" "github.com/ethereum/eth-go/ethrpc"
"github.com/ethereum/eth-go/ethutil" "github.com/ethereum/eth-go/ethutil"
"github.com/ethereum/eth-go/ethwire" "github.com/ethereum/eth-go/ethwire"
"github.com/ethereum/eth-go/ethlog"
"io/ioutil" "io/ioutil"
"math/rand" "math/rand"
"net" "net"

View File

@ -2,10 +2,10 @@ package ethlog
import ( import (
"fmt" "fmt"
"sync"
"log"
"io" "io"
"log"
"os" "os"
"sync"
) )
type LogSystem interface { type LogSystem interface {
@ -70,7 +70,8 @@ func start() {
// waits until log messages are drained (dispatched to log writers) // waits until log messages are drained (dispatched to log writers)
func Flush() { func Flush() {
for !drained {} for !drained {
}
} }
type Logger struct { type Logger struct {
@ -185,4 +186,3 @@ func NewStdLogSystem(writer io.Writer, flags int, level LogLevel) *StdLogSystem
logger := log.New(writer, "", flags) logger := log.New(writer, "", flags)
return &StdLogSystem{logger, level} return &StdLogSystem{logger, level}
} }

View File

@ -1,10 +1,10 @@
package ethlog package ethlog
import ( import (
"testing"
"fmt" "fmt"
"io/ioutil" "io/ioutil"
"os" "os"
"testing"
) )
type TestLogSystem struct { type TestLogSystem struct {
@ -107,9 +107,3 @@ func TestNoLogSystem(t *testing.T) {
logger.Warnln("warn") logger.Warnln("warn")
Flush() Flush()
} }

View File

@ -3,9 +3,9 @@ package ethminer
import ( import (
"bytes" "bytes"
"github.com/ethereum/eth-go/ethchain" "github.com/ethereum/eth-go/ethchain"
"github.com/ethereum/eth-go/ethlog"
"github.com/ethereum/eth-go/ethutil" "github.com/ethereum/eth-go/ethutil"
"github.com/ethereum/eth-go/ethwire" "github.com/ethereum/eth-go/ethwire"
"github.com/ethereum/eth-go/ethlog"
"sort" "sort"
) )
@ -57,18 +57,23 @@ func NewDefaultMiner(coinbase []byte, ethereum ethchain.EthManager) Miner {
return miner return miner
} }
func (miner *Miner) Start() { func (miner *Miner) Start() {
// Prepare inital block // Prepare inital block
//miner.ethereum.StateManager().Prepare(miner.block.State(), miner.block.State()) //miner.ethereum.StateManager().Prepare(miner.block.State(), miner.block.State())
go miner.listener() go miner.listener()
logger.Infoln("Started")
} }
func (miner *Miner) listener() { func (miner *Miner) listener() {
out: out:
for { for {
select { select {
case <-miner.quitChan: case <-miner.quitChan:
logger.Infoln("Stopped")
break out break out
case chanMessage := <-miner.reactChan: case chanMessage := <-miner.reactChan:
if block, ok := chanMessage.Resource.(*ethchain.Block); ok { if block, ok := chanMessage.Resource.(*ethchain.Block); ok {
//logger.Infoln("Got new block via Reactor") //logger.Infoln("Got new block via Reactor")
if bytes.Compare(miner.ethereum.BlockChain().CurrentBlock.Hash(), block.Hash()) == 0 { if bytes.Compare(miner.ethereum.BlockChain().CurrentBlock.Hash(), block.Hash()) == 0 {
@ -123,8 +128,9 @@ out:
} }
func (self *Miner) Stop() { func (self *Miner) Stop() {
self.powQuitChan <- ethutil.React{} logger.Infoln("Stopping...")
self.quitChan <- true self.quitChan <- true
self.powQuitChan <- ethutil.React{}
} }
func (self *Miner) mineNewBlock() { func (self *Miner) mineNewBlock() {

View File

@ -5,8 +5,8 @@ import (
"encoding/hex" "encoding/hex"
"encoding/json" "encoding/json"
"github.com/ethereum/eth-go/ethchain" "github.com/ethereum/eth-go/ethchain"
"github.com/ethereum/eth-go/ethutil"
"github.com/ethereum/eth-go/ethlog" "github.com/ethereum/eth-go/ethlog"
"github.com/ethereum/eth-go/ethutil"
"math/big" "math/big"
"strings" "strings"
"sync/atomic" "sync/atomic"

View File

@ -2,8 +2,8 @@ package ethrpc
import ( import (
"fmt" "fmt"
"github.com/ethereum/eth-go/ethpub"
"github.com/ethereum/eth-go/ethlog" "github.com/ethereum/eth-go/ethlog"
"github.com/ethereum/eth-go/ethpub"
"net" "net"
"net/rpc" "net/rpc"
"net/rpc/jsonrpc" "net/rpc/jsonrpc"

View File

@ -4,8 +4,8 @@ import (
"flag" "flag"
"fmt" "fmt"
"github.com/rakyll/globalconf" "github.com/rakyll/globalconf"
"runtime"
"os" "os"
"runtime"
) )
// Config struct // Config struct

View File

@ -5,9 +5,9 @@ import (
"container/list" "container/list"
"fmt" "fmt"
"github.com/ethereum/eth-go/ethchain" "github.com/ethereum/eth-go/ethchain"
"github.com/ethereum/eth-go/ethlog"
"github.com/ethereum/eth-go/ethutil" "github.com/ethereum/eth-go/ethutil"
"github.com/ethereum/eth-go/ethwire" "github.com/ethereum/eth-go/ethwire"
"github.com/ethereum/eth-go/ethlog"
"net" "net"
"strconv" "strconv"
"strings" "strings"