Javadoc
Processor for item that will be processed from check to poll and other processes.
Lifecycle of the item processor is:
- download
- check
- resync subitems (optinal)
- polling
- send consensus
- remove
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
or after
ItemProcessor#forceChecking(boolean) call. Will call
Approvable#check()or
Approvable#paymentCheck(Set) if item is payment (
Approvable#shouldBeU()).
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
own
Approvable#getReferencedItems() will recursively checked and will get
ItemState#LOCKED;
Approvable#getNewItems() will checked if errors exists (after
Approvable#check() -
it recursively call check() for new items) and recursively checked for own references, revokes and new items,
if all is ok - item will get
ItemState#LOCKED_FOR_CREATION state.
While checking, after item itself checking but before subitems checking
ItemProcessor#isNeedToResync(boolean)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
ItemState#PENDING_POSITIVE or
ItemState#PENDING_NEGATIVEstate 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
using
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
via
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#removeSelf()Look at
ItemProcessor#processingState to know what happend with processing at calling time.