Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Event and filtering system (high-level API) #15

Closed
graup opened this issue Nov 22, 2018 · 4 comments
Closed

Event and filtering system (high-level API) #15

graup opened this issue Nov 22, 2018 · 4 comments

Comments

@graup
Copy link
Member

graup commented Nov 22, 2018

We need an event system, not just for plugins like in #14, but also as general API so that clients can react without needing to scan all transactions.

In Go

How about making a system similar to the actor messages with pub/sub? Maybe a component could
Subscribe(events.Block)
and then

func (ns *SomeComponent) Receive(context actor.Context) {
    switch msg := context.Message().(type) {
        case *events.Block:
            ns.HandleBlock(msg.Block);
        default:
    }
}

For contract events, you probably want to subscribe to something like Ethereum-style topics.
SubscribeWithFilter(events.Transaction, { To: someAddress, Topic: someTopic } )

This is how it could look in Go, but more importantly this should also be accessible over GRPC, ideally supporting both streams for real-time and searching in the past.

End-to-end example for streams

Herajs

contract.events.Deposit({from: someAddress}).on('transaction', (tx) => { console.log(tx); });

GRPC

wss://127.0.0.1:7845/types.AergoRPCService/EventsStream
event=...   from=someAddress

Aergosvr

SubscribeWithFilter(events.Transaction, { To: someAddress, Topic: someTopic } )
Receive: 
    stream.Send(transaction)

(Need to think about performance here, what if there are a lot of clients connecting to the server at once?)

Filtering

Is there any problem with just implementing Ethereum-like filters? (Store logs in tx receipts and have bloom filters to quickly search for topics)

Some related discussion about topics/filters:

@graup graup added feature New feature or request help wanted Extra attention is needed labels Nov 22, 2018
@graup graup changed the title Event and filtering system Event and filtering system (high-level API) Nov 22, 2018
@ashen1dev
Copy link
Contributor

We already have some plans to create an event framework. First one is Pub-Sub model like Ethereum. and Second one is POST method in Coinstack 3sp1. We can discuss them in here.

@graup
Copy link
Member Author

graup commented Nov 26, 2018

@ashen1dev I think the POST method in Coinstack is interesting, but the use case seems a bit different. I guess it's a bit like a webhook in GitHub? So the server will request a given URL when something happens in the contract? It makes the contract very tightly coupled to a specific centralized deployment, right?

@graup graup added this to the Testnet milestone Nov 28, 2018
@graup graup added proposal and removed feature New feature or request labels Nov 28, 2018
@graup graup removed this from the Testnet milestone Dec 26, 2018
@graup
Copy link
Member Author

graup commented Mar 11, 2019

This has landed in 0.12, but documentation is still lacking.

@graup
Copy link
Member Author

graup commented Mar 26, 2019

There's some documentation here:

I'd like to see a bit more in the first article and also in the Lua Guide

@graup graup added documentation and removed help wanted Extra attention is needed proposal labels Mar 26, 2019
@graup graup closed this as completed Aug 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants