alloy_node_bindings/
node.rs

1//! Node-related types and constants.
2
3use alloy_primitives::hex;
4use std::time::Duration;
5use thiserror::Error;
6
7/// How long we will wait for the node to indicate that it is ready.
8pub const NODE_STARTUP_TIMEOUT: Duration = Duration::from_secs(10);
9
10/// Timeout for waiting for the node to add a peer.
11pub const NODE_DIAL_LOOP_TIMEOUT: Duration = Duration::from_secs(20);
12
13/// Errors that can occur when working with the node instance.
14#[derive(Debug, Error)]
15pub enum NodeError {
16    /// No stderr was captured from the child process.
17    #[error("no stderr was captured from the process")]
18    NoStderr,
19    /// No stdout was captured from the child process.
20    #[error("no stdout was captured from the process")]
21    NoStdout,
22    /// Timed out waiting for the node to start.
23    #[error("timed out waiting for node to spawn; is the node binary installed?")]
24    Timeout,
25    /// Encountered a fatal error.
26    #[error("fatal error: {0}")]
27    Fatal(String),
28    /// A line could not be read from the node stderr.
29    #[error("could not read line from node stderr: {0}")]
30    ReadLineError(std::io::Error),
31
32    /// The chain id was not set.
33    #[error("the chain ID was not set")]
34    ChainIdNotSet,
35    /// Could not create the data directory.
36    #[error("could not create directory: {0}")]
37    CreateDirError(std::io::Error),
38
39    /// Genesis error
40    #[error("genesis error occurred: {0}")]
41    GenesisError(String),
42    /// Node init error
43    #[error("node init error occurred")]
44    InitError,
45    /// Spawn node error
46    #[error("could not spawn node: {0}")]
47    SpawnError(std::io::Error),
48    /// Wait error
49    #[error("could not wait for node to exit: {0}")]
50    WaitError(std::io::Error),
51
52    /// Clique private key error
53    #[error("clique address error: {0}")]
54    CliqueAddressError(String),
55
56    /// The private key could not be parsed.
57    #[error("could not parse private key")]
58    ParsePrivateKeyError,
59    /// An error occurred while deserializing a private key.
60    #[error("could not deserialize private key from bytes")]
61    DeserializePrivateKeyError,
62    /// An error occurred while parsing a hex string.
63    #[error(transparent)]
64    FromHexError(#[from] hex::FromHexError),
65    /// No keys available this node instance.
66    #[error("no keys available in this node instance")]
67    NoKeysAvailable,
68}