aboutsummaryrefslogtreecommitdiffstats
path: root/rpc/writer.go
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-10-21 19:24:48 +0800
committerobscuren <geffobscura@gmail.com>2014-10-21 19:24:48 +0800
commit10b252dd0517175117d8d4a8ef30b3689a10eda5 (patch)
tree50c151da01936eb169d4ee6c3a1a717dfd9aabb1 /rpc/writer.go
parent097ba56df59293f9225a8ecdc9e1c43a5ad891bb (diff)
downloaddexon-10b252dd0517175117d8d4a8ef30b3689a10eda5.tar
dexon-10b252dd0517175117d8d4a8ef30b3689a10eda5.tar.gz
dexon-10b252dd0517175117d8d4a8ef30b3689a10eda5.tar.bz2
dexon-10b252dd0517175117d8d4a8ef30b3689a10eda5.tar.lz
dexon-10b252dd0517175117d8d4a8ef30b3689a10eda5.tar.xz
dexon-10b252dd0517175117d8d4a8ef30b3689a10eda5.tar.zst
dexon-10b252dd0517175117d8d4a8ef30b3689a10eda5.zip
WIP RPC interface
Diffstat (limited to 'rpc/writer.go')
-rw-r--r--rpc/writer.go75
1 files changed, 75 insertions, 0 deletions
diff --git a/rpc/writer.go b/rpc/writer.go
new file mode 100644
index 000000000..4cc39f577
--- /dev/null
+++ b/rpc/writer.go
@@ -0,0 +1,75 @@
+package rpc
+
+/*
+func pack(id int, v ...interface{}) Message {
+ return Message{Data: v, Id: id}
+}
+
+func WriteOn(msg *Message, writer io.Writer) {
+ //msg := &Message{Seed: seed, Data: data}
+
+ switch msg.Call {
+ case "compile":
+ data := ethutil.NewValue(msg.Args)
+ bcode, err := ethutil.Compile(data.Get(0).Str(), false)
+ if err != nil {
+ JSON.Send(writer, pack(msg.Id, err.Error()))
+ }
+
+ code := ethutil.Bytes2Hex(bcode)
+
+ JSON.Send(writer, pack(msg.Id, code, nil))
+ case "block":
+ args := msg.Arguments()
+
+ block := pipe.BlockByNumber(int32(args.Get(0).Uint()))
+
+ JSON.Send(writer, pack(msg.Id, block))
+ case "transact":
+ if mp, ok := msg.Args[0].(map[string]interface{}); ok {
+ object := mapToTxParams(mp)
+ JSON.Send(
+ writer,
+ pack(msg.Id, args(pipe.Transact(object["from"], object["to"], object["value"], object["gas"], object["gasPrice"], object["data"]))),
+ )
+
+ }
+ case "coinbase":
+ JSON.Send(writer, pack(msg.Id, pipe.CoinBase(), msg.Seed))
+
+ case "listening":
+ JSON.Send(writer, pack(msg.Id, pipe.IsListening()))
+
+ case "mining":
+ JSON.Send(writer, pack(msg.Id, pipe.IsMining()))
+
+ case "peerCoint":
+ JSON.Send(writer, pack(msg.Id, pipe.PeerCount()))
+
+ case "countAt":
+ args := msg.Arguments()
+
+ JSON.Send(writer, pack(msg.Id, pipe.TxCountAt(args.Get(0).Str())))
+
+ case "codeAt":
+ args := msg.Arguments()
+
+ JSON.Send(writer, pack(msg.Id, len(pipe.CodeAt(args.Get(0).Str()))))
+
+ case "stateAt":
+ args := msg.Arguments()
+
+ JSON.Send(writer, pack(msg.Id, pipe.StorageAt(args.Get(0).Str(), args.Get(1).Str())))
+
+ case "balanceAt":
+ args := msg.Arguments()
+
+ JSON.Send(writer, pack(msg.Id, pipe.BalanceAt(args.Get(0).Str())))
+
+ case "newFilter":
+ case "newFilterString":
+ case "messages":
+ // TODO
+ }
+}
+*/