Add JSON format to import blocks and set it as default (#5816)
* Add BlockStream Enum and utility fn * WIP: Modify import closure to work with BlockStream * Fix trait bounds * Working prototype * Revamp block importing * Add export_import_flow tests * Add comments and clean code * Add more comments in the import fn * Add link code to import function * Add condition when returning Ready(Ok(()) to make sure we've imported every block * Add check for imported blocks in JSON case * Use rest pattern * Fix compilation error for undeclared variable * Add polling and waker before pending * Print read_block_count instead of count * Simplify binary cli option with structopt * Update test to reflect changes in CLI api * Change Stream to take SignedBlock<B> instead of B * Add comments to BlockStream * Move out logic to smaller functions for clearer code * Remove result over import_blocks return type * Check for error in command output rather than simply checking command exit status * Revamp export/import/revert testing * Fix minor typos and formatting errors Co-authored-by: Bastian Köcher <[email protected]> * Remove unnecessary if condition in terminating condition Co-authored-by: Bastian Köcher <[email protected]> * Explicit error instead of returning it as a string Co-authored-by: Bastian Köcher <[email protected]> * Pass BlockStream to log_importing_status_updates and simplify matching arms for block stream * Use .contains() instead of regex match * Line break in match block; return future::ready instead of poll_fn * Update Cargo.lock * Add check so that queue doesn't grow too big * Use Iterator instead of Stream * Remove allow dead_code * Remove outdated comments Co-authored-by: Bastian Köcher <[email protected]> * Return Errors instead of logging them * Simplify match arms Co-authored-by: Bastian Köcher <[email protected]> * Remove check before terminating block import * Apply suggestions from code review * Check that queue is not full BEFORE calling * Revert "Remove check before terminating block import" This reverts commit 377823c0a648a3eb2e61185a257a61023067893d. * Improve unit tests to make sure we actually import blocks * Remove Unpin implementation for BlockIter * Add prototype of enum for ImportStates * Add working prototype for StateMachine * Add comments for clearer code * Add sleep before calling Waker when waiting for import queue * Add Speedometer * add dbg!(&log) for test debugging * Fix lines with more than 100 cols * Fix regex capture for test * Update regexes to take to capture the whole number * Rename Cmd to Command Co-authored-by: Gavin Wood <[email protected]> * Actually rename Cmd to Command * Apply suggestions from code review Co-authored-by: Gavin Wood <[email protected]> * Fix compilation errors for tests * Fix compilation errors from code review suggestion * Update bin/node/cli/tests/export_import_flow.rs Co-authored-by: Bastian Köcher <[email protected]> Co-authored-by: Gavin Wood <[email protected]> Co-authored-by: Benjamin Kampmann <[email protected]>
parent
66fe846d
Please register or sign in to comment