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
8ab6c532
Commit
8ab6c532
authored
Feb 10, 2014
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reversed back
parent
1d26ae2d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
14 deletions
+15
-14
ethereum.go
ethereum.go
+2
-2
peer.go
peer.go
+13
-12
No files found.
ethereum.go
View file @
8ab6c532
...
@@ -58,8 +58,8 @@ type Ethereum struct {
...
@@ -58,8 +58,8 @@ type Ethereum struct {
}
}
func
New
(
caps
Caps
,
usePnp
bool
)
(
*
Ethereum
,
error
)
{
func
New
(
caps
Caps
,
usePnp
bool
)
(
*
Ethereum
,
error
)
{
db
,
err
:=
ethdb
.
NewLDBDatabase
()
//
db, err := ethdb.NewLDBDatabase()
//
db, err := ethdb.NewMemDatabase()
db
,
err
:=
ethdb
.
NewMemDatabase
()
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
...
...
peer.go
View file @
8ab6c532
package
eth
package
eth
import
(
import
(
"bytes"
_
"bytes"
"fmt"
"fmt"
"github.com/ethereum/ethchain-go"
"github.com/ethereum/ethchain-go"
"github.com/ethereum/ethutil-go"
"github.com/ethereum/ethutil-go"
...
@@ -139,8 +139,6 @@ func NewPeer(conn net.Conn, ethereum *Ethereum, inbound bool) *Peer {
...
@@ -139,8 +139,6 @@ func NewPeer(conn net.Conn, ethereum *Ethereum, inbound bool) *Peer {
}
}
func
NewOutboundPeer
(
addr
string
,
ethereum
*
Ethereum
,
caps
Caps
)
*
Peer
{
func
NewOutboundPeer
(
addr
string
,
ethereum
*
Ethereum
,
caps
Caps
)
*
Peer
{
data
,
_
:=
ethutil
.
Config
.
Db
.
Get
([]
byte
(
"KeyRing"
))
pubkey
:=
ethutil
.
NewValueFromBytes
(
data
)
.
Get
(
2
)
.
Bytes
()
p
:=
&
Peer
{
p
:=
&
Peer
{
outputQueue
:
make
(
chan
*
ethwire
.
Msg
,
outputBufferSize
),
outputQueue
:
make
(
chan
*
ethwire
.
Msg
,
outputBufferSize
),
...
@@ -150,7 +148,6 @@ func NewOutboundPeer(addr string, ethereum *Ethereum, caps Caps) *Peer {
...
@@ -150,7 +148,6 @@ func NewOutboundPeer(addr string, ethereum *Ethereum, caps Caps) *Peer {
connected
:
0
,
connected
:
0
,
disconnect
:
0
,
disconnect
:
0
,
caps
:
caps
,
caps
:
caps
,
pubkey
:
pubkey
,
}
}
// 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
...
@@ -283,7 +280,6 @@ func (p *Peer) HandleInbound() {
...
@@ -283,7 +280,6 @@ func (p *Peer) HandleInbound() {
msg
.
Data
=
msg
.
Data
msg
.
Data
=
msg
.
Data
var
block
*
ethchain
.
Block
var
block
*
ethchain
.
Block
for
i
:=
msg
.
Data
.
Length
()
-
1
;
i
>=
0
;
i
--
{
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
)
err
:=
p
.
ethereum
.
BlockManager
.
ProcessBlock
(
block
)
...
@@ -440,9 +436,12 @@ func (p *Peer) Stop() {
...
@@ -440,9 +436,12 @@ func (p *Peer) Stop() {
}
}
func
(
p
*
Peer
)
pushHandshake
()
error
{
func
(
p
*
Peer
)
pushHandshake
()
error
{
data
,
_
:=
ethutil
.
Config
.
Db
.
Get
([]
byte
(
"KeyRing"
))
pubkey
:=
ethutil
.
NewValueFromBytes
(
data
)
.
Get
(
2
)
.
Bytes
()
clientId
:=
fmt
.
Sprintf
(
"/Ethereum(G) v%s/%s"
,
ethutil
.
Config
.
Ver
,
runtime
.
GOOS
)
clientId
:=
fmt
.
Sprintf
(
"/Ethereum(G) v%s/%s"
,
ethutil
.
Config
.
Ver
,
runtime
.
GOOS
)
msg
:=
ethwire
.
NewMessage
(
ethwire
.
MsgHandshakeTy
,
[]
interface
{}{
msg
:=
ethwire
.
NewMessage
(
ethwire
.
MsgHandshakeTy
,
[]
interface
{}{
uint32
(
3
),
uint32
(
0
),
clientId
,
byte
(
p
.
caps
),
p
.
port
,
p
.
p
ubkey
,
uint32
(
3
),
uint32
(
0
),
clientId
,
byte
(
p
.
caps
),
p
.
port
,
pubkey
,
})
})
p
.
QueueMessage
(
msg
)
p
.
QueueMessage
(
msg
)
...
@@ -485,13 +484,15 @@ func (p *Peer) handleHandshake(msg *ethwire.Msg) {
...
@@ -485,13 +484,15 @@ func (p *Peer) handleHandshake(msg *ethwire.Msg) {
p
.
port
=
uint16
(
c
.
Get
(
4
)
.
AsUint
())
p
.
port
=
uint16
(
c
.
Get
(
4
)
.
AsUint
())
// Self connect detection
// Self connect detection
data
,
_
:=
ethutil
.
Config
.
Db
.
Get
([]
byte
(
"KeyRing"
))
/*
pubkey
:=
ethutil
.
NewValueFromBytes
(
data
)
.
Get
(
2
)
.
Bytes
()
data, _ := ethutil.Config.Db.Get([]byte("KeyRing"))
if
bytes
.
Compare
(
pubkey
,
p
.
pubkey
)
==
0
{
pubkey := ethutil.NewValueFromBytes(data).Get(2).Bytes()
p
.
Stop
()
if bytes.Compare(pubkey, p.pubkey) == 0 {
p.Stop()
return
return
}
}
*/
istr
=
"inbound"
istr
=
"inbound"
}
else
{
}
else
{
...
...
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