mirror of
https://github.com/fluencelabs/tendermint
synced 2025-05-28 13:41:21 +00:00
Update README; Remove GetEvents() from Application
This commit is contained in:
parent
d319c5be0d
commit
201bf2374b
13
README.md
13
README.md
@ -38,8 +38,7 @@ TMSP is an asynchronous streaming protocol: message responses are written back a
|
||||
* __Arguments__:
|
||||
* `EventsMode (int8)`:
|
||||
* `EventsModeOff (0)`: Events are not reported. Used for mempool.
|
||||
* `EventsModeCached (1)`: Events are cached.
|
||||
* `EventsModeOn (2)`: Flush cache and report events.
|
||||
* `EventsModeOn (1)`: Report events that are listened on.
|
||||
* __Returns__:
|
||||
* `RetCode (int8)`
|
||||
* __Usage__:<br/>
|
||||
@ -61,3 +60,13 @@ TMSP is an asynchronous streaming protocol: message responses are written back a
|
||||
* __Usage__:<br/>
|
||||
Remove event listener callback for events with given key.
|
||||
|
||||
#### Flush
|
||||
* __Usage__:<br/>
|
||||
Flush the response queue. Applications that implement `types.Application` need not implement this message -- it's handled by the project.
|
||||
|
||||
#### Info
|
||||
* __Returns__:
|
||||
* `Data ([]string)`
|
||||
* __Usage__:<br/>
|
||||
Return an array of strings about the application state. Application specific.
|
||||
|
||||
|
@ -51,9 +51,9 @@ func (dapp *DummyApplication) Info() []string {
|
||||
return []string{Fmt("size:%v", dapp.state.Size())}
|
||||
}
|
||||
|
||||
func (dapp *DummyApplication) AppendTx(tx []byte) types.RetCode {
|
||||
func (dapp *DummyApplication) AppendTx(tx []byte) ([]types.Event, types.RetCode) {
|
||||
dapp.state.Set(tx, tx)
|
||||
return 0
|
||||
return nil, 0
|
||||
}
|
||||
|
||||
func (dapp *DummyApplication) GetHash() ([]byte, types.RetCode) {
|
||||
@ -82,7 +82,3 @@ func (dapp *DummyApplication) AddListener(key string) types.RetCode {
|
||||
func (dapp *DummyApplication) RemListener(key string) types.RetCode {
|
||||
return 0
|
||||
}
|
||||
|
||||
func (dapp *DummyApplication) GetEvents() []types.Event {
|
||||
return nil
|
||||
}
|
||||
|
@ -78,9 +78,8 @@ func handleRequest(app types.Application, req types.Request, responses chan<- ty
|
||||
data := app.Info()
|
||||
responses <- types.ResponseInfo{data}
|
||||
case types.RequestAppendTx:
|
||||
retCode := app.AppendTx(req.TxBytes)
|
||||
events, retCode := app.AppendTx(req.TxBytes)
|
||||
responses <- types.ResponseAppendTx{retCode}
|
||||
events := app.GetEvents()
|
||||
for _, event := range events {
|
||||
responses <- types.ResponseEvent{event}
|
||||
}
|
||||
@ -96,12 +95,6 @@ func handleRequest(app types.Application, req types.Request, responses chan<- ty
|
||||
case types.RequestSetEventsMode:
|
||||
retCode := app.SetEventsMode(req.EventsMode)
|
||||
responses <- types.ResponseSetEventsMode{retCode}
|
||||
if req.EventsMode == types.EventsModeOn {
|
||||
events := app.GetEvents()
|
||||
for _, event := range events {
|
||||
responses <- types.ResponseEvent{event}
|
||||
}
|
||||
}
|
||||
case types.RequestAddListener:
|
||||
retCode := app.AddListener(req.EventKey)
|
||||
responses <- types.ResponseAddListener{retCode}
|
||||
|
@ -9,7 +9,7 @@ type Application interface {
|
||||
Info() []string
|
||||
|
||||
// Append a tx, which may or may not get committed
|
||||
AppendTx(tx []byte) RetCode
|
||||
AppendTx(tx []byte) ([]Event, RetCode)
|
||||
|
||||
// Return the application Merkle root hash
|
||||
GetHash() ([]byte, RetCode)
|
||||
@ -28,7 +28,4 @@ type Application interface {
|
||||
|
||||
// Remove event listener
|
||||
RemListener(key string) RetCode
|
||||
|
||||
// Get all events
|
||||
GetEvents() []Event
|
||||
}
|
||||
|
@ -3,12 +3,11 @@ package types
|
||||
type EventsMode int8
|
||||
|
||||
const (
|
||||
EventsModeOff = EventsMode(0)
|
||||
EventsModeCached = EventsMode(1)
|
||||
EventsModeOn = EventsMode(2)
|
||||
EventsModeOff = EventsMode(0)
|
||||
EventsModeOn = EventsMode(1)
|
||||
)
|
||||
|
||||
type Event struct {
|
||||
Key string
|
||||
TxBytes []byte
|
||||
Key string
|
||||
Data []byte
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user