Nyzo techRelease notesNyzo 568: coins in circulation

Nyzo 568: coins in circulation

Nyzo version 568 (commit on GitHub) adds the CoinsInCirculationCommand to the client.

This version affects the client only.

In LockedAccountManager, the new accountIsLocked() method allows direct querying of whether an account is subject to locking. Previously, only transactions could be queried, using the isSubjectToLock() method.

RN_568 code 0

In the Client initialization process, the new CommandManager.checkCommandStrings() method is called. This method does nothing more than print messages if duplicate command strings are used among multiple commands.

RN_568 code 1

In CommandEndpointApi.getResponse(), use of the ExecutionResult.toJson() method has been replaced with the new ExecutionResult.toEndpointResponse() method. This allows ExecutionResult objects to return types other than JSON.

RN_568 code 2

In CommandEndpointWeb.getResponse(), presentation and processing of the form is now bypassed for commands with no arguments.

RN_568 code 3

In CommandManager, the new CoinsInCirculationCommand was added to the list of commands. The checkCommandStrings() method, as noted above, prints messages when duplicate command names are found. This method is intended to prevent developers from inadvertently adding a new command whose command strings collide with those of an existing command.

RN_568 code 4

In the ExecutionResult interface, the toJson() method was replaced with toEndpointResponse(). This allows an ExecutionResult to return API responses of any type, including binary and plain text.

RN_568 code 5

In SimpleExecutionResult, implementation of toJson() was modified to become toEndpointResponse() to satisfy the new requirement of ExecutionResult.

RN_568 code 6

The new CoinsInCirculationCommand implements the required methods for the Command interface. This command takes no arguments, and it requires neither validation nor confirmation. It is not long-running.

RN_568 code 7

CoinsInCirculationCommand.run() begins by creating the structure for its output. A CommandTable stores the calculation of coins in circulation along with a number of values used in the calculation.

RN_568 code 8

The frozen-edge balance list is used to calculate circulation. The sum of locked accounts is calculated, and balances of other accounts not in circulation are retrieved. The total circulation is calculated by subtracting total locked amounts from the total number of coins in the system. An additive calculation of all unlocked amounts would produce the same result.

RN_568 code 9

The result table is assembled, and the result is produced. Instead of using the default JSON API response provided by SimpleExecutionResult, the toEndpointResponse() method is overridden to produce a plain-text response with just the circulation value.

RN_568 code 10

In EndpointResponse, a content type was added for plain text.

RN_568 code 11

The web form of this command, http://client.nyzo.co/circulation, displays a table.

RN_568 code 12

The API form of this command, http://client.nyzo.co/api/circulation, returns a plain-text value. This should allow for easy implementation for anyone who wants to track Nyzo circulation.

RN_568 code 13