Each item (such as Contract or parts of Parcel) will processing on the node by ItemProcessor.
Lifecycle of the item processor is:
- resync subitems (optinal)
- send consensus
First of all item should be downloaded from other node or get from param of a constructor.
Then item will be checked. Immediately after download if
ItemProcessor#isCheckingForce is true
ItemProcessor#forceChecking(boolean) call. Will call
Approvable#paymentCheck(Set) if item is payment (
Then subitems will be checked:
Approvable#getReferencedItems() will checked if exists in the ledger;
Approvable#getRevokingItems() will checked if exists in the ledger and its
Approvable#getReferencedItems() will recursively checked and will get
Approvable#getNewItems() will checked if errors exists (after
it recursively call
check() for new items) and recursively checked for own references, revokes and new items,
if all is ok - item will get
Resync subitems (optinal)
While checking, after item itself checking but before subitems checking
calling. If return value is true item processor will go to resync subitems. Resync calls to nodes
about states of subitems and update consensus states. After resync back to check subitems.
After checking item processor run polling. It set
state for processing item, send state to the network via
ItemProcessor#broadcastMyState() and run polling.
While polling item processing wait for votes from other nodes and collect it
ItemProcessor#vote(NodeInfo, ItemState). When consensus is got item processor save item
to the ledger with consensus state via
ItemProcessor#approveAndCommit() if consensus is positive or
ItemProcessor#rollbackChanges(ItemState) if consensus is negative.
Then item processor looking for nodes that not answered with for polling and send them new consensus until they will have answered.
And finally, if node got answers from all other nodes - item processor removing via
ItemProcessor#processingState to know what happend with processing at calling time.