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
02905994
Unverified
Commit
02905994
authored
Jul 29, 2022
by
Seungbae Yu
Committed by
GitHub
Jul 29, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
all: use AbsTime.Add instead of conversion (#25417)
parent
9ad50801
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
11 additions
and
11 deletions
+11
-11
simclock.go
common/mclock/simclock.go
+2
-2
lazyqueue.go
common/prque/lazyqueue.go
+2
-2
distributor.go
les/distributor.go
+1
-1
control.go
les/flowcontrol/control.go
+1
-1
timeutils_test.go
les/utils/timeutils_test.go
+1
-1
balance.go
les/vflux/server/balance.go
+4
-4
No files found.
common/mclock/simclock.go
View file @
02905994
...
...
@@ -58,7 +58,7 @@ func (s *Simulated) Run(d time.Duration) {
s
.
mu
.
Lock
()
s
.
init
()
end
:=
s
.
now
+
AbsTime
(
d
)
end
:=
s
.
now
.
Add
(
d
)
var
do
[]
func
()
for
len
(
s
.
scheduled
)
>
0
&&
s
.
scheduled
[
0
]
.
at
<=
end
{
ev
:=
heap
.
Pop
(
&
s
.
scheduled
)
.
(
*
simTimer
)
...
...
@@ -134,7 +134,7 @@ func (s *Simulated) AfterFunc(d time.Duration, fn func()) Timer {
func
(
s
*
Simulated
)
schedule
(
d
time
.
Duration
,
fn
func
())
*
simTimer
{
s
.
init
()
at
:=
s
.
now
+
AbsTime
(
d
)
at
:=
s
.
now
.
Add
(
d
)
ev
:=
&
simTimer
{
do
:
fn
,
at
:
at
,
s
:
s
}
heap
.
Push
(
&
s
.
scheduled
,
ev
)
s
.
cond
.
Broadcast
()
...
...
common/prque/lazyqueue.go
View file @
02905994
...
...
@@ -87,13 +87,13 @@ func (q *LazyQueue) Refresh() {
// refresh re-evaluates items in the older queue and swaps the two queues
func
(
q
*
LazyQueue
)
refresh
(
now
mclock
.
AbsTime
)
{
q
.
maxUntil
=
now
+
mclock
.
AbsTime
(
q
.
period
)
q
.
maxUntil
=
now
.
Add
(
q
.
period
)
for
q
.
queue
[
0
]
.
Len
()
!=
0
{
q
.
Push
(
heap
.
Pop
(
q
.
queue
[
0
])
.
(
*
item
)
.
value
)
}
q
.
queue
[
0
],
q
.
queue
[
1
]
=
q
.
queue
[
1
],
q
.
queue
[
0
]
q
.
indexOffset
=
1
-
q
.
indexOffset
q
.
maxUntil
+=
mclock
.
AbsTime
(
q
.
period
)
q
.
maxUntil
=
q
.
maxUntil
.
Add
(
q
.
period
)
}
// Push adds an item to the queue
...
...
les/distributor.go
View file @
02905994
...
...
@@ -256,7 +256,7 @@ func (d *requestDistributor) queue(r *distReq) chan distPeer {
if
r
.
reqOrder
==
0
{
d
.
lastReqOrder
++
r
.
reqOrder
=
d
.
lastReqOrder
r
.
waitForPeers
=
d
.
clock
.
Now
()
+
mclock
.
AbsTime
(
waitForPeers
)
r
.
waitForPeers
=
d
.
clock
.
Now
()
.
Add
(
waitForPeers
)
}
// Assign the timestamp when the request is queued no matter it's
// a new one or re-queued one.
...
...
les/flowcontrol/control.go
View file @
02905994
...
...
@@ -182,7 +182,7 @@ func (node *ClientNode) UpdateParams(params ServerParams) {
return
}
}
node
.
updateSchedule
=
append
(
node
.
updateSchedule
,
scheduledUpdate
{
time
:
now
+
mclock
.
AbsTime
(
DecParamDelay
),
params
:
params
})
node
.
updateSchedule
=
append
(
node
.
updateSchedule
,
scheduledUpdate
{
time
:
now
.
Add
(
DecParamDelay
),
params
:
params
})
}
}
...
...
les/utils/timeutils_test.go
View file @
02905994
...
...
@@ -37,7 +37,7 @@ func TestUpdateTimer(t *testing.T) {
if
updated
:=
timer
.
Update
(
func
(
diff
time
.
Duration
)
bool
{
return
true
});
!
updated
{
t
.
Fatalf
(
"Doesn't update the clock when reaching the threshold"
)
}
if
updated
:=
timer
.
UpdateAt
(
sim
.
Now
()
+
mclock
.
AbsTime
(
time
.
Second
),
func
(
diff
time
.
Duration
)
bool
{
return
true
});
!
updated
{
if
updated
:=
timer
.
UpdateAt
(
sim
.
Now
()
.
Add
(
time
.
Second
),
func
(
diff
time
.
Duration
)
bool
{
return
true
});
!
updated
{
t
.
Fatalf
(
"Doesn't update the clock when reaching the threshold"
)
}
timer
=
NewUpdateTimer
(
sim
,
0
)
...
...
les/vflux/server/balance.go
View file @
02905994
...
...
@@ -356,7 +356,7 @@ func (n *nodeBalance) estimatePriority(capacity uint64, addBalance int64, future
b
=
n
.
reducedBalance
(
b
,
now
,
future
,
capacity
,
avgReqCost
)
}
if
bias
>
0
{
b
=
n
.
reducedBalance
(
b
,
now
+
mclock
.
AbsTime
(
future
),
bias
,
capacity
,
0
)
b
=
n
.
reducedBalance
(
b
,
now
.
Add
(
future
),
bias
,
capacity
,
0
)
}
pri
:=
n
.
balanceToPriority
(
now
,
b
,
capacity
)
// Ensure that biased estimates are always lower than actual priorities, even if
...
...
@@ -512,7 +512,7 @@ func (n *nodeBalance) scheduleCheck(now mclock.AbsTime) {
n
.
updateAfter
(
0
)
return
}
if
n
.
nextUpdate
==
0
||
n
.
nextUpdate
>
now
+
mclock
.
AbsTime
(
d
)
{
if
n
.
nextUpdate
==
0
||
n
.
nextUpdate
>
now
.
Add
(
d
)
{
if
d
>
time
.
Second
{
// Note: if the scheduled update is not in the very near future then we
// schedule the update a bit earlier. This way we do need to update a few
...
...
@@ -520,7 +520,7 @@ func (n *nodeBalance) scheduleCheck(now mclock.AbsTime) {
// brings the expected firing time a little bit closer.
d
=
((
d
-
time
.
Second
)
*
7
/
8
)
+
time
.
Second
}
n
.
nextUpdate
=
now
+
mclock
.
AbsTime
(
d
)
n
.
nextUpdate
=
now
.
Add
(
d
)
n
.
updateAfter
(
d
)
}
}
else
{
...
...
@@ -629,7 +629,7 @@ func (n *nodeBalance) reducedBalance(b balance, start mclock.AbsTime, dt time.Du
// since the costs are applied continuously during the dt time period we calculate
// the expiration offset at the middle of the period
var
(
at
=
start
+
mclock
.
AbsTime
(
dt
/
2
)
at
=
start
.
Add
(
dt
/
2
)
dtf
=
float64
(
dt
)
)
if
!
b
.
pos
.
IsZero
()
{
...
...
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