-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ba8ead4
commit b6f86f3
Showing
6 changed files
with
239 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
127 changes: 127 additions & 0 deletions
127
packages/docs/src/spec/src/04-client-architecture/sync-db.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
###### | ||
SyncDB | ||
###### | ||
|
||
*********** | ||
Description | ||
*********** | ||
``SyncDB`` is used by the `SyncManager`_ to store information about current synchronization statuses. | ||
|
||
------------------------------------------------------------------------------- | ||
|
||
*** | ||
API | ||
*** | ||
|
||
Methods | ||
======= | ||
|
||
putLastSyncedBlock | ||
------------------ | ||
|
||
.. code-block:: typescript | ||
async function putLastSyncedBlock( | ||
plasmaContract: string, | ||
block: number | ||
): Promise<void> | ||
Description | ||
^^^^^^^^^^^ | ||
Sets the last block up to which the client has synchronized with a given plasma contract. | ||
|
||
Parameters | ||
^^^^^^^^^^ | ||
1. ``plasmaContract`` - ``string``: ID of the plasma chain to set last block for. | ||
2. ``block`` - ``number``: Last block up to which the client has synchronized. | ||
|
||
Returns | ||
^^^^^^^ | ||
``Promise<void>``: Promise that resolves once the block has been set. | ||
|
||
getLastSyncedBlock | ||
------------------ | ||
|
||
.. code-block:: typescript | ||
async function getLastSyncedBlock(plasmaContract: string): Promise<number> | ||
Description | ||
^^^^^^^^^^^ | ||
Gets the last block up to which the client has synchronized with a given plasma contract. | ||
|
||
Parameters | ||
^^^^^^^^^^ | ||
1. ``plasmaContract`` - ``string``: Contract to query the last synced block for. | ||
|
||
Returns | ||
^^^^^^^ | ||
``Promise<number>``: Block up to which the client has synchronized. | ||
|
||
addSyncQuery | ||
------------ | ||
|
||
.. code-block:: typescript | ||
async function addSyncQuery( | ||
plasmaContract: string, | ||
stateQuery: StateQuery | ||
): Promise<void> | ||
Description | ||
^^^^^^^^^^^ | ||
Adds a `StateQuery`_ to the list of queries to execute for a given plasma contract. | ||
|
||
Parameters | ||
^^^^^^^^^^ | ||
1. ``plasmaContract`` - ``string``: Contract to add a query for. | ||
2. ``stateQuery`` - ``StateQuery``: Query to add for the contract. | ||
|
||
Returns | ||
^^^^^^^ | ||
``Promise<void>``: Promise that resolves once the query has been added. | ||
|
||
removeSyncQuery | ||
--------------- | ||
|
||
.. code-block:: typescript | ||
async function removeSyncQuery( | ||
plasmaContract: string, | ||
stateQuery: StateQuery | ||
): Promise<void> | ||
Description | ||
^^^^^^^^^^^ | ||
Removes a `StateQuery`_ from the list of queries to execute for a given plasma contract. | ||
|
||
Parameters | ||
^^^^^^^^^^ | ||
1. ``plasmaContract`` - ``string``: Contract to remove a query for. | ||
2. ``stateQuery`` - ``StateQuery``: Query to remove for the contract. | ||
|
||
Returns | ||
^^^^^^^ | ||
``Promise<void>``: Promise that resolves once the query has been removed. | ||
|
||
getSyncQueries | ||
-------------- | ||
|
||
.. code-block:: typescript | ||
async function getSyncQueries( | ||
plasmaContract: string | ||
): Promise<StateQuery[]> | ||
Description | ||
^^^^^^^^^^^ | ||
Returns the `StateQuery`_ objects to execute for a given plasma contract. | ||
|
||
Parameters | ||
^^^^^^^^^^ | ||
1. ``plasmaContract`` - ``string``: Contract to get sync queries for. | ||
|
||
Returns | ||
^^^^^^^ | ||
``Promise<StateQuery[]>``: List of queries to execute for a given contract. | ||
|
105 changes: 105 additions & 0 deletions
105
packages/docs/src/spec/src/04-client-architecture/sync-manager.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
########### | ||
SyncManager | ||
########### | ||
|
||
*********** | ||
Description | ||
*********** | ||
``SyncManager`` runs in the background and automatically synchronizes the client's state with the operator's state. It watches for new block submissions and queries the operator for any relevant state updates. | ||
|
||
------------------------------------------------------------------------------- | ||
|
||
*** | ||
API | ||
*** | ||
|
||
Methods | ||
======= | ||
|
||
getLastSyncedBlock | ||
------------------ | ||
|
||
.. code-block:: typescript | ||
async function getLastSyncedBlock(plasmaContract: string): Promise<number> | ||
Description | ||
^^^^^^^^^^^ | ||
Gets the last block up to which the manager has synchronized for a given plasma chain. | ||
|
||
Parameters | ||
^^^^^^^^^^ | ||
1. ``plasmaContract`` - ``string``: ID of the plasma chain to get the last synced block for. | ||
|
||
Returns | ||
^^^^^^^ | ||
``Promise<number>``: Block up to which the manager has synchronized. | ||
|
||
addSyncQuery | ||
------------ | ||
|
||
.. code-block:: typescript | ||
async function addSyncQuery( | ||
plasmaContract: string, | ||
stateQuery: StateQuery | ||
): Promise<void> | ||
Description | ||
^^^^^^^^^^^ | ||
Adds a `StateQuery`_ to the list of queries to call on a specific plasma chain when the synchronization loop triggers. Necessary because different predicates can be parsed in different ways and the manager needs to know what to look for. | ||
|
||
Parameters | ||
^^^^^^^^^^ | ||
1. ``plasmaContract`` - ``string``: ID of the plasma contract to add a query for. | ||
2. ``stateQuery`` - ``StateQuery``: `StateQuery`_ to add for that contract. | ||
|
||
Returns | ||
^^^^^^^ | ||
``Promise<void>``: Promise that resolves once the query has been added. | ||
|
||
removeSyncQuery | ||
--------------- | ||
|
||
.. code-block:: typescript | ||
async function removeSyncQuery( | ||
plasmaContract: string, | ||
stateQuery: StateQuery, | ||
): Promise<void> | ||
Description | ||
^^^^^^^^^^^ | ||
Removes a `StateQuery`_ to the list of queries to call on a specific plasma chain when the synchronization loop triggers. | ||
|
||
Parameters | ||
^^^^^^^^^^ | ||
1. ``plasmaContract`` - ``string``: ID of the plasma contract to remove a query for. | ||
2. ``stateQuery`` - ``StateQuery``: `StateQuery`_ to remove for that contract. | ||
|
||
Returns | ||
^^^^^^^ | ||
``Promise<void>``: Promise that resolves once the query has been added. | ||
|
||
.. _`StateQuery`: TODO | ||
|
||
getSyncQueries | ||
-------------- | ||
|
||
.. code-block:: typescript | ||
async function getSyncQueries(plasmaContract: string): Promise<StateQuery[]> | ||
Description | ||
^^^^^^^^^^^ | ||
Returns the list of active `StateQuery`_ objects the manager is using when the synchronization loop triggers. | ||
|
||
Parameters | ||
^^^^^^^^^^ | ||
1. ``plasmaContract`` - ``string``: Contract to get active queries for. | ||
|
||
Returns | ||
^^^^^^^ | ||
``Promise<StateQuery[]>``: A list of `StateQuery`_ objects the manager is using. | ||
|
||
|