From 01740695cda7fe27c53f0fa078732fa5a15a88a5 Mon Sep 17 00:00:00 2001 From: obscuren Date: Thu, 9 Jan 2014 16:19:44 +0100 Subject: [PATCH] moved db to dev console --- db_query_interface.go => dev_console.go | 30 +++++++++++++------------ 1 file changed, 16 insertions(+), 14 deletions(-) rename db_query_interface.go => dev_console.go (70%) diff --git a/db_query_interface.go b/dev_console.go similarity index 70% rename from db_query_interface.go rename to dev_console.go index ec1d7feb5..65166c0c1 100644 --- a/db_query_interface.go +++ b/dev_console.go @@ -9,19 +9,19 @@ import ( "encoding/hex" ) -type DbInterface struct { +type Console struct { db *MemDatabase trie *Trie } -func NewDBInterface() *DbInterface { +func NewConsole() *Console { db, _ := NewMemDatabase() trie := NewTrie(db, "") - return &DbInterface{db: db, trie: trie} + return &Console{db: db, trie: trie} } -func (i *DbInterface) ValidateInput(action string, argumentLength int) error { +func (i *Console) 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 *DbInterface) ParseInput(input string) bool { +func (i *Console) 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"+ + "\033[1m= DB =\033[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"+ + "\033[1m= Dagger =\033[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 *DbInterface) Start() { - fmt.Printf("DB Query tool. Type (help) for help\n") +func (i *Console) 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)