diff options
author | obscuren <geffobscura@gmail.com> | 2014-01-15 04:48:16 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2014-01-15 04:48:16 +0800 |
commit | 44900e363cbc81b640bc16bcc7e6a50c22352be4 (patch) | |
tree | cf7ce2273bc493ec0757d1d445f9bb1aa9024ae3 /dev_console.go | |
parent | 578b63e2b8a32122fb45f9f053503e51d9a5c535 (diff) | |
download | dexon-44900e363cbc81b640bc16bcc7e6a50c22352be4.tar dexon-44900e363cbc81b640bc16bcc7e6a50c22352be4.tar.gz dexon-44900e363cbc81b640bc16bcc7e6a50c22352be4.tar.bz2 dexon-44900e363cbc81b640bc16bcc7e6a50c22352be4.tar.lz dexon-44900e363cbc81b640bc16bcc7e6a50c22352be4.tar.xz dexon-44900e363cbc81b640bc16bcc7e6a50c22352be4.tar.zst dexon-44900e363cbc81b640bc16bcc7e6a50c22352be4.zip |
Updated to temporary trie
Diffstat (limited to 'dev_console.go')
-rw-r--r-- | dev_console.go | 36 |
1 files changed, 30 insertions, 6 deletions
diff --git a/dev_console.go b/dev_console.go index 923c483c2..228cfc47e 100644 --- a/dev_console.go +++ b/dev_console.go @@ -37,6 +37,12 @@ func (i *Console) ValidateInput(action string, argumentLength int) error { case action == "dag" && argumentLength != 2: err = true expArgCount = 2 + case action == "decode" && argumentLength != 1: + err = true + expArgCount = 1 + case action == "encode" && argumentLength != 1: + err = true + expArgCount = 1 } if err { @@ -46,6 +52,15 @@ func (i *Console) ValidateInput(action string, argumentLength int) error { } } +func (i *Console) PrintRoot() { + root := ethutil.Conv(i.trie.RootT) + if len(root.AsBytes()) != 0 { + fmt.Println(hex.EncodeToString(root.AsBytes())) + } else { + fmt.Println(i.trie.RootT) + } +} + func (i *Console) ParseInput(input string) bool { scanner := bufio.NewScanner(strings.NewReader(input)) scanner.Split(bufio.ScanWords) @@ -70,21 +85,26 @@ func (i *Console) ParseInput(input string) bool { } else { switch tokens[0] { case "update": - i.trie.Update(tokens[1], tokens[2]) + i.trie.UpdateT(tokens[1], tokens[2]) - fmt.Println(hex.EncodeToString([]byte(i.trie.Root))) + i.PrintRoot() case "get": - fmt.Println(i.trie.Get(tokens[1])) + fmt.Println(i.trie.GetT(tokens[1])) case "root": - fmt.Println(hex.EncodeToString([]byte(i.trie.Root))) + i.PrintRoot() case "rawroot": - fmt.Println(i.trie.Root) + fmt.Println(i.trie.RootT) case "print": i.db.Print() case "dag": fmt.Println(DaggerVerify(ethutil.Big(tokens[1]), // hash ethutil.BigPow(2, 36), // diff ethutil.Big(tokens[2]))) // nonce + case "decode": + d, _ := ethutil.Decode([]byte(tokens[1]), 0) + fmt.Printf("%q\n", d) + case "encode": + fmt.Printf("%q\n", ethutil.Encode(tokens[1])) case "exit", "quit", "q": return false case "help": @@ -95,7 +115,11 @@ func (i *Console) ParseInput(input string) bool { "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") + "dag HASH NONCE - Verifies a nonce with the given hash with dagger\n" + + "\033[1m= Enroding =\033[0m\n" + + "decode STR\n" + + "encode STR\n") + default: fmt.Println("Unknown command:", tokens[0]) } |