-
Notifications
You must be signed in to change notification settings - Fork 764
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(core/geth): enable Clique mode (#2063)
* feat(core/geth): add method for initing Clique genesis * feat(core/geth): add Clique mode this is ported from https://github.com/paradigmxyz/reth/pull/623/files\#diff-99e7bcdfb85c75ffe5fb2ccfbc5fd8234fced6704c34b622fbf24289b8522515R228-R245 * feat(core/geth): disable discovery in clique mode * examples: add Geth Clique example
- Loading branch information
Showing
5 changed files
with
150 additions
and
6 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
use ethers::{ | ||
core::{rand::thread_rng, utils::Geth}, | ||
signers::LocalWallet, | ||
}; | ||
use eyre::Result; | ||
|
||
#[tokio::main] | ||
/// Shows how to instantiate a Geth with Clique enabled. | ||
async fn main() -> Result<()> { | ||
// Generate a random clique signer and set it on Geth. | ||
let data_dir = tempfile::tempdir().expect("should be able to create temp geth datadir"); | ||
let dir_path = data_dir.into_path(); | ||
println!("Using {}", dir_path.display()); | ||
|
||
// Create a random signer | ||
let key = LocalWallet::new(&mut thread_rng()); | ||
|
||
let clique_key = key.signer().clone(); | ||
let _geth = Geth::new() | ||
// set the signer | ||
.set_clique_private_key(clique_key) | ||
// must always set the chain id here | ||
.chain_id(199u64) | ||
// set the datadir to a temp dir | ||
.data_dir(dir_path) | ||
// spawn it | ||
.spawn(); | ||
|
||
Ok(()) | ||
} |