onflow / flow-go

A fast, secure, and developer-friendly blockchain built to support the next generation of games, apps, and the digital assets that power them.
GNU Affero General Public License v3.0
534 stars 179 forks source link

[Access] Add implementation for transaction status data providers #6586

Open Guitarheroua opened 1 month ago

Guitarheroua commented 1 month ago

Send & subscribe and subscribe transaction data providers should be implemented as part of the new WebSocket pub/sub system based on the [Draft design of new WebSockets] (https://github.com/onflow/flow-go/issues/6508).

Requirements:

  1. Send & subscribe and subscribe transaction data providers constructors should be implemented. The constructors should create a corresponding subscription.Subscription based on input arguments, and store topic, subscription and other necessary parameters in a newly created instance. These constructors should be called in a DataProviderFactory::NewDataProvider method.

  2. Run should be implemented. It will start in a forever loop until the subscription is closed. This method collects streaming data from the subscription, similar to how we do it, for example in SendAndSubscribeTransactionStatuses:

https://github.com/onflow/flow-go/blob/3496c0f02d51602994d4fe60b32fcb00aab084f4/access/handler.go#L1407-L1451

Then the data is formatted in response messages for the client and written to the send callback.

Also, MessageIndex should be included in the response.

  1. The Close method should be implemented to shut down the subscription gracefully.

  2. ID and Topic getters should return UUID and the topic respectively.

Guitarheroua commented 5 days ago

Part of the implementation relates to issue https://github.com/onflow/flow-go/issues/6767