good morning!!!!
Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
bor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
open
bor
Commits
73b9ae95
Commit
73b9ae95
authored
Feb 22, 2014
by
Jeffrey Wilcke
Browse files
Options
Downloads
Patches
Plain Diff
Updated some of the log statements to use the ethutil logger
parent
4bfd717b
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
ethchain/block_chain.go
+0
-2
0 additions, 2 deletions
ethchain/block_chain.go
ethereum.go
+8
-8
8 additions, 8 deletions
ethereum.go
peer.go
+14
-16
14 additions, 16 deletions
peer.go
with
22 additions
and
26 deletions
ethchain/block_chain.go
+
0
−
2
View file @
73b9ae95
...
...
@@ -2,7 +2,6 @@ package ethchain
import
(
"bytes"
"fmt"
"github.com/ethereum/eth-go/ethutil"
"log"
"math"
...
...
@@ -119,7 +118,6 @@ func (bc *BlockChain) GetChain(hash []byte, amount int) []*Block {
var
blocks
[]
*
Block
for
i
:=
0
;
i
<
amount
&&
block
!=
nil
;
block
=
bc
.
GetBlock
(
block
.
PrevHash
)
{
fmt
.
Println
(
block
)
blocks
=
append
([]
*
Block
{
block
},
blocks
...
)
if
bytes
.
Compare
(
genHash
,
block
.
Hash
())
==
0
{
...
...
This diff is collapsed.
Click to expand it.
ethereum.go
+
8
−
8
View file @
73b9ae95
...
...
@@ -70,7 +70,7 @@ func New(caps Caps, usePnp bool) (*Ethereum, error) {
if
usePnp
{
nat
,
err
=
Discover
()
if
err
!=
nil
{
log
.
Print
ln
(
"UPnP failed"
,
err
)
ethutil
.
Config
.
Log
.
Debug
ln
(
"UPnP failed"
,
err
)
}
}
...
...
@@ -234,7 +234,7 @@ func (s *Ethereum) Start() {
log
.
Println
(
"Connection listening disabled. Acting as client"
)
}
else
{
// Starting accepting connections
log
.
Print
ln
(
"Ready and accepting connections"
)
ethutil
.
Config
.
Log
.
Info
ln
(
"Ready and accepting connections"
)
// Start the peer handler
go
s
.
peerHandler
(
ln
)
}
...
...
@@ -250,7 +250,7 @@ func (s *Ethereum) Start() {
s
.
TxPool
.
Start
()
if
ethutil
.
Config
.
Seed
{
log
.
Print
ln
(
"Seeding"
)
ethutil
.
Config
.
Log
.
Debug
ln
(
"Seeding"
)
// Testnet seed bootstrapping
resp
,
err
:=
http
.
Get
(
"http://www.ethereum.org/servers.poc3.txt"
)
if
err
!=
nil
{
...
...
@@ -272,7 +272,7 @@ func (s *Ethereum) peerHandler(listener net.Listener) {
for
{
conn
,
err
:=
listener
.
Accept
()
if
err
!=
nil
{
log
.
Print
ln
(
err
)
ethutil
.
Config
.
Log
.
Debug
ln
(
err
)
continue
}
...
...
@@ -315,13 +315,13 @@ out:
var
err
error
_
,
err
=
s
.
nat
.
AddPortMapping
(
"TCP"
,
int
(
lport
),
int
(
lport
),
"eth listen port"
,
20
*
60
)
if
err
!=
nil
{
log
.
Print
ln
(
"can't add UPnP port mapping:"
,
err
)
ethutil
.
Config
.
Log
.
Debug
ln
(
"can't add UPnP port mapping:"
,
err
)
break
out
}
if
first
&&
err
==
nil
{
_
,
err
=
s
.
nat
.
GetExternalAddress
()
if
err
!=
nil
{
log
.
Print
ln
(
"UPnP can't get external address:"
,
err
)
ethutil
.
Config
.
Log
.
Debug
ln
(
"UPnP can't get external address:"
,
err
)
continue
out
}
first
=
false
...
...
@@ -335,8 +335,8 @@ out:
timer
.
Stop
()
if
err
:=
s
.
nat
.
DeletePortMapping
(
"TCP"
,
int
(
lport
),
int
(
lport
));
err
!=
nil
{
log
.
Print
ln
(
"unable to remove UPnP port mapping:"
,
err
)
ethutil
.
Config
.
Log
.
Debug
ln
(
"unable to remove UPnP port mapping:"
,
err
)
}
else
{
log
.
Print
ln
(
"succesfully disestablished UPnP port mapping"
)
ethutil
.
Config
.
Log
.
Debug
ln
(
"succesfully disestablished UPnP port mapping"
)
}
}
This diff is collapsed.
Click to expand it.
peer.go
+
14
−
16
View file @
73b9ae95
...
...
@@ -6,7 +6,6 @@ import (
"github.com/ethereum/eth-go/ethchain"
"github.com/ethereum/eth-go/ethutil"
"github.com/ethereum/eth-go/ethwire"
"log"
"net"
"runtime"
"strconv"
...
...
@@ -165,7 +164,7 @@ func NewOutboundPeer(addr string, ethereum *Ethereum, caps Caps) *Peer {
conn
,
err
:=
net
.
DialTimeout
(
"tcp"
,
addr
,
30
*
time
.
Second
)
if
err
!=
nil
{
log
.
Print
ln
(
"Connection to peer failed"
,
err
)
ethutil
.
Config
.
Log
.
Debug
ln
(
"Connection to peer failed"
,
err
)
p
.
Stop
()
return
}
...
...
@@ -202,7 +201,7 @@ func (p *Peer) writeMessage(msg *ethwire.Msg) {
err
:=
ethwire
.
WriteMessage
(
p
.
conn
,
msg
)
if
err
!=
nil
{
log
.
Print
ln
(
"Can't send message:"
,
err
)
ethutil
.
Config
.
Log
.
Debug
ln
(
"Can't send message:"
,
err
)
// Stop the client if there was an error writing to it
p
.
Stop
()
return
...
...
@@ -264,7 +263,7 @@ func (p *Peer) HandleInbound() {
// Wait for a message from the peer
msgs
,
err
:=
ethwire
.
ReadMessages
(
p
.
conn
)
if
err
!=
nil
{
log
.
Print
ln
(
err
)
ethutil
.
Config
.
Log
.
Debug
ln
(
err
)
}
for
_
,
msg
:=
range
msgs
{
switch
msg
.
Type
{
...
...
@@ -277,7 +276,7 @@ func (p *Peer) HandleInbound() {
}
case
ethwire
.
MsgDiscTy
:
p
.
Stop
()
log
.
Print
ln
(
"Disconnect peer:"
,
DiscReason
(
msg
.
Data
.
Get
(
0
)
.
Uint
()))
ethutil
.
Config
.
Log
.
Info
ln
(
"Disconnect peer:"
,
DiscReason
(
msg
.
Data
.
Get
(
0
)
.
Uint
()))
case
ethwire
.
MsgPingTy
:
// Respond back with pong
p
.
QueueMessage
(
ethwire
.
NewMessage
(
ethwire
.
MsgPongTy
,
""
))
...
...
@@ -296,9 +295,8 @@ func (p *Peer) HandleInbound() {
if
err
!=
nil
{
if
ethutil
.
Config
.
Debug
{
log
.
Printf
(
"[PEER] Block %x failed
\n
"
,
block
.
Hash
())
log
.
Printf
(
"[PEER] %v
\n
"
,
err
)
log
.
Println
(
block
)
ethutil
.
Config
.
Log
.
Infof
(
"[PEER] Block %x failed
\n
"
,
block
.
Hash
())
ethutil
.
Config
.
Log
.
Infof
(
"[PEER] %v
\n
"
,
err
)
}
break
}
else
{
...
...
@@ -309,7 +307,7 @@ func (p *Peer) HandleInbound() {
if
err
!=
nil
{
// If the parent is unknown try to catch up with this peer
if
ethchain
.
IsParentErr
(
err
)
{
log
.
Print
ln
(
"Attempting to catch up"
)
ethutil
.
Config
.
Log
.
Info
ln
(
"Attempting to catch up"
)
p
.
catchingUp
=
false
p
.
CatchupWithPeer
()
}
else
if
ethchain
.
IsValidationErr
(
err
)
{
...
...
@@ -321,7 +319,7 @@ func (p *Peer) HandleInbound() {
if
p
.
catchingUp
&&
msg
.
Data
.
Len
()
>
1
{
if
ethutil
.
Config
.
Debug
&&
lastBlock
!=
nil
{
blockInfo
:=
lastBlock
.
BlockInfo
()
log
.
Print
f
(
"Synced to block height #%d %x %x
\n
"
,
blockInfo
.
Number
,
lastBlock
.
Hash
(),
blockInfo
.
Hash
)
ethutil
.
Config
.
Log
.
Info
f
(
"Synced to block height #%d %x %x
\n
"
,
blockInfo
.
Number
,
lastBlock
.
Hash
(),
blockInfo
.
Hash
)
}
p
.
catchingUp
=
false
p
.
CatchupWithPeer
()
...
...
@@ -392,12 +390,12 @@ func (p *Peer) HandleInbound() {
p
.
QueueMessage
(
ethwire
.
NewMessage
(
ethwire
.
MsgNotInChainTy
,
[]
interface
{}{
lastHash
.
Raw
()}))
}
case
ethwire
.
MsgNotInChainTy
:
log
.
Printf
(
"Not in chain %x
\n
"
,
msg
.
Data
)
ethutil
.
Config
.
Log
.
Infoln
(
"Not in chain %x
\n
"
,
msg
.
Data
)
// TODO
// Unofficial but fun nonetheless
case
ethwire
.
MsgTalkTy
:
log
.
Printf
(
"%v says: %s
\n
"
,
p
.
conn
.
RemoteAddr
(),
msg
.
Data
.
Str
())
ethutil
.
Config
.
Log
.
Infoln
(
"%v says: %s
\n
"
,
p
.
conn
.
RemoteAddr
(),
msg
.
Data
.
Str
())
}
}
}
...
...
@@ -440,7 +438,7 @@ func (p *Peer) Start() {
err
:=
p
.
pushHandshake
()
if
err
!=
nil
{
log
.
Print
ln
(
"Peer can't send outbound version ack"
,
err
)
ethutil
.
Config
.
Log
.
Debug
ln
(
"Peer can't send outbound version ack"
,
err
)
p
.
Stop
()
...
...
@@ -499,7 +497,7 @@ func (p *Peer) handleHandshake(msg *ethwire.Msg) {
c
:=
msg
.
Data
if
c
.
Get
(
0
)
.
Uint
()
!=
5
{
log
.
Print
ln
(
"Invalid peer version. Require protocol v
4
"
)
ethutil
.
Config
.
Log
.
Debug
ln
(
"Invalid peer version. Require protocol v
5
"
)
p
.
Stop
()
return
}
...
...
@@ -531,7 +529,7 @@ func (p *Peer) handleHandshake(msg *ethwire.Msg) {
// Get a reference to the peers version
p
.
Version
=
c
.
Get
(
2
)
.
Str
()
log
.
Print
ln
(
"[PEER]"
,
p
)
ethutil
.
Config
.
Log
.
Debug
ln
(
"[PEER]"
,
p
)
}
func
(
p
*
Peer
)
String
()
string
{
...
...
@@ -558,7 +556,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 %x...
\n
"
,
p
.
ethereum
.
BlockManager
.
BlockChain
()
.
CurrentBlock
.
Hash
()[
:
4
])
ethutil
.
Config
.
Log
.
Debugln
(
"Requesting blockchain %x...
\n
"
,
p
.
ethereum
.
BlockManager
.
BlockChain
()
.
CurrentBlock
.
Hash
()[
:
4
])
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment