diff --git a/docs/cbp_state_machine.puml b/docs/cbp_state_machine.puml new file mode 100644 index 00000000..51f0de48 --- /dev/null +++ b/docs/cbp_state_machine.puml @@ -0,0 +1,84 @@ +@startuml +hide empty description + +note as Lines + Green lines are happy paths. + Red lines are error paths. + Blue lines are stop paths. + + In general any action for any state can produce error. + And the sync process can be stopped during any action. +end note + + +[*] -> validateServer + +validateServer : ValidateServerAction +validateServer -[#green,bold]-> computeSyncRanges +validateServer -[#red]-> failed : Error occured. +validateServer -[#blue]-> stopped : Sync was stopped. + +computeSyncRanges : ComputeSyncRangesAction +computeSyncRanges -[#green,bold]-> checksBeforeSync +computeSyncRanges -[#red]-> failed : Error occured. +computeSyncRanges -[#blue]-> stopped : Sync was stopped. + +checksBeforeSync : ChecksBeforeSyncAction +checksBeforeSync -[#green,bold]-> fetchUTXO +checksBeforeSync -[#red]-> failed : Error occured. +checksBeforeSync -[#blue]-> stopped : Sync was stopped. + +fetchUTXO : FetchUTXOAction +fetchUTXO -[#green,bold]-> handleSaplingParams +fetchUTXO -[#red]-> failed : Error occured. +fetchUTXO -[#blue]-> stopped : Sync was stopped. + +handleSaplingParams : SaplingParamsAction +handleSaplingParams -[#green,bold]-> scanDownloaded +handleSaplingParams -[#red]-> failed : Error occured. +handleSaplingParams -[#blue]-> stopped : Sync was stopped. + +scanDownloaded : ScanDownloadedButUnscannedAction +scanDownloaded -[#green,bold]-> download +scanDownloaded -[#red]-> failed : Error occured. +scanDownloaded -[#blue]-> stopped : Sync was stopped. + +download : DownloadAction +download -[#green,bold]-> validate +download -[#red]-> failed : Error occured. +download -[#blue]-> stopped : Sync was stopped. + +validate : ValidateAction +validate -[#green,bold]-> scan +validate -[#red]-> failed : Error occured. +validate -[#blue]-> stopped : Sync was stopped. + +scan : ScanAction +scan -[#green,bold]-> clearAlreadyScannedBlocks + +clearAlreadyScannedBlocks : ClearAlreadyScannedBlocksAction +clearAlreadyScannedBlocks -[#green,bold]-> enhance + +enhance : EnhanceAction +enhance -[#green,bold]-> download : Not all blocks in the\nsync range are downloaded\nand scanned yet. +enhance -[#green,bold]-> clearCache : All the blocks in\nthe sync range are downloaded\nand scanned. +enhance -[#red]-> failed : Error occured. +enhance -[#blue]-> stopped : Sync was stopped. + +note right of enhance + Enhance transactions in batches of 1000 + blocks. Dont't do it for each scan batch + which is usualy 100 blocks. +end note + +clearCache : ClearCacheAction +clearCache --> finished +clearCache -[#red]-> failed : Error occured. +clearCache -[#blue]-> stopped : Sync was stopped. + +finished --> [*] +failed --> [*] +stopped --> [*] + +@enduml + diff --git a/docs/images/cbp_state_machine.png b/docs/images/cbp_state_machine.png new file mode 100644 index 00000000..68696ab0 Binary files /dev/null and b/docs/images/cbp_state_machine.png differ