aboutsummaryrefslogtreecommitdiffstats
path: root/eth
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2015-03-04 03:30:05 +0800
committerobscuren <geffobscura@gmail.com>2015-03-04 03:30:05 +0800
commitf0b2ea64fc331fe6ef9f15097ac2d129dd9b7207 (patch)
treeb54c28e87d0a64cab079c08108672b8d7e39d5f2 /eth
parent27078919669ad99bfb51b468f7c475120e6e148a (diff)
parent6c2856df2335dec946a5ebc14a4438b261e0c881 (diff)
downloaddexon-f0b2ea64fc331fe6ef9f15097ac2d129dd9b7207.tar
dexon-f0b2ea64fc331fe6ef9f15097ac2d129dd9b7207.tar.gz
dexon-f0b2ea64fc331fe6ef9f15097ac2d129dd9b7207.tar.bz2
dexon-f0b2ea64fc331fe6ef9f15097ac2d129dd9b7207.tar.lz
dexon-f0b2ea64fc331fe6ef9f15097ac2d129dd9b7207.tar.xz
dexon-f0b2ea64fc331fe6ef9f15097ac2d129dd9b7207.tar.zst
dexon-f0b2ea64fc331fe6ef9f15097ac2d129dd9b7207.zip
Merge branch 'jsonlogs' of https://github.com/ethersphere/go-ethereum into ethersphere-jsonlogs
Conflicts: eth/block_pool.go eth/block_pool_test.go eth/protocol_test.go miner/worker.go
Diffstat (limited to 'eth')
-rw-r--r--eth/backend.go24
-rw-r--r--eth/protocol.go16
-rw-r--r--eth/protocol_test.go1
3 files changed, 28 insertions, 13 deletions
diff --git a/eth/backend.go b/eth/backend.go
index 50fb70720..8673a265a 100644
--- a/eth/backend.go
+++ b/eth/backend.go
@@ -14,7 +14,7 @@ import (
"github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/ethutil"
"github.com/ethereum/go-ethereum/event"
- ethlogger "github.com/ethereum/go-ethereum/logger"
+ "github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/miner"
"github.com/ethereum/go-ethereum/p2p"
"github.com/ethereum/go-ethereum/p2p/discover"
@@ -25,8 +25,8 @@ import (
)
var (
- logger = ethlogger.NewLogger("SERV")
- jsonlogger = ethlogger.NewJsonLogger()
+ ethlogger = logger.NewLogger("SERV")
+ jsonlogger = logger.NewJsonLogger()
defaultBootNodes = []*discover.Node{
// ETH/DEV cmd/bootnode
@@ -76,7 +76,7 @@ func (cfg *Config) parseBootNodes() []*discover.Node {
}
n, err := discover.ParseNode(url)
if err != nil {
- logger.Errorf("Bootstrap URL %s: %v\n", url, err)
+ ethlogger.Errorf("Bootstrap URL %s: %v\n", url, err)
continue
}
ns = append(ns, n)
@@ -100,7 +100,7 @@ func (cfg *Config) nodeKey() (*ecdsa.PrivateKey, error) {
return nil, fmt.Errorf("could not generate server key: %v", err)
}
if err := ioutil.WriteFile(keyfile, crypto.FromECDSA(key), 0600); err != nil {
- logger.Errorln("could not persist nodekey: ", err)
+ ethlogger.Errorln("could not persist nodekey: ", err)
}
return key, nil
}
@@ -132,14 +132,14 @@ type Ethereum struct {
WsServer rpc.RpcServer
keyManager *crypto.KeyManager
- logger ethlogger.LogSystem
+ logger logger.LogSystem
Mining bool
}
func New(config *Config) (*Ethereum, error) {
// Boostrap database
- logger := ethlogger.New(config.DataDir, config.LogFile, config.LogLevel, config.LogFormat)
+ ethlogger := logger.New(config.DataDir, config.LogFile, config.LogLevel, config.LogFormat)
db, err := ethdb.NewLDBDatabase("blockchain")
if err != nil {
return nil, err
@@ -176,7 +176,7 @@ func New(config *Config) (*Ethereum, error) {
keyManager: keyManager,
blacklist: p2p.NewBlacklist(),
eventMux: &event.TypeMux{},
- logger: logger,
+ logger: ethlogger,
}
eth.chainManager = core.NewChainManager(db, eth.EventMux())
@@ -220,7 +220,7 @@ func New(config *Config) (*Ethereum, error) {
}
func (s *Ethereum) KeyManager() *crypto.KeyManager { return s.keyManager }
-func (s *Ethereum) Logger() ethlogger.LogSystem { return s.logger }
+func (s *Ethereum) Logger() logger.LogSystem { return s.logger }
func (s *Ethereum) Name() string { return s.net.Name }
func (s *Ethereum) ChainManager() *core.ChainManager { return s.chainManager }
func (s *Ethereum) BlockProcessor() *core.BlockProcessor { return s.blockProcessor }
@@ -238,7 +238,7 @@ func (s *Ethereum) Coinbase() []byte { return nil } // TODO
// Start the ethereum
func (s *Ethereum) Start() error {
- jsonlogger.LogJson(&ethlogger.LogStarting{
+ jsonlogger.LogJson(&logger.LogStarting{
ClientString: s.net.Name,
ProtocolVersion: ProtocolVersion,
})
@@ -264,7 +264,7 @@ func (s *Ethereum) Start() error {
s.blockSub = s.eventMux.Subscribe(core.NewMinedBlockEvent{})
go s.blockBroadcastLoop()
- logger.Infoln("Server started")
+ ethlogger.Infoln("Server started")
return nil
}
@@ -299,7 +299,7 @@ func (s *Ethereum) Stop() {
s.whisper.Stop()
}
- logger.Infoln("Server stopped")
+ ethlogger.Infoln("Server stopped")
close(s.shutdownChan)
}
diff --git a/eth/protocol.go b/eth/protocol.go
index 67ed8f9e5..d394ba739 100644
--- a/eth/protocol.go
+++ b/eth/protocol.go
@@ -9,6 +9,7 @@ import (
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/errs"
"github.com/ethereum/go-ethereum/ethutil"
+ "github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/p2p"
"github.com/ethereum/go-ethereum/rlp"
)
@@ -165,6 +166,12 @@ func (self *ethProtocol) handle() error {
if err := msg.Decode(&txs); err != nil {
return self.protoError(ErrDecode, "msg %v: %v", msg, err)
}
+ for _, tx := range txs {
+ jsonlogger.LogJson(&logger.EthTxReceived{
+ TxHash: ethutil.Bytes2Hex(tx.Hash()),
+ RemoteId: self.peer.ID().String(),
+ })
+ }
self.txPool.AddTransactions(txs)
case GetBlockHashesMsg:
@@ -243,6 +250,15 @@ func (self *ethProtocol) handle() error {
return self.protoError(ErrDecode, "msg %v: %v", msg, err)
}
hash := request.Block.Hash()
+ _, chainHead, _ := self.chainManager.Status()
+
+ jsonlogger.LogJson(&logger.EthChainReceivedNewBlock{
+ BlockHash: ethutil.Bytes2Hex(hash),
+ BlockNumber: request.Block.Number(), // this surely must be zero
+ ChainHeadHash: ethutil.Bytes2Hex(chainHead),
+ BlockPrevHash: ethutil.Bytes2Hex(request.Block.ParentHash()),
+ RemoteId: self.peer.ID().String(),
+ })
// to simplify backend interface adding a new block
// uses AddPeer followed by AddBlock only if peer is the best peer
// (or selected as new best peer)
diff --git a/eth/protocol_test.go b/eth/protocol_test.go
index f499d033e..c4e3e9f1b 100644
--- a/eth/protocol_test.go
+++ b/eth/protocol_test.go
@@ -13,7 +13,6 @@ import (
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/errs"
"github.com/ethereum/go-ethereum/ethutil"
- ethlogger "github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/p2p"
"github.com/ethereum/go-ethereum/p2p/discover"
)