forked from cerc-io/plugeth
go fmt
This commit is contained in:
parent
da38faa8f7
commit
853053a3b2
@ -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"
|
||||||
)
|
)
|
||||||
|
@ -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++
|
||||||
|
@ -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"
|
||||||
|
@ -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"
|
||||||
)
|
)
|
||||||
|
@ -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"
|
||||||
)
|
)
|
||||||
|
@ -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"
|
||||||
|
@ -2,10 +2,10 @@ package ethlog
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"sync"
|
|
||||||
"log"
|
|
||||||
"io"
|
"io"
|
||||||
|
"log"
|
||||||
"os"
|
"os"
|
||||||
|
"sync"
|
||||||
)
|
)
|
||||||
|
|
||||||
type LogSystem interface {
|
type LogSystem interface {
|
||||||
@ -21,11 +21,11 @@ type logMessage struct {
|
|||||||
msg string
|
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...))}
|
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...))}
|
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 logSystems []LogSystem
|
||||||
var drained = true
|
var drained = true
|
||||||
|
|
||||||
@ -56,7 +56,7 @@ const (
|
|||||||
func start() {
|
func start() {
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case msg := <- logMessages:
|
case msg := <-logMessages:
|
||||||
for _, logSystem := range logSystems {
|
for _, logSystem := range logSystems {
|
||||||
if logSystem.GetLogLevel() >= msg.LogLevel {
|
if logSystem.GetLogLevel() >= msg.LogLevel {
|
||||||
msg.send(logSystem)
|
msg.send(logSystem)
|
||||||
@ -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 {
|
||||||
@ -92,7 +93,7 @@ func AddLogSystem(logSystem LogSystem) {
|
|||||||
logSystems = append(logSystems, logSystem)
|
logSystems = append(logSystems, logSystem)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (logger *Logger) sendln(level LogLevel, v...interface{}) {
|
func (logger *Logger) sendln(level LogLevel, v ...interface{}) {
|
||||||
if logMessages != nil {
|
if logMessages != nil {
|
||||||
msg := newPrintlnLogMessage(level, logger.tag, v...)
|
msg := newPrintlnLogMessage(level, logger.tag, v...)
|
||||||
drained = false
|
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 {
|
if logMessages != nil {
|
||||||
msg := newPrintfLogMessage(level, logger.tag, format, v...)
|
msg := newPrintfLogMessage(level, logger.tag, format, v...)
|
||||||
drained = false
|
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...)
|
logger.sendln(ErrorLevel, v...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (logger *Logger) Warnln(v...interface{}) {
|
func (logger *Logger) Warnln(v ...interface{}) {
|
||||||
logger.sendln(WarnLevel, v...)
|
logger.sendln(WarnLevel, v...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (logger *Logger) Infoln(v...interface{}) {
|
func (logger *Logger) Infoln(v ...interface{}) {
|
||||||
logger.sendln(InfoLevel, v...)
|
logger.sendln(InfoLevel, v...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (logger *Logger) Debugln(v...interface{}) {
|
func (logger *Logger) Debugln(v ...interface{}) {
|
||||||
logger.sendln(DebugLevel, v...)
|
logger.sendln(DebugLevel, v...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (logger *Logger) DebugDetailln(v...interface{}) {
|
func (logger *Logger) DebugDetailln(v ...interface{}) {
|
||||||
logger.sendln(DebugDetailLevel, v...)
|
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...)
|
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...)
|
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...)
|
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...)
|
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...)
|
logger.sendf(DebugDetailLevel, format, v...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (logger *Logger) Fatalln (v...interface{}) {
|
func (logger *Logger) Fatalln(v ...interface{}) {
|
||||||
logger.sendln(ErrorLevel, v...)
|
logger.sendln(ErrorLevel, v...)
|
||||||
Flush()
|
Flush()
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (logger *Logger) Fatalf (format string, v...interface{}) {
|
func (logger *Logger) Fatalf(format string, v ...interface{}) {
|
||||||
logger.sendf(ErrorLevel, format, v...)
|
logger.sendf(ErrorLevel, format, v...)
|
||||||
Flush()
|
Flush()
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
@ -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}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -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() {
|
||||||
|
@ -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"
|
||||||
|
@ -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"
|
||||||
|
@ -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
|
||||||
|
2
peer.go
2
peer.go
@ -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"
|
||||||
|
Loading…
Reference in New Issue
Block a user