diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/vm/types.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/vm/types.go index 4aa0964b59efb68b312aae7b8d98b174fcfeee51..ed76fb2cb1dce54bcf028975576fd3f7d6e876b6 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/vm/types.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/vm/types.go @@ -29,6 +29,13 @@ type Log struct { Height uint64 } +type SolLog struct { + Address string `json:"address"` + Topics []string `json:"topics"` + Data string `json:"data"` + Height uint64 `json:"height"` +} + type AppState interface { // Accounts diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/vm/vm.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/vm/vm.go index abfd855251c4e10e68fd465ea6004b5b7e8a9013..70c7e902d67fd267a94b3a45637bc096899deec9 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/vm/vm.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/vm/vm.go @@ -655,6 +655,21 @@ func (vm *VM) call(caller, callee *Account, code, input []byte, value uint64, ga vm.params.BlockHeight, } vm.appState.AddLog(log) + if vm.evc != nil { + eventId := "Solidity/" + fmt.Sprintf("%X", callee.Address.Bytes()[12:]) + solLog := &SolLog{ + Address: fmt.Sprintf("%X",log.Address.Bytes()), + Data: fmt.Sprintf("%X", log.Data), + Height: log.Height} + solLog.Topics = []string{} + for _, ts := range log.Topics { + solLog.Topics = append(solLog.Topics, fmt.Sprintf("%X",ts.Bytes())) + } + vm.evc.FireEvent(eventId, solLog) + fmt.Println("***************************************************************") + fmt.Printf("%v\n", solLog) + fmt.Println("***************************************************************") + } dbg.Printf(" => %v\n", log) case CREATE: // 0xF0 diff --git a/api.md b/api.md index 368a4ed68b32bdd4b177f7a0011d7fa2a93d4d73..97305f32d8917039d14ec12034b7bad00152630a 100644 --- a/api.md +++ b/api.md @@ -2,7 +2,7 @@ ### for eris-db version 0.10.x -Eris DB allows remote access to its functionality over http and websocket. It currently supports JSON-RPC, and REST-like http. There is also javascript bindings available in the [erisdb-js](TODO) library. +Eris DB allows remote access to its functionality over http and websocket. It currently supports [JSON-RPC 2.0](http://www.jsonrpc.org/specification), and REST-like http. There is also javascript bindings available in the [erisdb-js](TODO) library. ## TOC @@ -24,6 +24,8 @@ The only data format supported is JSON. All post requests needs to use `Content- The default endpoints for JSON-RPC (2.0) is `/rpc` for http based, and `/socketrpc` for websocket. The namespace for the JSON-RPC service is `erisdb`. +It does not yet support notifications or batched requests. + ### Objects ##### Errors @@ -448,7 +450,6 @@ Event object: | [GetNetworkInfo](#get-network-info) | erisdb.getNetworkInfo | GET | `/network` | | [GetClientVersion](#get-client-version) | erisdb.getClientVersion | GET | `/network/client_version` | | [GetMoniker](#get-moniker) | erisdb.getMoniker | GET | `/network/moniker` | -| [GetChainId](#get-chain-id) | erisdb.getChainId | GET | `/network/chain_id` | | [IsListening](#is-listening) | erisdb.isListening | GET | `/network/listening` | | [GetListeners](#get-listeners) | erisdb.getListeners | GET | `/network/listeners` | | [GetPeers](#get-peers) | erisdb.getPeers | GET | `/network/peers` | diff --git a/erisdb/json_service.go b/erisdb/json_service.go index 887d270709e7269d68166bc9c1e690f0923e8640..d80255f97a1e4a751a019ad039d601ef31e952ba 100644 --- a/erisdb/json_service.go +++ b/erisdb/json_service.go @@ -171,7 +171,6 @@ func (this *ErisDbJsonService) EventPoll(request *rpc.RPCRequest, requester inte subId := param.SubId result, errC := this.eventSubs.poll(subId) - if errC != nil { return nil, rpc.INTERNAL_ERROR, errC } diff --git a/erisdb/methods.go b/erisdb/methods.go index 95871fb7af676050e98cdd8e64e6f267e0645de1..634869a4e376e0dd6a0d96bdabe353a2016cce21 100644 --- a/erisdb/methods.go +++ b/erisdb/methods.go @@ -10,9 +10,8 @@ import ( "strings" ) +// TODO use the method name definition file. const ( - // string used in subscriber ids. - ID = "socketrpc" SERVICE_NAME = "erisdb" GET_ACCOUNTS = SERVICE_NAME + ".getAccounts" // Accounts diff --git a/erisdb/pipe/pipe.go b/erisdb/pipe/pipe.go index c2a203a1556b624310e25d004e7133e2705c8f7f..c5ce929dc4882556de8d0801a0ffb2581c4f7ec1 100644 --- a/erisdb/pipe/pipe.go +++ b/erisdb/pipe/pipe.go @@ -86,7 +86,7 @@ func NewPipe(tNode *node.Node) Pipe { consensus := newConsensus(tNode.ConsensusState(), tNode.Switch()) events := newEvents(tNode.EventSwitch()) net := newNetwork(tNode.Switch()) - txs := newTransactor(tNode.ConsensusState(), tNode.MempoolReactor(), events) + txs := newTransactor(tNode.EventSwitch(), tNode.ConsensusState(), tNode.MempoolReactor(), events) return &PipeImpl{ tNode, accounts, diff --git a/erisdb/pipe/transactor.go b/erisdb/pipe/transactor.go index c97d328c4dc985bb2b39851bb3291c5f6a4f0d33..885d0a1ba0f5afcd21071ced1cc44eae40a13f2d 100644 --- a/erisdb/pipe/transactor.go +++ b/erisdb/pipe/transactor.go @@ -6,6 +6,7 @@ import ( "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/account" cmn "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/common" cs "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/consensus" + tEvents "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/events" mempl "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/mempool" "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/state" "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/types" @@ -19,13 +20,15 @@ const ( ) type transactor struct { + eventSwitch tEvents.Fireable consensusState *cs.ConsensusState mempoolReactor *mempl.MempoolReactor eventEmitter EventEmitter } -func newTransactor(consensusState *cs.ConsensusState, mempoolReactor *mempl.MempoolReactor, eventEmitter EventEmitter) *transactor { +func newTransactor(eventSwitch tEvents.Fireable, consensusState *cs.ConsensusState, mempoolReactor *mempl.MempoolReactor, eventEmitter EventEmitter) *transactor { txs := &transactor{ + eventSwitch, consensusState, mempoolReactor, eventEmitter, @@ -54,6 +57,7 @@ func (this *transactor) Call(address, data []byte) (*Call, error) { } vmach := vm.NewVM(txCache, params, caller.Address, nil) + vmach.SetFireable(this.eventSwitch) gas := uint64(1000000000) ret, err := vmach.Call(caller, callee, callee.Code, data, 0, &gas) if err != nil { diff --git a/erisdb/pipe/types.go b/erisdb/pipe/types.go index bf75a020ab7ed865cabdb92db4d6e644d0d0c8f2..4538cf85eecebc49f56423519e9e45065e381f79 100644 --- a/erisdb/pipe/types.go +++ b/erisdb/pipe/types.go @@ -166,4 +166,4 @@ func FromRoundState(rs *csus.RoundState) *ConsensusState { Validators: rs.Validators.Validators, } return cs -} +} \ No newline at end of file