-
Notifications
You must be signed in to change notification settings - Fork 6
steem state Documentation
Documentation reference for the steem-state
npm package (this does not include the steem-transact
package).
The steem-state
package exports this function, which returns a state processor, which all below functions are from.
client
: A dsteem
client to use to interface with the Steem blockchain.
steem
: A dsteem
instance for utils around the blockchain API.
currentBlockNumber
: The block to start processing transactions from.
blockComputeSpeed
: How quickly to process previous blocks (amount of milliseconds between processing each block).
prefix
: A string at the beginning of each operation id; used to show which DApp a transaction is for. An example would be SteemMonster's sm_
prefix.
mode
: A string representing the block streaming mode: can be either latest
or irreversible
.
The on
function tells the processor a function to call when a certain custom_json
operation id is read.
operationId
: The operation id to use. Will be combined with the prefix to form the full operation id to look for.
callback
: The function to call when an operation of operationId
is found. The callback will be called with arguments (json, from, active)
where json
is the operation's json data, from
is the operation's creator, and active
is whether the operation was signed with an active key (true for signed with an active key).
Note for .on
and all similar functions: the JSON object returned also has two extra properties: tx_id
and block_num
which tell the transaction id and block number respectively.
The onNoPrefix
function tells the processor a function to call when a certain custom_json
operation id is read but does not automatically add on the prefix. Useful for interfacing with other steem-state applications or listening for resteems/follows.
operationId
: The operation id to use. Will NOT be combined with the prefix to form the full operation id to look for.
callback
: The function to call when an operation of operationId
is found. The callback will be called with arguments (json, from, active)
where json
is the operation's json data, from
is the operation's creator, and active
is whether the operation was signed with an active key (true for signed with an active key).
The onOperation
function tells the processor a function to call when a certain operation type is read. Useful for streaming STEEM transfers, posts, votes, etc.
type
: The type of operation to stream. Could be (but not limited to) vote
, comment
.
callback
: The function to call when an operation of type
is found. The callback will be called with arguments (json)
where json
is the operation's json data.
The onBlock
function tells the processor a function to call before a new block is processed.
callback
: The fuction to call before a new block is processed. The callback will be called with an argument of the block's full json.
The start
function starts the processor and it starts reading from blocks starting from the block currentBlockNumber
(argument to steem-state
).
The stop
function stops the processor cleanly then calls the callback. Always use this function to exit, not just process.exit()
.
callback
: Called after a successful exit.
processor.stop(function() {
process.exit();
});
The above code would be used in the event that the user wished to close the program.
Returns whether the client is up to date (streaming new blocks, not old ones). true return value = streaming new blocks.
Subscribes to an event that is called when the processor is processing blocks at real-time. Useful to display info to the user to tell them that they are viewing new operations at real time.
callback
: The function to call when the processor is processing blocks at real-time. callback
will be called with no arguments.
Returns the next block number processed by the processor.
If you have any questions, suggestions, problems, or want advice about incorporating soft-consensus into your project, email me at nicholas2591@gmail.com.