Skip to content

Commit

Permalink
[WS protocol] Call account callback on proposals and get proposals of…
Browse files Browse the repository at this point in the history
… accounts
  • Loading branch information
xeroc committed Jan 20, 2016
1 parent 596a579 commit 5929897
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions grapheneapi/graphenewsprotocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def subscribe_to_objects(self, *args):

def getAccountHistory(self, account_id, callback,
start="1.11.0", stop="1.11.0", limit=100):
""" Get Account history History
""" Get Account history History and call callback
:param account-id account_id: Account ID to read the history for
:param fnt callback: Callback to execute with the response
Expand All @@ -170,6 +170,18 @@ def getAccountHistory(self, account_id, callback,
raise ValueError("getAccountHistory expects an account" +
"id of the form '1.2.x'!")

def getAccountProposals(self, account_ids, callback):
""" Get Account Proposals and call callback
:param array account_ids: Array containing account ids
:param fnt callback: Callback to execute with the response
"""
self.wsexec([self.api_ids["database"],
"get_proposed_transactions",
account_ids],
callback)

def dispatchNotice(self, notice):
""" Main Message Dispatcher for notifications as called by
``onMessage``. This dispatcher will separated object,
Expand All @@ -185,16 +197,18 @@ def dispatchNotice(self, notice):
[inst, _type, _id] = oid.split(".")
account_ids = []
for a in self.accounts :
account_ids.append("2.6.%s" % a.split(".")[2])
account_ids.append("1.2.%s" % a.split(".")[2])
account_ids.append("2.6.%s" % a.split(".")[2]) # account history
account_ids.append("1.2.%s" % a.split(".")[2]) # account
try:
if (oid in self.database_callbacks_ids and
callable(self.database_callbacks_ids[oid])):
self.database_callbacks_ids[oid](self, notice)

" Account Notifications "
if (callable(self.accounts_callback) and
oid in account_ids):
(oid in account_ids or # account updates
inst == "1" and _type == "10" or # proposals
inst == "1" and _type == "11")): # history
self.accounts_callback(notice)

" Market notifications "
Expand Down

0 comments on commit 5929897

Please sign in to comment.