Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
884f7928
Commit
884f7928
authored
Jan 27, 2014
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Removed default connection
parent
7931c662
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
6 deletions
+34
-6
ethereum.go
ethereum.go
+7
-5
peer.go
peer.go
+27
-1
No files found.
ethereum.go
View file @
884f7928
...
@@ -152,12 +152,14 @@ func (s *Ethereum) Start() {
...
@@ -152,12 +152,14 @@ func (s *Ethereum) Start() {
if
ethutil
.
Config
.
Debug
{
if
ethutil
.
Config
.
Debug
{
log
.
Println
(
"Connection listening disabled. Acting as client"
)
log
.
Println
(
"Connection listening disabled. Acting as client"
)
err
=
s
.
ConnectToPeer
(
"localhost:12345"
)
/*
if
err
!=
nil
{
err = s.ConnectToPeer("localhost:12345")
log
.
Println
(
"Error starting ethereum"
,
err
)
if err != nil {
log.Println("Error starting ethereum", err)
s
.
Stop
()
s.Stop()
}
}
*/
}
else
{
}
else
{
log
.
Fatal
(
err
)
log
.
Fatal
(
err
)
}
}
...
...
peer.go
View file @
884f7928
...
@@ -68,9 +68,12 @@ func NewOutboundPeer(addr string, ethereum *Ethereum) *Peer {
...
@@ -68,9 +68,12 @@ func NewOutboundPeer(addr string, ethereum *Ethereum) *Peer {
// Set up the connection in another goroutine so we don't block the main thread
// Set up the connection in another goroutine so we don't block the main thread
go
func
()
{
go
func
()
{
conn
,
err
:=
net
.
Dial
(
"tcp"
,
addr
)
conn
,
err
:=
net
.
DialTimeout
(
"tcp"
,
addr
,
30
*
time
.
Second
)
if
err
!=
nil
{
if
err
!=
nil
{
log
.
Println
(
"Connection to peer failed"
,
err
)
p
.
Stop
()
p
.
Stop
()
return
}
}
p
.
conn
=
conn
p
.
conn
=
conn
...
@@ -211,7 +214,30 @@ out:
...
@@ -211,7 +214,30 @@ out:
p
.
requestedPeerList
=
false
p
.
requestedPeerList
=
false
}
}
case
ethwire
.
MsgGetChainTy
:
case
ethwire
.
MsgGetChainTy
:
blocksFound
:=
0
l
:=
msg
.
Data
.
Length
()
// Check each SHA block hash from the message and determine whether
// the SHA is in the database
for
i
:=
0
;
i
<
l
;
i
++
{
if
p
.
ethereum
.
BlockManager
.
BlockChain
()
.
HasBlock
(
msg
.
Data
.
Get
(
i
)
.
AsString
())
{
blocksFound
++
// TODO send reply
}
}
// If no blocks are found we send back a reply with msg not in chain
// and the last hash from get chain
if
blocksFound
==
0
{
lastHash
:=
msg
.
Data
.
Get
(
l
-
1
)
p
.
QueueMessage
(
ethwire
.
NewMessage
(
ethwire
.
MsgNotInChainTy
,
lastHash
))
}
case
ethwire
.
MsgNotInChainTy
:
log
.
Println
(
"Not in chain, not yet implemented"
)
// TODO
// Unofficial but fun nonetheless
case
ethwire
.
MsgTalkTy
:
log
.
Printf
(
"%v says: %s
\n
"
,
p
.
conn
.
RemoteAddr
(),
msg
.
Data
.
Get
(
0
)
.
AsString
())
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment