aboutsummaryrefslogtreecommitdiffstats
path: root/cmd
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2015-06-03 19:14:06 +0800
committerobscuren <geffobscura@gmail.com>2015-06-04 04:39:17 +0800
commit770a0e78396d66dc0b15a267891ed69be1414f52 (patch)
treefeb88a9ad7352bfb422bba11d6c066c9487575f0 /cmd
parentb26f5e0bb7e8922c80bc3513d1ebce2c99a081f5 (diff)
downloadgo-tangerine-770a0e78396d66dc0b15a267891ed69be1414f52.tar
go-tangerine-770a0e78396d66dc0b15a267891ed69be1414f52.tar.gz
go-tangerine-770a0e78396d66dc0b15a267891ed69be1414f52.tar.bz2
go-tangerine-770a0e78396d66dc0b15a267891ed69be1414f52.tar.lz
go-tangerine-770a0e78396d66dc0b15a267891ed69be1414f52.tar.xz
go-tangerine-770a0e78396d66dc0b15a267891ed69be1414f52.tar.zst
go-tangerine-770a0e78396d66dc0b15a267891ed69be1414f52.zip
wip
Diffstat (limited to 'cmd')
-rw-r--r--cmd/geth/admin.go68
1 files changed, 66 insertions, 2 deletions
diff --git a/cmd/geth/admin.go b/cmd/geth/admin.go
index 01de97ac2..13d10de32 100644
--- a/cmd/geth/admin.go
+++ b/cmd/geth/admin.go
@@ -78,6 +78,12 @@ func (js *jsre) adminBindings() {
miner.Set("stopAutoDAG", js.stopAutoDAG)
miner.Set("makeDAG", js.makeDAG)
+ admin.Set("txPool", struct{}{})
+ t, _ = admin.Get("txPool")
+ txPool := t.Object()
+ txPool.Set("pending", js.allPendingTransactions)
+ txPool.Set("queued", js.allQueuedTransactions)
+
admin.Set("debug", struct{}{})
t, _ = admin.Get("debug")
debug := t.Object()
@@ -89,6 +95,7 @@ func (js *jsre) adminBindings() {
debug.Set("setHead", js.setHead)
debug.Set("processBlock", js.debugBlock)
debug.Set("seedhash", js.seedHash)
+ debug.Set("insertBlock", js.insertBlockRlp)
// undocumented temporary
debug.Set("waitForBlocks", js.waitForBlocks)
}
@@ -140,6 +147,32 @@ func (js *jsre) seedHash(call otto.FunctionCall) otto.Value {
return otto.UndefinedValue()
}
+func (js *jsre) allPendingTransactions(call otto.FunctionCall) otto.Value {
+ txs := js.ethereum.TxPool().GetTransactions()
+
+ ltxs := make([]*tx, len(txs))
+ for i, tx := range txs {
+ // no need to check err
+ ltxs[i] = newTx(tx)
+ }
+
+ v, _ := call.Otto.ToValue(ltxs)
+ return v
+}
+
+func (js *jsre) allQueuedTransactions(call otto.FunctionCall) otto.Value {
+ txs := js.ethereum.TxPool().GetQueuedTransactions()
+
+ ltxs := make([]*tx, len(txs))
+ for i, tx := range txs {
+ // no need to check err
+ ltxs[i] = newTx(tx)
+ }
+
+ v, _ := call.Otto.ToValue(ltxs)
+ return v
+}
+
func (js *jsre) pendingTransactions(call otto.FunctionCall) otto.Value {
txs := js.ethereum.TxPool().GetTransactions()
@@ -237,16 +270,47 @@ func (js *jsre) debugBlock(call otto.FunctionCall) otto.Value {
return otto.UndefinedValue()
}
+ tstart := time.Now()
+
old := vm.Debug
vm.Debug = true
_, err = js.ethereum.BlockProcessor().RetryProcess(block)
if err != nil {
fmt.Println(err)
+ r, _ := call.Otto.ToValue(map[string]interface{}{"success": false, "time": time.Since(tstart).Seconds()})
+ return r
}
vm.Debug = old
- fmt.Println("ok")
- return otto.UndefinedValue()
+ r, _ := call.Otto.ToValue(map[string]interface{}{"success": true, "time": time.Since(tstart).Seconds()})
+ return r
+}
+
+func (js *jsre) insertBlockRlp(call otto.FunctionCall) otto.Value {
+ tstart := time.Now()
+
+ var block types.Block
+ if call.Argument(0).IsString() {
+ blockRlp, _ := call.Argument(0).ToString()
+ err := rlp.DecodeBytes(common.Hex2Bytes(blockRlp), &block)
+ if err != nil {
+ fmt.Println(err)
+ return otto.UndefinedValue()
+ }
+ }
+
+ old := vm.Debug
+ vm.Debug = true
+ _, err := js.ethereum.BlockProcessor().RetryProcess(&block)
+ if err != nil {
+ fmt.Println(err)
+ r, _ := call.Otto.ToValue(map[string]interface{}{"success": false, "time": time.Since(tstart).Seconds()})
+ return r
+ }
+ vm.Debug = old
+
+ r, _ := call.Otto.ToValue(map[string]interface{}{"success": true, "time": time.Since(tstart).Seconds()})
+ return r
}
func (js *jsre) setHead(call otto.FunctionCall) otto.Value {