go fmt
This commit is contained in:
parent
da38faa8f7
commit
853053a3b2
@ -2,9 +2,9 @@ package ethchain
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"github.com/ethereum/eth-go/ethlog"
|
||||
"github.com/ethereum/eth-go/ethutil"
|
||||
"github.com/ethereum/eth-go/ethwire"
|
||||
"github.com/ethereum/eth-go/ethlog"
|
||||
"math"
|
||||
"math/big"
|
||||
)
|
||||
|
@ -1,8 +1,8 @@
|
||||
package ethchain
|
||||
|
||||
import (
|
||||
"github.com/ethereum/eth-go/ethutil"
|
||||
"github.com/ethereum/eth-go/ethlog"
|
||||
"github.com/ethereum/eth-go/ethutil"
|
||||
"github.com/obscuren/sha3"
|
||||
"hash"
|
||||
"math/big"
|
||||
@ -31,7 +31,6 @@ func (pow *EasyPow) Search(block *Block, reactChan chan ethutil.React) []byte {
|
||||
for {
|
||||
select {
|
||||
case <-reactChan:
|
||||
//powlogger.Infoln("Received reactor event; breaking out.")
|
||||
return nil
|
||||
default:
|
||||
i++
|
||||
|
@ -3,9 +3,9 @@ package ethchain
|
||||
import (
|
||||
"bytes"
|
||||
"container/list"
|
||||
"github.com/ethereum/eth-go/ethlog"
|
||||
"github.com/ethereum/eth-go/ethutil"
|
||||
"github.com/ethereum/eth-go/ethwire"
|
||||
"github.com/ethereum/eth-go/ethlog"
|
||||
"math/big"
|
||||
"sync"
|
||||
"time"
|
||||
|
@ -4,8 +4,8 @@ import (
|
||||
"bytes"
|
||||
"container/list"
|
||||
"fmt"
|
||||
"github.com/ethereum/eth-go/ethwire"
|
||||
"github.com/ethereum/eth-go/ethlog"
|
||||
"github.com/ethereum/eth-go/ethwire"
|
||||
"math/big"
|
||||
"sync"
|
||||
)
|
||||
|
@ -2,8 +2,8 @@ package ethchain
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/ethereum/eth-go/ethutil"
|
||||
"github.com/ethereum/eth-go/ethlog"
|
||||
"github.com/ethereum/eth-go/ethutil"
|
||||
"math"
|
||||
"math/big"
|
||||
)
|
||||
|
@ -5,10 +5,10 @@ import (
|
||||
"fmt"
|
||||
"github.com/ethereum/eth-go/ethchain"
|
||||
"github.com/ethereum/eth-go/ethdb"
|
||||
"github.com/ethereum/eth-go/ethlog"
|
||||
"github.com/ethereum/eth-go/ethrpc"
|
||||
"github.com/ethereum/eth-go/ethutil"
|
||||
"github.com/ethereum/eth-go/ethwire"
|
||||
"github.com/ethereum/eth-go/ethlog"
|
||||
"io/ioutil"
|
||||
"math/rand"
|
||||
"net"
|
||||
|
@ -2,10 +2,10 @@ package ethlog
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"sync"
|
||||
"log"
|
||||
"io"
|
||||
"log"
|
||||
"os"
|
||||
"sync"
|
||||
)
|
||||
|
||||
type LogSystem interface {
|
||||
@ -21,11 +21,11 @@ type logMessage struct {
|
||||
msg string
|
||||
}
|
||||
|
||||
func newPrintlnLogMessage(level LogLevel, tag string, v...interface{}) *logMessage {
|
||||
func newPrintlnLogMessage(level LogLevel, tag string, v ...interface{}) *logMessage {
|
||||
return &logMessage{level, false, fmt.Sprintf("[%s] %s", tag, fmt.Sprint(v...))}
|
||||
}
|
||||
|
||||
func newPrintfLogMessage(level LogLevel, tag string, format string, v...interface{}) *logMessage {
|
||||
func newPrintfLogMessage(level LogLevel, tag string, format string, v ...interface{}) *logMessage {
|
||||
return &logMessage{level, true, fmt.Sprintf("[%s] %s", tag, fmt.Sprintf(format, v...))}
|
||||
}
|
||||
|
||||
@ -37,7 +37,7 @@ func (msg *logMessage) send(logger LogSystem) {
|
||||
}
|
||||
}
|
||||
|
||||
var logMessages chan(*logMessage)
|
||||
var logMessages chan (*logMessage)
|
||||
var logSystems []LogSystem
|
||||
var drained = true
|
||||
|
||||
@ -56,7 +56,7 @@ const (
|
||||
func start() {
|
||||
for {
|
||||
select {
|
||||
case msg := <- logMessages:
|
||||
case msg := <-logMessages:
|
||||
for _, logSystem := range logSystems {
|
||||
if logSystem.GetLogLevel() >= msg.LogLevel {
|
||||
msg.send(logSystem)
|
||||
@ -70,7 +70,8 @@ func start() {
|
||||
|
||||
// waits until log messages are drained (dispatched to log writers)
|
||||
func Flush() {
|
||||
for !drained {}
|
||||
for !drained {
|
||||
}
|
||||
}
|
||||
|
||||
type Logger struct {
|
||||
@ -92,7 +93,7 @@ func AddLogSystem(logSystem LogSystem) {
|
||||
logSystems = append(logSystems, logSystem)
|
||||
}
|
||||
|
||||
func (logger *Logger) sendln(level LogLevel, v...interface{}) {
|
||||
func (logger *Logger) sendln(level LogLevel, v ...interface{}) {
|
||||
if logMessages != nil {
|
||||
msg := newPrintlnLogMessage(level, logger.tag, v...)
|
||||
drained = false
|
||||
@ -100,7 +101,7 @@ func (logger *Logger) sendln(level LogLevel, v...interface{}) {
|
||||
}
|
||||
}
|
||||
|
||||
func (logger *Logger) sendf(level LogLevel, format string, v...interface{}) {
|
||||
func (logger *Logger) sendf(level LogLevel, format string, v ...interface{}) {
|
||||
if logMessages != nil {
|
||||
msg := newPrintfLogMessage(level, logger.tag, format, v...)
|
||||
drained = false
|
||||
@ -108,53 +109,53 @@ func (logger *Logger) sendf(level LogLevel, format string, v...interface{}) {
|
||||
}
|
||||
}
|
||||
|
||||
func (logger *Logger) Errorln(v...interface{}) {
|
||||
func (logger *Logger) Errorln(v ...interface{}) {
|
||||
logger.sendln(ErrorLevel, v...)
|
||||
}
|
||||
|
||||
func (logger *Logger) Warnln(v...interface{}) {
|
||||
func (logger *Logger) Warnln(v ...interface{}) {
|
||||
logger.sendln(WarnLevel, v...)
|
||||
}
|
||||
|
||||
func (logger *Logger) Infoln(v...interface{}) {
|
||||
func (logger *Logger) Infoln(v ...interface{}) {
|
||||
logger.sendln(InfoLevel, v...)
|
||||
}
|
||||
|
||||
func (logger *Logger) Debugln(v...interface{}) {
|
||||
func (logger *Logger) Debugln(v ...interface{}) {
|
||||
logger.sendln(DebugLevel, v...)
|
||||
}
|
||||
|
||||
func (logger *Logger) DebugDetailln(v...interface{}) {
|
||||
func (logger *Logger) DebugDetailln(v ...interface{}) {
|
||||
logger.sendln(DebugDetailLevel, v...)
|
||||
}
|
||||
|
||||
func (logger *Logger) Errorf(format string, v...interface{}) {
|
||||
func (logger *Logger) Errorf(format string, v ...interface{}) {
|
||||
logger.sendf(ErrorLevel, format, v...)
|
||||
}
|
||||
|
||||
func (logger *Logger) Warnf(format string, v...interface{}) {
|
||||
func (logger *Logger) Warnf(format string, v ...interface{}) {
|
||||
logger.sendf(WarnLevel, format, v...)
|
||||
}
|
||||
|
||||
func (logger *Logger) Infof(format string, v...interface{}) {
|
||||
func (logger *Logger) Infof(format string, v ...interface{}) {
|
||||
logger.sendf(InfoLevel, format, v...)
|
||||
}
|
||||
|
||||
func (logger *Logger) Debugf(format string, v...interface{}) {
|
||||
func (logger *Logger) Debugf(format string, v ...interface{}) {
|
||||
logger.sendf(DebugLevel, format, v...)
|
||||
}
|
||||
|
||||
func (logger *Logger) DebugDetailf(format string, v...interface{}) {
|
||||
func (logger *Logger) DebugDetailf(format string, v ...interface{}) {
|
||||
logger.sendf(DebugDetailLevel, format, v...)
|
||||
}
|
||||
|
||||
func (logger *Logger) Fatalln (v...interface{}) {
|
||||
func (logger *Logger) Fatalln(v ...interface{}) {
|
||||
logger.sendln(ErrorLevel, v...)
|
||||
Flush()
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
func (logger *Logger) Fatalf (format string, v...interface{}) {
|
||||
func (logger *Logger) Fatalf(format string, v ...interface{}) {
|
||||
logger.sendf(ErrorLevel, format, v...)
|
||||
Flush()
|
||||
os.Exit(0)
|
||||
@ -185,4 +186,3 @@ func NewStdLogSystem(writer io.Writer, flags int, level LogLevel) *StdLogSystem
|
||||
logger := log.New(writer, "", flags)
|
||||
return &StdLogSystem{logger, level}
|
||||
}
|
||||
|
||||
|
@ -1,10 +1,10 @@
|
||||
package ethlog
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"testing"
|
||||
)
|
||||
|
||||
type TestLogSystem struct {
|
||||
@ -107,9 +107,3 @@ func TestNoLogSystem(t *testing.T) {
|
||||
logger.Warnln("warn")
|
||||
Flush()
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -3,9 +3,9 @@ package ethminer
|
||||
import (
|
||||
"bytes"
|
||||
"github.com/ethereum/eth-go/ethchain"
|
||||
"github.com/ethereum/eth-go/ethlog"
|
||||
"github.com/ethereum/eth-go/ethutil"
|
||||
"github.com/ethereum/eth-go/ethwire"
|
||||
"github.com/ethereum/eth-go/ethlog"
|
||||
"sort"
|
||||
)
|
||||
|
||||
@ -57,18 +57,23 @@ func NewDefaultMiner(coinbase []byte, ethereum ethchain.EthManager) Miner {
|
||||
|
||||
return miner
|
||||
}
|
||||
|
||||
func (miner *Miner) Start() {
|
||||
// Prepare inital block
|
||||
//miner.ethereum.StateManager().Prepare(miner.block.State(), miner.block.State())
|
||||
go miner.listener()
|
||||
logger.Infoln("Started")
|
||||
}
|
||||
|
||||
func (miner *Miner) listener() {
|
||||
out:
|
||||
for {
|
||||
select {
|
||||
case <-miner.quitChan:
|
||||
logger.Infoln("Stopped")
|
||||
break out
|
||||
case chanMessage := <-miner.reactChan:
|
||||
|
||||
if block, ok := chanMessage.Resource.(*ethchain.Block); ok {
|
||||
//logger.Infoln("Got new block via Reactor")
|
||||
if bytes.Compare(miner.ethereum.BlockChain().CurrentBlock.Hash(), block.Hash()) == 0 {
|
||||
@ -123,8 +128,9 @@ out:
|
||||
}
|
||||
|
||||
func (self *Miner) Stop() {
|
||||
self.powQuitChan <- ethutil.React{}
|
||||
logger.Infoln("Stopping...")
|
||||
self.quitChan <- true
|
||||
self.powQuitChan <- ethutil.React{}
|
||||
}
|
||||
|
||||
func (self *Miner) mineNewBlock() {
|
||||
|
@ -5,8 +5,8 @@ import (
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"github.com/ethereum/eth-go/ethchain"
|
||||
"github.com/ethereum/eth-go/ethutil"
|
||||
"github.com/ethereum/eth-go/ethlog"
|
||||
"github.com/ethereum/eth-go/ethutil"
|
||||
"math/big"
|
||||
"strings"
|
||||
"sync/atomic"
|
||||
|
@ -2,8 +2,8 @@ package ethrpc
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/ethereum/eth-go/ethpub"
|
||||
"github.com/ethereum/eth-go/ethlog"
|
||||
"github.com/ethereum/eth-go/ethpub"
|
||||
"net"
|
||||
"net/rpc"
|
||||
"net/rpc/jsonrpc"
|
||||
|
@ -4,8 +4,8 @@ import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"github.com/rakyll/globalconf"
|
||||
"runtime"
|
||||
"os"
|
||||
"runtime"
|
||||
)
|
||||
|
||||
// Config struct
|
||||
|
Loading…
Reference in New Issue
Block a user