good morning!!!!
Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
bor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
open
bor
Commits
01740695
Commit
01740695
authored
Jan 9, 2014
by
Jeffrey Wilcke
Browse files
Options
Downloads
Patches
Plain Diff
moved db to dev console
parent
d895f831
Branches
Branches containing commit
Tags
v0.0.34
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
dev_console.go
+16
-14
16 additions, 14 deletions
dev_console.go
with
16 additions
and
14 deletions
d
b_query_interfac
e.go
→
d
ev_consol
e.go
+
16
−
14
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 to
ol. Type (help) for help
\n
"
)
func
(
i
*
Consol
e
)
Start
()
{
fmt
.
Printf
(
"
Eth Cons
ol
e
. 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
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment