enha: implement Consensus trait for Importer #1608
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PR Type
Enhancement, Bug fix
Description
Consensus
trait by adding default methods forshould_serve
andforward
, along with new methodsget_chain
andlag
.Consensus
trait forImporter
,Raft
, andSimpleConsensus
structs.RpcContext
and RPC server to handle an optionalconsensus
.run
function inmain.rs
to initializeconsensus
as anOption
.Changes walkthrough 📝
mod.rs
Enhance `Consensus` trait with default methods and error handling
src/eth/consensus/mod.rs
should_serve
andforward
in theConsensus
trait.get_chain
andlag
methods to theConsensus
trait.transaction forwarding.
mod.rs
Implement `get_chain` and `lag` for `Raft` struct
src/eth/consensus/raft/mod.rs
get_chain
andlag
methods forRaft
struct.should_forward
method.mod.rs
Implement `get_chain` and `lag` for `SimpleConsensus` struct
src/eth/consensus/simple_consensus/mod.rs
get_chain
andlag
methods forSimpleConsensus
struct.should_forward
andshould_serve
methods.importer.rs
Implement `Consensus` trait for `Importer` struct
src/eth/importer/importer.rs
Consensus
trait forImporter
struct.lag
andget_chain
methods toImporter
.rpc_context.rs
Make `consensus` field optional in `RpcContext`
src/eth/rpc/rpc_context.rs
consensus
field inRpcContext
to be anOption
.rpc_server.rs
Handle optional `consensus` in RPC server
src/eth/rpc/rpc_server.rs
consensus
.None
value inconsensus
before calling methods.main.rs
Update `run` function to handle optional `consensus`
src/main.rs
run
function to initializeconsensus
as anOption
.SimpleConsensus
.