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
92ffc1cc
Commit
92ffc1cc
authored
10 years ago
by
obscuren
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'release/0.6.0' into develop
parents
702cf5a3
54f9ea14
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
31 deletions
+41
-31
vm.go
ethvm/vm.go
+16
-27
peer.go
peer.go
+25
-4
No files found.
ethvm/vm.go
View file @
92ffc1cc
...
...
@@ -282,20 +282,15 @@ func (self *Vm) RunClosure(closure *Closure) (ret []byte, err error) {
case
SDIV
:
require
(
2
)
x
,
y
:=
stack
.
Popn
()
// n > 2**255
if
x
.
Cmp
(
Pow256
)
>
0
{
x
.
Sub
(
Pow256
,
x
)
}
if
y
.
Cmp
(
Pow256
)
>
0
{
y
.
Sub
(
Pow256
,
y
)
}
z
:=
new
(
big
.
Int
)
z
.
Div
(
x
,
y
)
if
z
.
Cmp
(
Pow256
)
>
0
{
z
.
Sub
(
Pow256
,
z
)
self
.
Printf
(
" %v / %v"
,
y
,
x
)
if
x
.
Cmp
(
ethutil
.
Big0
)
!=
0
{
base
.
Div
(
y
,
x
)
}
// Push result on to the stack
stack
.
Push
(
z
)
self
.
Printf
(
" = %v"
,
base
)
// Pop result back on the stack
stack
.
Push
(
base
)
case
MOD
:
require
(
2
)
x
,
y
:=
stack
.
Popn
()
...
...
@@ -309,20 +304,14 @@ func (self *Vm) RunClosure(closure *Closure) (ret []byte, err error) {
case
SMOD
:
require
(
2
)
x
,
y
:=
stack
.
Popn
()
// n > 2**255
if
x
.
Cmp
(
Pow256
)
>
0
{
x
.
Sub
(
Pow256
,
x
)
}
if
y
.
Cmp
(
Pow256
)
>
0
{
y
.
Sub
(
Pow256
,
y
)
}
z
:=
new
(
big
.
Int
)
z
.
Mod
(
x
,
y
)
if
z
.
Cmp
(
Pow256
)
>
0
{
z
.
Sub
(
Pow256
,
z
)
}
// Push result on to the stack
stack
.
Push
(
z
)
self
.
Printf
(
" %v %% %v"
,
y
,
x
)
base
.
Mod
(
y
,
x
)
self
.
Printf
(
" = %v"
,
base
)
stack
.
Push
(
base
)
case
EXP
:
require
(
2
)
x
,
y
:=
stack
.
Popn
()
...
...
This diff is collapsed.
Click to expand it.
peer.go
View file @
92ffc1cc
...
...
@@ -121,7 +121,8 @@ type Peer struct {
versionKnown
bool
// Last received pong message
lastPong
int64
lastPong
int64
lastBlockReceived
time
.
Time
host
[]
byte
port
uint16
...
...
@@ -408,10 +409,7 @@ func (p *Peer) HandleInbound() {
for
i
:=
msg
.
Data
.
Len
()
-
1
;
i
>=
0
;
i
--
{
block
=
ethchain
.
NewBlockFromRlpValue
(
msg
.
Data
.
Get
(
i
))
//p.ethereum.StateManager().PrepareDefault(block)
//state := p.ethereum.StateManager().CurrentState()
err
=
p
.
ethereum
.
StateManager
()
.
Process
(
block
,
false
)
if
err
!=
nil
{
if
ethutil
.
Config
.
Debug
{
peerlogger
.
Infof
(
"Block %x failed
\n
"
,
block
.
Hash
())
...
...
@@ -422,6 +420,8 @@ func (p *Peer) HandleInbound() {
}
else
{
lastBlock
=
block
}
p
.
lastBlockReceived
=
time
.
Now
()
}
if
msg
.
Data
.
Len
()
<=
1
{
...
...
@@ -561,6 +561,25 @@ func (p *Peer) HandleInbound() {
p
.
Stop
()
}
// General update method
func
(
self
*
Peer
)
update
()
{
serviceTimer
:=
time
.
NewTicker
(
5
*
time
.
Second
)
out
:
for
{
select
{
case
<-
serviceTimer
.
C
:
if
time
.
Since
(
self
.
lastBlockReceived
)
>
10
*
time
.
Second
{
self
.
catchingUp
=
false
}
case
<-
self
.
quit
:
break
out
}
}
serviceTimer
.
Stop
()
}
func
(
p
*
Peer
)
Start
()
{
peerHost
,
peerPort
,
_
:=
net
.
SplitHostPort
(
p
.
conn
.
LocalAddr
()
.
String
())
servHost
,
servPort
,
_
:=
net
.
SplitHostPort
(
p
.
conn
.
RemoteAddr
()
.
String
())
...
...
@@ -583,6 +602,8 @@ func (p *Peer) Start() {
go
p
.
HandleOutbound
()
// Run the inbound handler in a new goroutine
go
p
.
HandleInbound
()
// Run the general update handler
go
p
.
update
()
// Wait a few seconds for startup and then ask for an initial ping
time
.
Sleep
(
2
*
time
.
Second
)
...
...
This diff is collapsed.
Click to expand it.
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