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
f3a93b04
Commit
f3a93b04
authored
Sep 17, 2014
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Upped protocol version for VM change
parent
b3834d82
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
110 additions
and
81 deletions
+110
-81
fees.go
ethchain/fees.go
+0
-2
trie.go
ethtrie/trie.go
+7
-0
vm.go
ethvm/vm.go
+1
-2
client_identity.go
ethwire/client_identity.go
+1
-1
peer.go
peer.go
+101
-76
No files found.
ethchain/fees.go
View file @
f3a93b04
...
...
@@ -5,5 +5,3 @@ import (
)
var
BlockReward
*
big
.
Int
=
big
.
NewInt
(
1.5e+18
)
var
UncleReward
*
big
.
Int
=
big
.
NewInt
(
1.125e+18
)
var
UncleInclusionReward
*
big
.
Int
=
big
.
NewInt
(
1.875e+17
)
ethtrie/trie.go
View file @
f3a93b04
...
...
@@ -92,6 +92,13 @@ func (cache *Cache) Get(key []byte) *ethutil.Value {
data
,
_
:=
cache
.
db
.
Get
(
key
)
// Create the cached value
value
:=
ethutil
.
NewValueFromBytes
(
data
)
defer
func
()
{
if
r
:=
recover
();
r
!=
nil
{
fmt
.
Println
(
"RECOVER GET"
,
cache
,
cache
.
nodes
)
panic
(
"bye"
)
}
}()
// Create caching node
cache
.
nodes
[
string
(
key
)]
=
NewNode
(
key
,
value
,
false
)
...
...
ethvm/vm.go
View file @
f3a93b04
...
...
@@ -872,8 +872,7 @@ func (self *Vm) RunClosure(closure *Closure) (ret []byte, err error) {
default
:
vmlogger
.
Debugf
(
"(pc) %-3v Invalid opcode %x
\n
"
,
pc
,
op
)
// XXX Really?
closure
.
UseGas
(
closure
.
Gas
)
//panic(fmt.Sprintf("Invalid opcode %x", op))
return
closure
.
Return
(
nil
),
fmt
.
Errorf
(
"Invalid opcode %x"
,
op
)
}
...
...
ethwire/client_identity.go
View file @
f3a93b04
...
...
@@ -24,7 +24,7 @@ func NewSimpleClientIdentity(clientIdentifier string, version string, customIden
version
:
version
,
customIdentifier
:
customIdentifier
,
os
:
runtime
.
GOOS
,
implementation
:
"Go"
,
implementation
:
runtime
.
Version
()
,
}
return
clientIdentity
...
...
peer.go
View file @
f3a93b04
...
...
@@ -24,9 +24,11 @@ const (
// The size of the output buffer for writing messages
outputBufferSize
=
50
// Current protocol version
ProtocolVersion
=
3
2
ProtocolVersion
=
3
3
// Current P2P version
P2PVersion
=
0
// Ethereum network version
NetVersion
=
0
// Interval for ping/pong message
pingPongTimer
=
2
*
time
.
Second
)
...
...
@@ -72,7 +74,7 @@ func (d DiscReason) String() string {
type
Caps
byte
const
(
CapPeerDiscTy
=
1
<<
iota
CapPeerDiscTy
Caps
=
1
<<
iota
CapTxTy
CapChainTy
...
...
@@ -309,6 +311,14 @@ out:
select
{
// Main message queue. All outbound messages are processed through here
case
msg
:=
<-
p
.
outputQueue
:
if
!
p
.
statusKnown
{
switch
msg
.
Type
{
case
ethwire
.
MsgGetTxsTy
,
ethwire
.
MsgGetBlockHashesTy
,
ethwire
.
MsgGetBlocksTy
,
ethwire
.
MsgBlockHashesTy
,
ethwire
.
MsgBlockTy
:
peerlogger
.
Debugln
(
"Blocked outgoing [eth] message to peer without the [eth] cap."
)
break
}
}
p
.
writeMessage
(
msg
)
p
.
lastSend
=
time
.
Now
()
...
...
@@ -435,100 +445,106 @@ func (p *Peer) HandleInbound() {
case
ethwire
.
MsgStatusTy
:
// Handle peer's status msg
p
.
handleStatus
(
msg
)
case
ethwire
.
MsgGetTxsTy
:
// Get the current transactions of the pool
txs
:=
p
.
ethereum
.
TxPool
()
.
CurrentTransactions
()
// Get the RlpData values from the txs
txsInterface
:=
make
([]
interface
{},
len
(
txs
))
for
i
,
tx
:=
range
txs
{
txsInterface
[
i
]
=
tx
.
RlpData
()
}
// Broadcast it back to the peer
p
.
QueueMessage
(
ethwire
.
NewMessage
(
ethwire
.
MsgTxTy
,
txsInterface
))
}
case
ethwire
.
MsgGetBlockHashesTy
:
if
msg
.
Data
.
Len
()
<
2
{
peerlogger
.
Debugln
(
"err: argument length invalid "
,
msg
.
Data
.
Len
())
}
// TMP
if
p
.
statusKnown
{
switch
msg
.
Type
{
case
ethwire
.
MsgGetTxsTy
:
// Get the current transactions of the pool
txs
:=
p
.
ethereum
.
TxPool
()
.
CurrentTransactions
()
// Get the RlpData values from the txs
txsInterface
:=
make
([]
interface
{},
len
(
txs
))
for
i
,
tx
:=
range
txs
{
txsInterface
[
i
]
=
tx
.
RlpData
()
}
// Broadcast it back to the peer
p
.
QueueMessage
(
ethwire
.
NewMessage
(
ethwire
.
MsgTxTy
,
txsInterface
))
case
ethwire
.
MsgGetBlockHashesTy
:
if
msg
.
Data
.
Len
()
<
2
{
peerlogger
.
Debugln
(
"err: argument length invalid "
,
msg
.
Data
.
Len
())
}
hash
:=
msg
.
Data
.
Get
(
0
)
.
Bytes
()
amount
:=
msg
.
Data
.
Get
(
1
)
.
Uint
()
hash
:=
msg
.
Data
.
Get
(
0
)
.
Bytes
()
amount
:=
msg
.
Data
.
Get
(
1
)
.
Uint
()
hashes
:=
p
.
ethereum
.
BlockChain
()
.
GetChainHashesFromHash
(
hash
,
amount
)
hashes
:=
p
.
ethereum
.
BlockChain
()
.
GetChainHashesFromHash
(
hash
,
amount
)
p
.
QueueMessage
(
ethwire
.
NewMessage
(
ethwire
.
MsgBlockHashesTy
,
ethutil
.
ByteSliceToInterface
(
hashes
)))
p
.
QueueMessage
(
ethwire
.
NewMessage
(
ethwire
.
MsgBlockHashesTy
,
ethutil
.
ByteSliceToInterface
(
hashes
)))
case
ethwire
.
MsgGetBlocksTy
:
// Limit to max 300 blocks
max
:=
int
(
math
.
Min
(
float64
(
msg
.
Data
.
Len
()),
300.0
))
var
blocks
[]
interface
{}
case
ethwire
.
MsgGetBlocksTy
:
// Limit to max 300 blocks
max
:=
int
(
math
.
Min
(
float64
(
msg
.
Data
.
Len
()),
300.0
))
var
blocks
[]
interface
{}
for
i
:=
0
;
i
<
max
;
i
++
{
hash
:=
msg
.
Data
.
Get
(
i
)
.
Bytes
()
block
:=
p
.
ethereum
.
BlockChain
()
.
GetBlock
(
hash
)
if
block
!=
nil
{
blocks
=
append
(
blocks
,
block
.
Value
()
.
Raw
())
for
i
:=
0
;
i
<
max
;
i
++
{
hash
:=
msg
.
Data
.
Get
(
i
)
.
Bytes
()
block
:=
p
.
ethereum
.
BlockChain
()
.
GetBlock
(
hash
)
if
block
!=
nil
{
blocks
=
append
(
blocks
,
block
.
Value
()
.
Raw
())
}
}
}
p
.
QueueMessage
(
ethwire
.
NewMessage
(
ethwire
.
MsgBlockTy
,
blocks
))
p
.
QueueMessage
(
ethwire
.
NewMessage
(
ethwire
.
MsgBlockTy
,
blocks
))
case
ethwire
.
MsgBlockHashesTy
:
p
.
catchingUp
=
true
case
ethwire
.
MsgBlockHashesTy
:
p
.
catchingUp
=
true
blockPool
:=
p
.
ethereum
.
blockPool
blockPool
:=
p
.
ethereum
.
blockPool
foundCommonHash
:=
false
foundCommonHash
:=
false
it
:=
msg
.
Data
.
NewIterator
()
for
it
.
Next
()
{
hash
:=
it
.
Value
()
.
Bytes
()
it
:=
msg
.
Data
.
NewIterator
()
for
it
.
Next
()
{
hash
:=
it
.
Value
()
.
Bytes
()
if
blockPool
.
HasCommonHash
(
hash
)
{
foundCommonHash
=
true
if
blockPool
.
HasCommonHash
(
hash
)
{
foundCommonHash
=
true
break
}
break
}
blockPool
.
AddHash
(
hash
)
blockPool
.
AddHash
(
hash
)
p
.
lastReceivedHash
=
hash
p
.
lastReceivedHash
=
hash
p
.
lastBlockReceived
=
time
.
Now
()
}
if
foundCommonHash
{
p
.
FetchBlocks
()
}
else
{
p
.
FetchHashes
()
}
p
.
lastBlockReceived
=
time
.
Now
()
}
case
ethwire
.
MsgBlockTy
:
p
.
catchingUp
=
true
if
foundCommonHash
{
p
.
FetchBlocks
()
}
else
{
p
.
FetchHashes
()
}
blockPool
:=
p
.
ethereum
.
blockPool
case
ethwire
.
MsgBlockTy
:
p
.
catchingUp
=
true
it
:=
msg
.
Data
.
NewIterator
()
for
it
.
Next
()
{
block
:=
ethchain
.
NewBlockFromRlpValue
(
it
.
Value
())
//fmt.Printf("%v %x - %x\n", block.Number, block.Hash()[0:4], block.PrevHash[0:4])
blockPool
:=
p
.
ethereum
.
blockPool
blockPool
.
SetBlock
(
block
,
p
)
it
:=
msg
.
Data
.
NewIterator
()
for
it
.
Next
()
{
block
:=
ethchain
.
NewBlockFromRlpValue
(
it
.
Value
())
//fmt.Printf("%v %x - %x\n", block.Number, block.Hash()[0:4], block.PrevHash[0:4])
p
.
lastBlockReceived
=
time
.
Now
()
}
blockPool
.
SetBlock
(
block
,
p
)
var
err
error
blockPool
.
CheckLinkAndProcess
(
func
(
block
*
ethchain
.
Block
)
{
err
=
p
.
ethereum
.
StateManager
()
.
Process
(
block
,
false
)
})
p
.
lastBlockReceived
=
time
.
Now
()
}
if
err
!=
nil
{
peerlogger
.
Infoln
(
err
)
}
else
{
// Don't trigger if there's just one block.
if
blockPool
.
Len
()
!=
0
&&
msg
.
Data
.
Len
()
>
1
{
p
.
FetchBlocks
()
var
err
error
blockPool
.
CheckLinkAndProcess
(
func
(
block
*
ethchain
.
Block
)
{
err
=
p
.
ethereum
.
StateManager
()
.
Process
(
block
,
false
)
})
if
err
!=
nil
{
peerlogger
.
Infoln
(
err
)
}
else
{
// Don't trigger if there's just one block.
if
blockPool
.
Len
()
!=
0
&&
msg
.
Data
.
Len
()
>
1
{
p
.
FetchBlocks
()
}
}
}
}
...
...
@@ -645,10 +661,9 @@ func (p *Peer) pushPeers() {
}
func
(
self
*
Peer
)
pushStatus
()
{
const
netVersion
=
0
msg
:=
ethwire
.
NewMessage
(
ethwire
.
MsgStatusTy
,
[]
interface
{}{
uint32
(
ProtocolVersion
),
uint32
(
n
etVersion
),
uint32
(
N
etVersion
),
self
.
ethereum
.
BlockChain
()
.
TD
,
self
.
ethereum
.
BlockChain
()
.
CurrentBlock
.
Hash
(),
self
.
ethereum
.
BlockChain
()
.
Genesis
()
.
Hash
(),
...
...
@@ -669,7 +684,17 @@ func (self *Peer) handleStatus(msg *ethwire.Msg) {
)
if
bytes
.
Compare
(
self
.
ethereum
.
BlockChain
()
.
Genesis
()
.
Hash
(),
genesis
)
!=
0
{
ethlogger
.
Warnf
(
"Invalid genisis hash %x. Disabling [ETH]
\n
"
,
genesis
)
ethlogger
.
Warnf
(
"Invalid genisis hash %x. Disabling [eth]
\n
"
,
genesis
)
return
}
if
netVersion
!=
NetVersion
{
ethlogger
.
Warnf
(
"Invalid network version %d. Disabling [eth]
\n
"
,
netVersion
)
return
}
if
protoVersion
!=
ProtocolVersion
{
ethlogger
.
Warnf
(
"Invalid protocol version %d. Disabling [eth]
\n
"
,
protoVersion
)
return
}
...
...
@@ -687,7 +712,7 @@ func (self *Peer) handleStatus(msg *ethwire.Msg) {
self
.
FetchHashes
()
}
ethlogger
.
Infof
(
"Peer is [
ETH
] capable. (TD = %v ~ %x) %d / %d"
,
self
.
td
,
self
.
bestHash
,
protoVersion
,
netVersion
)
ethlogger
.
Infof
(
"Peer is [
eth
] capable. (TD = %v ~ %x) %d / %d"
,
self
.
td
,
self
.
bestHash
,
protoVersion
,
netVersion
)
}
...
...
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