Added some loggers
This commit is contained in:
parent
8db7d791f0
commit
d2edc2bbf4
24
peer.go
24
peer.go
|
@ -26,14 +26,20 @@ const (
|
||||||
DiscBadProto = 0x02
|
DiscBadProto = 0x02
|
||||||
DiscBadPeer = 0x03
|
DiscBadPeer = 0x03
|
||||||
DiscTooManyPeers = 0x04
|
DiscTooManyPeers = 0x04
|
||||||
|
DiscConnDup = 0x05
|
||||||
|
DiscGenesisErr = 0x06
|
||||||
|
DiscProtoErr = 0x07
|
||||||
)
|
)
|
||||||
|
|
||||||
var discReasonToString = []string{
|
var discReasonToString = []string{
|
||||||
"Disconnect requested",
|
"Disconnect requested",
|
||||||
"Disconnect TCP sys error",
|
"Disconnect TCP sys error",
|
||||||
"Disconnect Bad protocol",
|
"Disconnect bad protocol",
|
||||||
"Disconnect Useless peer",
|
"Disconnect useless peer",
|
||||||
"Disconnect Too many peers",
|
"Disconnect too many peers",
|
||||||
|
"Disconnect already connected",
|
||||||
|
"Disconnect wrong genesis block",
|
||||||
|
"Disconnect incompatible network",
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d DiscReason) String() string {
|
func (d DiscReason) String() string {
|
||||||
|
@ -241,7 +247,6 @@ clean:
|
||||||
// Inbound handler. Inbound messages are received here and passed to the appropriate methods
|
// Inbound handler. Inbound messages are received here and passed to the appropriate methods
|
||||||
func (p *Peer) HandleInbound() {
|
func (p *Peer) HandleInbound() {
|
||||||
|
|
||||||
out:
|
|
||||||
for atomic.LoadInt32(&p.disconnect) == 0 {
|
for atomic.LoadInt32(&p.disconnect) == 0 {
|
||||||
// HMM?
|
// HMM?
|
||||||
time.Sleep(500 * time.Millisecond)
|
time.Sleep(500 * time.Millisecond)
|
||||||
|
@ -250,8 +255,6 @@ out:
|
||||||
msgs, err := ethwire.ReadMessages(p.conn)
|
msgs, err := ethwire.ReadMessages(p.conn)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println(err)
|
log.Println(err)
|
||||||
|
|
||||||
break out
|
|
||||||
}
|
}
|
||||||
for _, msg := range msgs {
|
for _, msg := range msgs {
|
||||||
switch msg.Type {
|
switch msg.Type {
|
||||||
|
@ -276,9 +279,10 @@ out:
|
||||||
case ethwire.MsgBlockTy:
|
case ethwire.MsgBlockTy:
|
||||||
// Get all blocks and process them
|
// Get all blocks and process them
|
||||||
msg.Data = msg.Data
|
msg.Data = msg.Data
|
||||||
|
var block *ethchain.Block
|
||||||
for i := msg.Data.Length() - 1; i >= 0; i-- {
|
for i := msg.Data.Length() - 1; i >= 0; i-- {
|
||||||
// FIXME
|
// 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)
|
err := p.ethereum.BlockManager.ProcessBlock(block)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -288,6 +292,10 @@ out:
|
||||||
|
|
||||||
// If we're catching up, try to catch up further.
|
// If we're catching up, try to catch up further.
|
||||||
if p.catchingUp && msg.Data.Length() > 1 {
|
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.catchingUp = false
|
||||||
p.CatchupWithPeer()
|
p.CatchupWithPeer()
|
||||||
}
|
}
|
||||||
|
@ -500,7 +508,7 @@ func (p *Peer) CatchupWithPeer() {
|
||||||
msg := ethwire.NewMessage(ethwire.MsgGetChainTy, []interface{}{p.ethereum.BlockManager.BlockChain().CurrentBlock.Hash(), uint64(50)})
|
msg := ethwire.NewMessage(ethwire.MsgGetChainTy, []interface{}{p.ethereum.BlockManager.BlockChain().CurrentBlock.Hash(), uint64(50)})
|
||||||
p.QueueMessage(msg)
|
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])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue