PERMANET network mode
This is a network mode for custom networks aimed to keep all contracts on each node independently. This mode is set while configuring the network and can not be changed in the network after it has been launched.
The main features of the PERMANET network mode are:
- independent and guaranteed storage of all contracts (contrary to the regular Mainnet, where by default only the contract hashes are stored);
- synchronization of contracts between all nodes of the network;
- capability to obtain an active contract or list of IDs (limited by configured limit) of all active contracts for the origin;
- capability to get a registered contract by its ID.
For proper PERMANET functioning, all the nodes of the network must be running in PERMANET mode.
PERMANET network mode configuration
In order to configure the network in PERMANET mode, you need to set the parameter
permanet_mode == true in the configuration file of the node. When the network is started, PERMANET network mode will be fixed and can not be changed.
You can check/determine if the network is working in PERMANET mode, by calling the method:
If the network is running in PERMANET mode, the method will return
Also in the configuration file of the node, you can set the maximum limit of the number of return ID of active contracts that which the network will return , for this, use the method:
By default the limit of the number of returned IDs is 100.
In order to determine the maximum size of the active contract identifiers list in the network, use the method:
The method returns the value set in the configuration file of the node.
Node HTTP API extensions
In the PERMANET network mode, you can use any regular available HTTP APIs of the network node. And also you can use commands specially developed for the network mode PERMANET:
Note that these commands will not work in the regular network mode, they are available only in the PERMANET network mode.
Get a contract (or list of ID) by contract origin
getContract command to find the latest approved revision of the contract, when you know the contract origin.
For regular contracts, where only one approved revision always exists (and a new revision always causes revocation of the previous approved revision), this command immediately returns the latest approved contract.
For contracts which may have multiple approved revisions for the same origin (such as the split-join contracts or URC20 tokens), getting the bodies of all of them would clog the network; to prevent it, in such scenario this command returns just the list of such contracts. The list size is limited.
To get a active contract (or the ID list for all the active contracts) for the known origin, you need to run the
getContract command and to specify the
origin contract as a parameter. Also, if necessary, you can change the predefined limit, but no larger than the limits specified in the node configuration file; in order to do this, specify the
This command returns the contract by its origin, if the network only one contract with this origin. If more than one contract found, command returns IDs of last known active contracts.
Get a contract by ID
getBody command to get the contract with the given contract
id. To do this, you need to run the
getBody command to specify the
id contract as a parameter of the contract you want to get:
This command returns the contract with the given contract