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
4bf0d11e
Unverified
Commit
4bf0d11e
authored
Apr 05, 2019
by
Péter Szilágyi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
trie: there's no point in retrieving the metaroot
parent
ee376f67
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
0 deletions
+38
-0
database.go
trie/database.go
+5
-0
database_test.go
trie/database_test.go
+33
-0
No files found.
trie/database.go
View file @
4bf0d11e
...
@@ -18,6 +18,7 @@ package trie
...
@@ -18,6 +18,7 @@ package trie
import
(
import
(
"encoding/binary"
"encoding/binary"
"errors"
"fmt"
"fmt"
"io"
"io"
"sync"
"sync"
...
@@ -400,6 +401,10 @@ func (db *Database) node(hash common.Hash) node {
...
@@ -400,6 +401,10 @@ func (db *Database) node(hash common.Hash) node {
// Node retrieves an encoded cached trie node from memory. If it cannot be found
// Node retrieves an encoded cached trie node from memory. If it cannot be found
// cached, the method queries the persistent database for the content.
// cached, the method queries the persistent database for the content.
func
(
db
*
Database
)
Node
(
hash
common
.
Hash
)
([]
byte
,
error
)
{
func
(
db
*
Database
)
Node
(
hash
common
.
Hash
)
([]
byte
,
error
)
{
// It doens't make sense to retrieve the metaroot
if
hash
==
(
common
.
Hash
{})
{
return
nil
,
errors
.
New
(
"not found"
)
}
// Retrieve the node from the clean cache if available
// Retrieve the node from the clean cache if available
if
db
.
cleans
!=
nil
{
if
db
.
cleans
!=
nil
{
if
enc
,
err
:=
db
.
cleans
.
Get
(
string
(
hash
[
:
]));
err
==
nil
&&
enc
!=
nil
{
if
enc
,
err
:=
db
.
cleans
.
Get
(
string
(
hash
[
:
]));
err
==
nil
&&
enc
!=
nil
{
...
...
trie/database_test.go
0 → 100644
View file @
4bf0d11e
// Copyright 2019 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
// The go-ethereum library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// The go-ethereum library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
package
trie
import
(
"testing"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/ethdb/memorydb"
)
// Tests that the trie database returns a missing trie node error if attempting
// to retrieve the meta root.
func
TestDatabaseMetarootFetch
(
t
*
testing
.
T
)
{
db
:=
NewDatabase
(
memorydb
.
New
())
if
_
,
err
:=
db
.
Node
(
common
.
Hash
{});
err
==
nil
{
t
.
Fatalf
(
"metaroot retrieval succeeded"
)
}
}
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