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 2010c13b4c99e2b4d934ff4473c1431956a6d99d..1fdfd1282a1d9e8aa4674302dac257e7aa3d43f6 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/vm/types.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/vm/types.go @@ -32,6 +32,13 @@ type Log struct { Height int64 } +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 bb17c2a7c72c3c58d9dadbe7177ec345ea6bace4..0397f078970993d55cd2ad9905b732a07353e740 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/vm/vm.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/vm/vm.go @@ -696,6 +696,21 @@ func (vm *VM) call(caller, callee *Account, code, input []byte, value int64, gas 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 22c080442772e9c9bed12b11318698d0adc53c3e..50000cc6cd00224b2cc0916e5a3faf23f9e25f93 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 7a96ba9447696029722ab4e281349d9e174233fa..c248bfdd196a219892046160d62a76b6ef086fba 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,7 +57,12 @@ func (this *transactor) Call(address, data []byte) (*Call, error) { } vmach := vm.NewVM(txCache, params, caller.Address, nil) +<<<<<<< HEAD gas := int64(1000000000) +======= + vmach.SetFireable(this.eventSwitch) + gas := uint64(1000000000) +>>>>>>> master ret, err := vmach.Call(caller, callee, callee.Code, data, 0, &gas) if err != nil { return nil, err diff --git a/erisdb/pipe/types.go b/erisdb/pipe/types.go index d74271289896c716a0402439c7882c40ed64f5da..cf9abc437633d9abc2823617446c49add02444f9 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