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
4de3ad17
Commit
4de3ad17
authored
Oct 08, 2014
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
New block message
parent
9d86a49a
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
23 additions
and
10 deletions
+23
-10
block_pool.go
block_pool.go
+17
-6
ethereum.go
ethereum.go
+2
-2
js_pipe.go
ethpipe/js_pipe.go
+0
-2
messaging.go
ethwire/messaging.go
+1
-0
peer.go
peer.go
+3
-0
No files found.
block_pool.go
View file @
4de3ad17
...
...
@@ -124,6 +124,14 @@ func (self *BlockPool) AddHash(hash []byte, peer *Peer) {
}
func
(
self
*
BlockPool
)
Add
(
b
*
ethchain
.
Block
,
peer
*
Peer
)
{
self
.
addBlock
(
b
,
peer
,
false
)
}
func
(
self
*
BlockPool
)
AddNew
(
b
*
ethchain
.
Block
,
peer
*
Peer
)
{
self
.
addBlock
(
b
,
peer
,
true
)
}
func
(
self
*
BlockPool
)
addBlock
(
b
*
ethchain
.
Block
,
peer
*
Peer
,
newBlock
bool
)
{
self
.
mut
.
Lock
()
defer
self
.
mut
.
Unlock
()
...
...
@@ -135,12 +143,15 @@ func (self *BlockPool) Add(b *ethchain.Block, peer *Peer) {
self
.
hashes
=
append
(
self
.
hashes
,
b
.
Hash
())
self
.
pool
[
hash
]
=
&
block
{
peer
,
peer
,
b
,
time
.
Now
(),
0
}
fmt
.
Println
(
"1."
,
!
self
.
eth
.
BlockChain
()
.
HasBlock
(
b
.
PrevHash
),
ethutil
.
Bytes2Hex
(
b
.
Hash
()[
0
:
4
]),
ethutil
.
Bytes2Hex
(
b
.
PrevHash
[
0
:
4
]))
fmt
.
Println
(
"2."
,
self
.
pool
[
string
(
b
.
PrevHash
)]
==
nil
)
fmt
.
Println
(
"3."
,
!
self
.
fetchingHashes
)
if
!
self
.
eth
.
BlockChain
()
.
HasBlock
(
b
.
PrevHash
)
&&
self
.
pool
[
string
(
b
.
PrevHash
)]
==
nil
&&
!
self
.
fetchingHashes
{
poollogger
.
Infof
(
"Unknown chain, requesting (%x...)
\n
"
,
b
.
PrevHash
[
0
:
4
])
peer
.
QueueMessage
(
ethwire
.
NewMessage
(
ethwire
.
MsgGetBlockHashesTy
,
[]
interface
{}{
b
.
Hash
(),
uint32
(
256
)}))
// The following is only performed on an unrequested new block
if
newBlock
{
fmt
.
Println
(
"1."
,
!
self
.
eth
.
BlockChain
()
.
HasBlock
(
b
.
PrevHash
),
ethutil
.
Bytes2Hex
(
b
.
Hash
()[
0
:
4
]),
ethutil
.
Bytes2Hex
(
b
.
PrevHash
[
0
:
4
]))
fmt
.
Println
(
"2."
,
self
.
pool
[
string
(
b
.
PrevHash
)]
==
nil
)
fmt
.
Println
(
"3."
,
!
self
.
fetchingHashes
)
if
!
self
.
eth
.
BlockChain
()
.
HasBlock
(
b
.
PrevHash
)
&&
self
.
pool
[
string
(
b
.
PrevHash
)]
==
nil
&&
!
self
.
fetchingHashes
{
poollogger
.
Infof
(
"Unknown chain, requesting (%x...)
\n
"
,
b
.
PrevHash
[
0
:
4
])
peer
.
QueueMessage
(
ethwire
.
NewMessage
(
ethwire
.
MsgGetBlockHashesTy
,
[]
interface
{}{
b
.
Hash
(),
uint32
(
256
)}))
}
}
}
else
if
self
.
pool
[
hash
]
!=
nil
{
self
.
pool
[
hash
]
.
block
=
b
...
...
ethereum.go
View file @
4de3ad17
...
...
@@ -385,7 +385,7 @@ func (s *Ethereum) RemovePeer(p *Peer) {
})
}
func
(
s
*
Ethereum
)
R
eapDeadPeerHandler
()
{
func
(
s
*
Ethereum
)
r
eapDeadPeerHandler
()
{
reapTimer
:=
time
.
NewTicker
(
processReapingTimeout
*
time
.
Second
)
for
{
...
...
@@ -420,7 +420,7 @@ func (s *Ethereum) Start(seed bool) {
}
// Start the reaping processes
go
s
.
R
eapDeadPeerHandler
()
go
s
.
r
eapDeadPeerHandler
()
go
s
.
update
()
go
s
.
filterLoop
()
...
...
ethpipe/js_pipe.go
View file @
4de3ad17
...
...
@@ -3,7 +3,6 @@ package ethpipe
import
(
"bytes"
"encoding/json"
"fmt"
"sync/atomic"
"github.com/ethereum/eth-go/ethchain"
...
...
@@ -93,7 +92,6 @@ func (self *JSPipe) NumberToHuman(balance string) string {
}
func
(
self
*
JSPipe
)
StorageAt
(
addr
,
storageAddr
string
)
string
{
fmt
.
Println
(
"get"
,
addr
,
storageAddr
)
storage
:=
self
.
World
()
.
SafeGet
(
ethutil
.
Hex2Bytes
(
addr
))
.
Storage
(
ethutil
.
Hex2Bytes
(
storageAddr
))
return
ethutil
.
Bytes2Hex
(
storage
.
Bytes
())
...
...
ethwire/messaging.go
View file @
4de3ad17
...
...
@@ -40,6 +40,7 @@ const (
MsgBlockHashesTy
=
0x14
MsgGetBlocksTy
=
0x15
MsgBlockTy
=
0x16
MsgNewBlockTy
=
0x17
)
var
msgTypeToString
=
map
[
MsgType
]
string
{
...
...
peer.go
View file @
4de3ad17
...
...
@@ -538,7 +538,10 @@ func (p *Peer) HandleInbound() {
p
.
lastBlockReceived
=
time
.
Now
()
}
case
ethwire
.
MsgNewBlockTy
:
p
.
ethereum
.
blockPool
.
AddNew
(
ethchain
.
NewBlockFromRlpValue
(
msg
.
Data
),
p
)
}
}
}
}
...
...
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