-
Notifications
You must be signed in to change notification settings - Fork 378
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
API exposure - RESTful API and socket.io-based push Events #280
Conversation
Should we merge this PR or wait for the changes as defined in #10 ? |
let's wait for the changes in #10 , I will push to this PR directly and rename it accordingly |
This is the server for the API exposure. All methods marked by the @expose decorator will be available via http-requests at the given REST endpoint, once the Dispatcher is initialized and the server is running. Synchronous methods will return their return-value immediately in the request's respond message. Asynchronous methods will not return their return value, but rather a unique callback-id, that will later be used in a 'rpc_response' Event via socket.io for evaluation. The response is structured like this: { callback_id: value or None if Synchronous method= str (the methods name) result= value or None if Asynchronous } Clients should also connect to the websocket that is used for push-Notifications ('Events') via the socket.io protocol. Without the connection to the socket, asynchronous calls over http-requests will be initiated, but the client has no knowledge about the success of the call. Also externally initiated state-changes such as channel-opening or incoming transfers will not be observed by the client, if he doesn't want to pull this information constantly. Events are structured like this: Event: 'rpc_response' namespace: '/' data: { callback_id: <int>, procedure: <str>, status: <bool> } closes #10 related issue: #207
…Exception classes
…_event methods, add basic Event Queue
from ethereum.transactions import Transaction | ||
from ethereum.utils import denoms, int_to_big_endian, encode_hex, normalize_address | ||
<<<<<<< 4c31f51f14f0b23ec72f06c4605e9944fbe60a20 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note to self: don't get distracted while rebasing
|
||
log = slogging.get_logger(__name__) # pylint: disable=invalid-name | ||
|
||
DEFAULT_REVEAL_TIMEOUT = 30 | ||
DEFAULT_SETTLE_TIMEOUT = DEFAULT_REVEAL_TIMEOUT * 20 | ||
|
||
EventListener = namedtuple('EventListener', ('event_name', 'filter_', 'translator')) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Careful: this and every related peace of code didn't make it in my pull-rebase from origin/master (somehow).
If I cannot rewind this easily, it has to be cherrypicked and reimplemented again!
this provides the initial ideas of the API-exposure.
what this PR implements:
@expose
decorated methods can be called via http-requests (REST-style URLs)"result": data
"result": null
Dispatcher
-classsocket.io
protocol)what is still TO DO:
closes #10
related #207