Fix the known issue with the DSA

I wrote it to only select TXs with a timelock, not only TXs which are unlocked.
This most likely explains why it so heavily selected coinbases.

Also moves an InternalError which would've never been hit on mainnet, yet
technically isn't an invariant, to only exist when cfg(test).
This commit is contained in:
Luke Parker
2023-07-04 18:07:27 -04:00
parent 89eef95fb3
commit b195db0929
3 changed files with 20 additions and 13 deletions

View File

@@ -138,7 +138,7 @@ impl<R: RpcConnection> Rpc<R> {
)
.map_err(|_| RpcError::InvalidNode)?,
)
.map_err(|_| RpcError::InternalError("Failed to parse JSON response"))
.map_err(|_| RpcError::InvalidNode)
}
/// Perform a JSON-RPC call with the specified method with the provided parameters
@@ -538,12 +538,10 @@ impl<R: RpcConnection> Rpc<R> {
.iter()
.enumerate()
.map(|(i, out)| {
Ok(Some([rpc_point(&out.key)?, rpc_point(&out.mask)?]).filter(|_| {
match txs[i].prefix.timelock {
Timelock::Block(t_height) => t_height <= height,
_ => false,
}
}))
Ok(
Some([rpc_point(&out.key)?, rpc_point(&out.mask)?])
.filter(|_| Timelock::Block(height) >= txs[i].prefix.timelock),
)
})
.collect()
}