-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: bring in latest dapi-client changes from platform repo
- Loading branch information
Showing
6 changed files
with
93 additions
and
53 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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
40 changes: 40 additions & 0 deletions
40
docs/dapi-client-js/usage/core/subscribetoblockheaderswithchainlocks.md
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,40 @@ | ||
# subscribeToBlockHeadersWithChainLocks | ||
|
||
**Usage**: `await client.core.subscribeToBlockHeadersWithChainLocks(options = { count: 0 })`\ | ||
**Description**: Returns a ClientReadableStream streaming of block headers and chainlocks. | ||
|
||
Parameters: | ||
|
||
| parameters | type | required | Description | | ||
|----------------------------|------------------|----------------| ------------------------------------------------------------------------------------------------ | | ||
| **options.fromBlockHash** | String | yes | Specifies block hash to start syncing from | | ||
| **options.fromBlockHeight**| Number | yes | Specifies block height to start syncing from | | ||
| **options.count** | Number | no (default: 0)| Number of blocks to sync, if set to 0 syncing is continuously sends new data as well | | ||
|
||
Returns : Promise<EventEmitter>|!grpc.web.ClientReadableStream<!BlockHeadersWithChainLocksResponse> | ||
|
||
Example : | ||
|
||
```js | ||
const { BlockHeader, ChainLock } = require('@dashevo/dashcore-lib'); | ||
|
||
const stream = await client.subscribeToBlockHeadersWithChainLocks({ fromBlockHeight: 0 }); | ||
|
||
stream | ||
.on('data', (response) => { | ||
const rawHeaders = response.getBlockHeaders(); | ||
const rawChainLock = response.getChainLock(); | ||
|
||
if (headers.length > 0) { | ||
const headers = rawHeaders.map((rawHeader) => new BlockHeader(rawHeader)); | ||
console.dir(headers); | ||
} | ||
|
||
if (rawChainLock) { | ||
const chainLock = new ChainLock(rawChainLock); | ||
} | ||
}) | ||
.on('error', (err) => { | ||
// do something with err | ||
}); | ||
``` |
26 changes: 26 additions & 0 deletions
26
docs/dapi-client-js/usage/core/subscribetomasternodelist.md
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,26 @@ | ||
# subscribeToMasternodeList | ||
|
||
**Usage**: `await client.core.subscribeToMasternodeList(options = {})`\ | ||
**Description**: Returns a ClientReadableStream streaming of masternode list diffs ([DIP-4](https://github.com/dashpay/dips/blob/master/dip-0004.md)). As a first message it returns a diff from the first block to the current tip and a diff for each new chainlocked block. | ||
|
||
Returns : Promise<EventEmitter>|!grpc.web.ClientReadableStream<!MasternodeListResponse> | ||
|
||
Example : | ||
|
||
```js | ||
const { SimplifiedMNList, SimplifiedMNListDiff } = require('@dashevo/dashcore-lib'); | ||
|
||
const stream = await client.subscribeToMasternodeList(); | ||
|
||
const list = new SimplifiedMNList(); | ||
|
||
stream | ||
.on('data', (response) => { | ||
const diffBuffer = Buffer.from(response.getMasternodeListDiff_asU8()); | ||
const diff = new SimplifiedMNListDiff(diffBuffer); | ||
list.applyDiff(diff); | ||
}) | ||
.on('error', (err) => { | ||
// do something with err | ||
}); | ||
``` |
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