Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nebula
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
exchain
nebula
Commits
d976350f
Unverified
Commit
d976350f
authored
May 10, 2023
by
mergify[bot]
Committed by
GitHub
May 10, 2023
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'develop' into refcell/safecall/send
parents
c9a6ab95
1a5c727c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
0 deletions
+22
-0
node.go
op-node/node/node.go
+9
-0
node_test.go
op-node/node/node_test.go
+13
-0
No files found.
op-node/node/node.go
View file @
d976350f
...
...
@@ -378,12 +378,21 @@ func (n *OpNode) RequestL2Range(ctx context.Context, start, end eth.L2BlockRef)
return
n
.
rpcSync
.
RequestL2Range
(
ctx
,
start
,
end
)
}
if
n
.
p2pNode
!=
nil
&&
n
.
p2pNode
.
AltSyncEnabled
()
{
if
unixTimeStale
(
start
.
Time
,
12
*
time
.
Hour
)
{
n
.
log
.
Debug
(
"ignoring request to sync L2 range, timestamp is too old for p2p"
,
"start"
,
start
,
"end"
,
end
,
"start_time"
,
start
.
Time
)
return
nil
}
return
n
.
p2pNode
.
RequestL2Range
(
ctx
,
start
,
end
)
}
n
.
log
.
Debug
(
"ignoring request to sync L2 range, no sync method available"
,
"start"
,
start
,
"end"
,
end
)
return
nil
}
// unixTimeStale returns true if the unix timestamp is before the current time minus the supplied duration.
func
unixTimeStale
(
timestamp
uint64
,
duration
time
.
Duration
)
bool
{
return
time
.
Unix
(
int64
(
timestamp
),
0
)
.
Before
(
time
.
Now
()
.
Add
(
-
1
*
duration
))
}
func
(
n
*
OpNode
)
P2P
()
p2p
.
Node
{
return
n
.
p2pNode
}
...
...
op-node/node/node_test.go
0 → 100644
View file @
d976350f
package
node
import
(
"testing"
"time"
"github.com/stretchr/testify/require"
)
func
TestUnixTimeStale
(
t
*
testing
.
T
)
{
require
.
True
(
t
,
unixTimeStale
(
1
_600_000_000
,
1
*
time
.
Hour
))
require
.
False
(
t
,
unixTimeStale
(
uint64
(
time
.
Now
()
.
Unix
()),
1
*
time
.
Hour
))
}
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