aboutsummaryrefslogtreecommitdiffstats
path: root/rpc/writer.go
blob: 4cc39f577053a8d7bab71349ef200ad73fe4b16b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
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
    }
}
*/