Skip to content

Commit a4950dd

Browse files
committed
remove fn extended_job_to_non_segwit
since the previous commit this function is no longer necessary
1 parent 5c6db60 commit a4950dd

File tree

2 files changed

+5
-51
lines changed

2 files changed

+5
-51
lines changed

protocols/v2/roles-logic-sv2/src/job_creator.rs

Lines changed: 4 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,7 @@ use std::{collections::HashMap, convert::TryInto};
1212
use template_distribution_sv2::{NewTemplate, SetNewPrevHash};
1313
use tracing::debug;
1414

15-
use stratum_common::bitcoin::{
16-
blockdata::transaction::{Transaction, TxOut},
17-
consensus::Decodable,
18-
util::psbt::serialize::Deserialize,
19-
};
15+
use stratum_common::bitcoin::{blockdata::transaction::TxOut, consensus::Decodable};
2016

2117
#[derive(Debug)]
2218
pub struct JobsCreators {
@@ -235,45 +231,6 @@ fn new_extended_job(
235231
Ok(new_extended_mining_job)
236232
}
237233

238-
/// Helper type to strip a segwit data from the coinbase_tx_prefix and coinbase_tx_suffix
239-
/// to ensure miners are hashing with the correct coinbase
240-
pub fn extended_job_to_non_segwit(
241-
job: NewExtendedMiningJob<'static>,
242-
full_extranonce_len: usize,
243-
) -> Result<NewExtendedMiningJob<'static>, Error> {
244-
let mut encoded = job.coinbase_tx_prefix.to_vec();
245-
// just add empty extranonce space so it can be deserialized. The real extranonce
246-
// should be inserted based on the miner's shares
247-
let extranonce = vec![0_u8; full_extranonce_len];
248-
encoded.extend_from_slice(&extranonce[..]);
249-
encoded.extend_from_slice(job.coinbase_tx_suffix.inner_as_ref());
250-
let tx = Transaction::deserialize(&encoded).map_err(|_| Error::InvalidCoinbase)?;
251-
252-
let coinbase = Coinbase {
253-
tx,
254-
script_sig_prefix_len: job.coinbase_tx_prefix.len()
255-
- (
256-
4 + // version
257-
1 + // input count
258-
32 + // outpoint
259-
4 + // input index
260-
1
261-
// script length byte
262-
),
263-
};
264-
265-
Ok(NewExtendedMiningJob {
266-
channel_id: job.channel_id,
267-
job_id: job.job_id,
268-
min_ntime: job.min_ntime,
269-
version: job.version,
270-
version_rolling_allowed: job.version_rolling_allowed,
271-
merkle_path: job.merkle_path,
272-
coinbase_tx_prefix: coinbase.clone().coinbase_tx_prefix()?,
273-
coinbase_tx_suffix: coinbase.coinbase_tx_suffix()?,
274-
})
275-
}
276-
277234
// Test
278235
#[cfg(test)]
279236

@@ -284,6 +241,9 @@ pub mod tests {
284241
use binary_sv2::u256_from_int;
285242
use quickcheck::{Arbitrary, Gen};
286243
use std::{cmp, vec};
244+
use stratum_common::bitcoin::{
245+
blockdata::transaction::Transaction, util::psbt::serialize::Deserialize,
246+
};
287247

288248
#[cfg(feature = "prop_test")]
289249
use std::borrow::BorrowMut;

roles/translator/src/lib/proxy/next_mining_notify.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
use roles_logic_sv2::{
2-
job_creator::extended_job_to_non_segwit,
3-
mining_sv2::{NewExtendedMiningJob, SetNewPrevHash},
4-
};
1+
use roles_logic_sv2::mining_sv2::{NewExtendedMiningJob, SetNewPrevHash};
52
use tracing::debug;
63
use v1::{
74
server_to_client,
@@ -17,9 +14,6 @@ pub fn create_notify(
1714
new_job: NewExtendedMiningJob<'static>,
1815
clean_jobs: bool,
1916
) -> server_to_client::Notify<'static> {
20-
// TODO 32 must be changed!
21-
let new_job = extended_job_to_non_segwit(new_job, 32)
22-
.expect("failed to convert extended job to non segwit");
2317
// Make sure that SetNewPrevHash + NewExtendedMiningJob is matching (not future)
2418
let job_id = new_job.job_id.to_string();
2519

0 commit comments

Comments
 (0)