Add Nethermind to clients that accept service transactions (#324)

* Add Nethermind to clients that accept service transactions

* fmt
This commit is contained in:
Jochen Müller 2021-03-18 14:00:05 +01:00 committed by GitHub
parent 504777e879
commit 37f5291538
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 16 additions and 3 deletions

View File

@ -128,8 +128,8 @@ pub trait ClientCapabilities {
/// if this version can handle requests for a large number of block bodies. /// if this version can handle requests for a large number of block bodies.
fn can_handle_large_requests(&self) -> bool; fn can_handle_large_requests(&self) -> bool;
/// Service transactions are specific to parity. Query if this version /// Service transactions are specific to parity and nethermind. Query if
/// accepts them. /// this version accepts them.
fn accepts_service_transaction(&self) -> bool; fn accepts_service_transaction(&self) -> bool;
} }
@ -146,7 +146,7 @@ impl ClientCapabilities for ClientVersion {
match self { match self {
ClientVersion::ParityClient(_) => true, ClientVersion::ParityClient(_) => true,
ClientVersion::ParityUnknownFormat(_) => true, ClientVersion::ParityUnknownFormat(_) => true,
ClientVersion::Other(_) => false, ClientVersion::Other(client_id) => is_nethermind(client_id),
} }
} }
} }
@ -156,6 +156,10 @@ fn is_parity(client_id: &str) -> bool {
|| client_id.starts_with(CURRENT_CLIENT_ID_PREFIX) || client_id.starts_with(CURRENT_CLIENT_ID_PREFIX)
} }
fn is_nethermind(client_id: &str) -> bool {
client_id.starts_with("Nethermind")
}
/// Parse known parity formats. Recognizes either a short format with four fields /// Parse known parity formats. Recognizes either a short format with four fields
/// or a long format which includes the same fields and an identity one. /// or a long format which includes the same fields and an identity one.
fn parse_parity_format(client_version: &str) -> Result<ParityClientData, ()> { fn parse_parity_format(client_version: &str) -> Result<ParityClientData, ()> {
@ -531,6 +535,15 @@ pub mod tests {
ClientVersion::from("Parity-Ethereum/ABCDEFGH/v2.7.3/linux/rustc") ClientVersion::from("Parity-Ethereum/ABCDEFGH/v2.7.3/linux/rustc")
.accepts_service_transaction() .accepts_service_transaction()
); );
assert!(
ClientVersion::from("OpenEthereum//v3.2.0/x86_64-linux-gnu/rustc1.49.0")
.accepts_service_transaction()
);
assert!(ClientVersion::from("OpenEthereum/ABCDEFGH").accepts_service_transaction());
assert!(
ClientVersion::from("Nethermind/v1.10.37-0-068e5c399-20210311/X64-Linux/5.0.4")
.accepts_service_transaction()
)
} }
#[test] #[test]