Nyzo techRelease notesNyzo 633: unconfirmed script states

Nyzo 633: unconfirmed script states

Nyzo version 633 (commit on GitHub) adds an option the NyzoScript Command to return script states that include information from unconfirmed (pending) transactions.

This version affects the client.

Those who followed development of the tic-tac-toe Micropay game example will recall that gameplay was rather slow in the initial implementation. Moves did not appear until the transactions representing them were confirmed by the cycle. Version 623 provided an option for the TransactionIndexedSearchCommand to return pending transactions in addition to confirmed transactions, which made gameplay almost instant.

This version adds a similar improvement to the NyzoScriptCommand. An option to include unconfirmed transactions in script results allow users to see the effects of those transactions almost immediately.

In ClientDataManager.start(), the Nyzo ScriptManager.start() method is called.

RN_633 image 0

An argument to request inclusion of unconfirmed transactions was added to NyzoScript Command.

RN_633 image 1

When running NyzoScriptCommand, the new argument is read and passed to NyzoScriptManager.stateForAccount(). The default value of this argument is false, which means that behavior of this command does not change for users who do not provide a value.

RN_633 image 2

The allTransactions() method was added to the TransactionForwardCommand to provide access to the pool of pending transactions.

RN_633 image 3

The NyzoScriptManager.start() method starts a thread that runs a loop for processing scripts with unconfirmed transactions. Currently, the loop sleeps 3 seconds each iteration. To improve responsiveness of script states, this sleep will likely be reduced in duration after some protections are implemented to ensure excessive resources are not consumed by this thread.

RN_633 image 4

In initial state creation, a false argument was added to the stateForAccount() method call. This results in the method call behaving as it did previously.

RN_633 image 5

In NyzoScriptManager.stateForAccount(), the new includeUnconfirmedTransactions argument causes the method to look to the unconfirmedStateMap for a state that includes information from unconfirmed transactions. If this argument is false or if the state is not present in the unconfirmedStateMap, the state is read from file.

RN_633 image 6

The NyzoScriptManager.processUnconfirmedTransactions() method is the unconfirmed-transaction equivalent of NyzoScriptManager.process BlockInternal(). This method retrieves transactions from the Transaction ForwardCommand and builds lists of transactions grouped by recipient.

RN_633 image 7

NyzoScriptManager.processUnconfirmedTransactions() then creates states with the unconfirmed transactions. The resulting states are stored in a map for later retrieval.

RN_633 image 8

Exceptions are logged. At the end of the method, the newUnconfirmedState Map is swapped to replace the unconfirmedStateMap. This is an atomic swap, which eliminates any potential for threading issues.

RN_633 image 9

In NyzoScriptManager.processBlockInternal(), a false argument was added to the stateFor Account() method call. This results in the method call behaving as it did previously.

RN_633 image 10