This commit is contained in:
+16
-3
@@ -154,8 +154,8 @@ pub fn parse_configure_response(
|
||||
}
|
||||
}
|
||||
|
||||
/// Decode both offered BIP310 extensions. The response must explicitly
|
||||
/// acknowledge each advertised extension before its notifications are used.
|
||||
/// Decode both offered BIP310 extensions. An omitted extranonce extension is
|
||||
/// unsupported; its notifications cannot be used without an explicit grant.
|
||||
pub fn parse_configure_result(
|
||||
line: &[u8],
|
||||
request_id: u64,
|
||||
@@ -168,7 +168,7 @@ pub fn parse_configure_result(
|
||||
.ok_or(PoolMessageError::InvalidField)?;
|
||||
let subscribe_extranonce = match result.get("subscribe-extranonce") {
|
||||
Some(Value::Bool(value)) => *value,
|
||||
Some(Value::String(_)) => false,
|
||||
Some(Value::String(_)) | None => false,
|
||||
_ => return Err(PoolMessageError::InvalidField),
|
||||
};
|
||||
Ok(ConfigureResult {
|
||||
@@ -293,3 +293,16 @@ pub fn parse_notify(line: &[u8], subscription: &Subscription) -> Result<PoolJob,
|
||||
work,
|
||||
})
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod configure_tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn omitted_extranonce_extension_is_unsupported() {
|
||||
let line = br#"{"id":1,"result":{"version-rolling":true,"version-rolling.mask":"1fffe000"},"error":null}"#;
|
||||
let result = parse_configure_result(line, 1).unwrap();
|
||||
assert!(result.version_mask.is_some());
|
||||
assert!(!result.subscribe_extranonce);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user