Improve reconnections by not emitting againg once events.

This commit is contained in:
Davide Casale
2023-04-19 18:05:27 +02:00
parent 3de6eee337
commit 7f788dd239
4 changed files with 95 additions and 50 deletions

View File

@@ -5,16 +5,24 @@ from .. serializers import _Notification
from .. exceptions import HandlerNotFound
class AuthenticatedEventsHandler:
__abbreviations = {
"os": "order_snapshot", "on": "order_new", "ou": "order_update",
"oc": "order_cancel", "ps": "position_snapshot", "pn": "position_new",
"pu": "position_update", "pc": "position_close", "te": "trade_executed",
"tu": "trade_execution_update", "fos": "funding_offer_snapshot", "fon": "funding_offer_new",
"fou": "funding_offer_update", "foc": "funding_offer_cancel", "fcs": "funding_credit_snapshot",
__once_abbreviations = {
"os": "order_snapshot", "ps": "position_snapshot", "fos": "funding_offer_snapshot",
"fcs": "funding_credit_snapshot", "fls": "funding_loan_snapshot", "ws": "wallet_snapshot"
}
__on_abbreviations = {
"on": "order_new", "ou": "order_update", "oc": "order_cancel",
"pn": "position_new", "pu": "position_update", "pc": "position_close",
"fon": "funding_offer_new", "fou": "funding_offer_update", "foc": "funding_offer_cancel",
"fcn": "funding_credit_new", "fcu": "funding_credit_update", "fcc": "funding_credit_close",
"fls": "funding_loan_snapshot", "fln": "funding_loan_new", "flu": "funding_loan_update",
"flc": "funding_loan_close", "ws": "wallet_snapshot", "wu": "wallet_update",
"bu": "balance_update",
"fln": "funding_loan_new", "flu": "funding_loan_update", "flc": "funding_loan_close",
"te": "trade_executed", "tu": "trade_execution_update", "wu": "wallet_update",
"bu": "balance_update"
}
__abbreviations = {
**__once_abbreviations,
**__on_abbreviations
}
__serializers = {
@@ -28,12 +36,15 @@ class AuthenticatedEventsHandler:
("bu",): serializers.Balance
}
EVENTS = [
"notification",
"on-req-notification", "ou-req-notification", "oc-req-notification",
"oc_multi-notification",
"fon-req-notification", "foc-req-notification",
*list(__abbreviations.values())
ONCE_EVENTS = [
*list(__once_abbreviations.values())
]
ON_EVENTS = [
*list(__on_abbreviations.values()),
"notification", "on-req-notification", "ou-req-notification",
"oc-req-notification", "oc_multi-notification", "fon-req-notification",
"foc-req-notification"
]
def __init__(self, event_emitter):