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
01740695
Commit
01740695
authored
Jan 09, 2014
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
moved db to dev console
parent
d895f831
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
14 deletions
+16
-14
dev_console.go
dev_console.go
+16
-14
No files found.
d
b_query_interfac
e.go
→
d
ev_consol
e.go
View file @
01740695
...
...
@@ -9,19 +9,19 @@ import (
"encoding/hex"
)
type
DbInterfac
e
struct
{
type
Consol
e
struct
{
db
*
MemDatabase
trie
*
Trie
}
func
New
DBInterface
()
*
DbInterfac
e
{
func
New
Console
()
*
Consol
e
{
db
,
_
:=
NewMemDatabase
()
trie
:=
NewTrie
(
db
,
""
)
return
&
DbInterfac
e
{
db
:
db
,
trie
:
trie
}
return
&
Consol
e
{
db
:
db
,
trie
:
trie
}
}
func
(
i
*
DbInterfac
e
)
ValidateInput
(
action
string
,
argumentLength
int
)
error
{
func
(
i
*
Consol
e
)
ValidateInput
(
action
string
,
argumentLength
int
)
error
{
err
:=
false
var
expArgCount
int
...
...
@@ -44,7 +44,7 @@ func (i *DbInterface) ValidateInput(action string, argumentLength int) error {
}
}
func
(
i
*
DbInterfac
e
)
ParseInput
(
input
string
)
bool
{
func
(
i
*
Consol
e
)
ParseInput
(
input
string
)
bool
{
scanner
:=
bufio
.
NewScanner
(
strings
.
NewReader
(
input
))
scanner
.
Split
(
bufio
.
ScanWords
)
...
...
@@ -82,12 +82,14 @@ func (i *DbInterface) ParseInput(input string) bool {
case
"exit"
,
"quit"
,
"q"
:
return
false
case
"help"
:
fmt
.
Printf
(
`QUERY COMMANDS:
update KEY VALUE - Updates/Creates a new value for the given key
get KEY - Retrieves the given key
root - Prints the hex encoded merkle root
rawroot - Prints the raw merkle root
`
)
fmt
.
Printf
(
"COMMANDS:
\n
"
+
"
\0
33[1m= DB =
\0
33[0m
\n
"
+
"update KEY VALUE - Updates/Creates a new value for the given key
\n
"
+
"get KEY - Retrieves the given key
\n
"
+
"root - Prints the hex encoded merkle root
\n
"
+
"rawroot - Prints the raw merkle root
\n
"
+
"
\0
33[1m= Dagger =
\0
33[0m
\n
"
+
"dag HASH NONCE - Verifies a nonce with the given hash with dagger
\n
"
)
default
:
fmt
.
Println
(
"Unknown command:"
,
tokens
[
0
])
}
...
...
@@ -96,11 +98,11 @@ rawroot - Prints the raw merkle root
return
true
}
func
(
i
*
DbInterfac
e
)
Start
()
{
fmt
.
Printf
(
"
DB Query tool
. Type (help) for help
\n
"
)
func
(
i
*
Consol
e
)
Start
()
{
fmt
.
Printf
(
"
Eth Console
. Type (help) for help
\n
"
)
reader
:=
bufio
.
NewReader
(
os
.
Stdin
)
for
{
fmt
.
Printf
(
"
db
>>> "
)
fmt
.
Printf
(
"
eth
>>> "
)
str
,
_
,
err
:=
reader
.
ReadLine
()
if
err
!=
nil
{
fmt
.
Println
(
"Error reading input"
,
err
)
...
...
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