aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-02-10 18:36:49 +0800
committerobscuren <geffobscura@gmail.com>2014-02-10 18:36:49 +0800
commitd2edc2bbf4641f3ca2ccf33e9014892d342ad021 (patch)
tree118b8e3c2c284b170a3c01da9357801f115817d3
parent8db7d791f0cee0fdcf574a9bcf34467dc00e313e (diff)
downloaddexon-d2edc2bbf4641f3ca2ccf33e9014892d342ad021.tar
dexon-d2edc2bbf4641f3ca2ccf33e9014892d342ad021.tar.gz
dexon-d2edc2bbf4641f3ca2ccf33e9014892d342ad021.tar.bz2
dexon-d2edc2bbf4641f3ca2ccf33e9014892d342ad021.tar.lz
dexon-d2edc2bbf4641f3ca2ccf33e9014892d342ad021.tar.xz
dexon-d2edc2bbf4641f3ca2ccf33e9014892d342ad021.tar.zst
dexon-d2edc2bbf4641f3ca2ccf33e9014892d342ad021.zip
Added some loggers
-rw-r--r--peer.go24
1 files changed, 16 insertions, 8 deletions
diff --git a/peer.go b/peer.go
index 6c2d6c8b5..e7be3bcb0 100644
--- a/peer.go
+++ b/peer.go
@@ -26,14 +26,20 @@ const (
DiscBadProto = 0x02
DiscBadPeer = 0x03
DiscTooManyPeers = 0x04
+ DiscConnDup = 0x05
+ DiscGenesisErr = 0x06
+ DiscProtoErr = 0x07
)
var discReasonToString = []string{
"Disconnect requested",
"Disconnect TCP sys error",
- "Disconnect Bad protocol",
- "Disconnect Useless peer",
- "Disconnect Too many peers",
+ "Disconnect bad protocol",
+ "Disconnect useless peer",
+ "Disconnect too many peers",
+ "Disconnect already connected",
+ "Disconnect wrong genesis block",
+ "Disconnect incompatible network",
}
func (d DiscReason) String() string {
@@ -241,7 +247,6 @@ clean:
// Inbound handler. Inbound messages are received here and passed to the appropriate methods
func (p *Peer) HandleInbound() {
-out:
for atomic.LoadInt32(&p.disconnect) == 0 {
// HMM?
time.Sleep(500 * time.Millisecond)
@@ -250,8 +255,6 @@ out:
msgs, err := ethwire.ReadMessages(p.conn)
if err != nil {
log.Println(err)
-
- break out
}
for _, msg := range msgs {
switch msg.Type {
@@ -276,9 +279,10 @@ out:
case ethwire.MsgBlockTy:
// Get all blocks and process them
msg.Data = msg.Data
+ var block *ethchain.Block
for i := msg.Data.Length() - 1; i >= 0; i-- {
// FIXME
- block := ethchain.NewBlockFromRlpValue(ethutil.NewValue(msg.Data.Get(i).AsRaw()))
+ block = ethchain.NewBlockFromRlpValue(ethutil.NewValue(msg.Data.Get(i).AsRaw()))
err := p.ethereum.BlockManager.ProcessBlock(block)
if err != nil {
@@ -288,6 +292,10 @@ out:
// If we're catching up, try to catch up further.
if p.catchingUp && msg.Data.Length() > 1 {
+ if ethutil.Config.Debug {
+ blockInfo := p.ethereum.BlockManager.BlockChain().BlockInfo(block)
+ log.Printf("Synced to block height #%d\n", blockInfo.Number)
+ }
p.catchingUp = false
p.CatchupWithPeer()
}
@@ -500,7 +508,7 @@ func (p *Peer) CatchupWithPeer() {
msg := ethwire.NewMessage(ethwire.MsgGetChainTy, []interface{}{p.ethereum.BlockManager.BlockChain().CurrentBlock.Hash(), uint64(50)})
p.QueueMessage(msg)
- log.Printf("Requesting blockchain up from %x\n", p.ethereum.BlockManager.BlockChain().CurrentBlock.Hash())
+ log.Printf("Requesting blockchain %x...\n", p.ethereum.BlockManager.BlockChain().CurrentBlock.Hash()[:4])
}
}