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
6b3e6cb2
Unverified
Commit
6b3e6cb2
authored
Jun 07, 2022
by
aaronbuchwald
Committed by
GitHub
Jun 07, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
trie: move locking into trieDB insert method (#25030)
Move locking into trieDB insert function
parent
096daa9a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
3 additions
and
4 deletions
+3
-4
committer.go
trie/committer.go
+0
-4
database.go
trie/database.go
+3
-0
No files found.
trie/committer.go
View file @
6b3e6cb2
...
@@ -193,9 +193,7 @@ func (c *committer) store(n node, db *Database) node {
...
@@ -193,9 +193,7 @@ func (c *committer) store(n node, db *Database) node {
}
else
if
db
!=
nil
{
}
else
if
db
!=
nil
{
// No leaf-callback used, but there's still a database. Do serial
// No leaf-callback used, but there's still a database. Do serial
// insertion
// insertion
db
.
lock
.
Lock
()
db
.
insert
(
common
.
BytesToHash
(
hash
),
size
,
n
)
db
.
insert
(
common
.
BytesToHash
(
hash
),
size
,
n
)
db
.
lock
.
Unlock
()
}
}
return
hash
return
hash
}
}
...
@@ -209,9 +207,7 @@ func (c *committer) commitLoop(db *Database) {
...
@@ -209,9 +207,7 @@ func (c *committer) commitLoop(db *Database) {
n
=
item
.
node
n
=
item
.
node
)
)
// We are pooling the trie nodes into an intermediate memory cache
// We are pooling the trie nodes into an intermediate memory cache
db
.
lock
.
Lock
()
db
.
insert
(
hash
,
size
,
n
)
db
.
insert
(
hash
,
size
,
n
)
db
.
lock
.
Unlock
()
if
c
.
onleaf
!=
nil
{
if
c
.
onleaf
!=
nil
{
switch
n
:=
n
.
(
type
)
{
switch
n
:=
n
.
(
type
)
{
...
...
trie/database.go
View file @
6b3e6cb2
...
@@ -310,6 +310,9 @@ func (db *Database) DiskDB() ethdb.KeyValueStore {
...
@@ -310,6 +310,9 @@ func (db *Database) DiskDB() ethdb.KeyValueStore {
// All nodes inserted by this function will be reference tracked
// All nodes inserted by this function will be reference tracked
// and in theory should only used for **trie nodes** insertion.
// and in theory should only used for **trie nodes** insertion.
func
(
db
*
Database
)
insert
(
hash
common
.
Hash
,
size
int
,
node
node
)
{
func
(
db
*
Database
)
insert
(
hash
common
.
Hash
,
size
int
,
node
node
)
{
db
.
lock
.
Lock
()
defer
db
.
lock
.
Unlock
()
// If the node's already cached, skip
// If the node's already cached, skip
if
_
,
ok
:=
db
.
dirties
[
hash
];
ok
{
if
_
,
ok
:=
db
.
dirties
[
hash
];
ok
{
return
return
...
...
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