Skip to content
This repository was archived by the owner on Jan 22, 2025. It is now read-only.

Commit 5a72fcb

Browse files
author
Tyera Eulberg
committed
Compress match statements
1 parent bc92b43 commit 5a72fcb

File tree

1 file changed

+16
-17
lines changed

1 file changed

+16
-17
lines changed

client/src/rpc_filter.rs

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -22,22 +22,10 @@ impl RpcFilterType {
2222
MemcmpEncoding::Binary => {
2323
use MemcmpEncodedBytes::*;
2424
match &compare.bytes {
25-
Binary(bytes) if bytes.len() > MAX_DATA_BASE58_SIZE => {
26-
Err(RpcFilterError::Base58DataTooLarge)
27-
}
28-
Base58(bytes) if bytes.len() > MAX_DATA_BASE58_SIZE => {
29-
Err(RpcFilterError::DataTooLarge)
30-
}
31-
Base64(bytes) if bytes.len() > MAX_DATA_BASE64_SIZE => {
32-
Err(RpcFilterError::DataTooLarge)
33-
}
34-
Bytes(bytes) if bytes.len() > MAX_DATA_SIZE => {
35-
Err(RpcFilterError::DataTooLarge)
36-
}
37-
_ => Ok(()),
38-
}?;
39-
match &compare.bytes {
40-
Binary(bytes) => {
25+
Binary(bytes) => { // DEPRECATED
26+
if bytes.len() > MAX_DATA_BASE58_SIZE {
27+
return Err(RpcFilterError::Base58DataTooLarge);
28+
}
4129
let bytes = bs58::decode(&bytes)
4230
.into_vec()
4331
.map_err(RpcFilterError::DecodeError)?;
@@ -48,6 +36,9 @@ impl RpcFilterType {
4836
}
4937
}
5038
Base58(bytes) => {
39+
if bytes.len() > MAX_DATA_BASE58_SIZE {
40+
return Err(RpcFilterError::DataTooLarge);
41+
}
5142
let bytes = bs58::decode(&bytes).into_vec()?;
5243
if bytes.len() > MAX_DATA_SIZE {
5344
Err(RpcFilterError::DataTooLarge)
@@ -56,14 +47,22 @@ impl RpcFilterType {
5647
}
5748
}
5849
Base64(bytes) => {
50+
if bytes.len() > MAX_DATA_BASE64_SIZE {
51+
return Err(RpcFilterError::DataTooLarge);
52+
}
5953
let bytes = base64::decode(&bytes)?;
6054
if bytes.len() > MAX_DATA_SIZE {
6155
Err(RpcFilterError::DataTooLarge)
6256
} else {
6357
Ok(())
6458
}
6559
}
66-
Bytes(_) => Ok(()),
60+
Bytes(bytes) => {
61+
if bytes.len() > MAX_DATA_SIZE {
62+
return Err(RpcFilterError::DataTooLarge);
63+
}
64+
Ok(())
65+
}
6766
}
6867
}
6968
}

0 commit comments

Comments
 (0)