@@ -179,14 +179,14 @@ pub struct Downstream {
179
179
receiver : tokio:: sync:: broadcast:: Sender < EitherFrame > ,
180
180
sender : tokio:: sync:: broadcast:: Sender < EitherFrame > ,
181
181
downstream_data : CommonDownstreamData ,
182
- solution_sender : Sender < SubmitSolution < ' static > > ,
182
+ solution_sender : tokio :: sync :: mpsc :: Sender < SubmitSolution < ' static > > ,
183
183
channel_factory : Arc < Mutex < PoolChannelFactory > > ,
184
184
}
185
185
186
186
/// Accept downstream connection
187
187
pub struct Pool {
188
188
downstreams : HashMap < u32 , Arc < Mutex < Downstream > > , BuildNoHashHasher < u32 > > ,
189
- solution_sender : Sender < SubmitSolution < ' static > > ,
189
+ solution_sender : tokio :: sync :: mpsc :: Sender < SubmitSolution < ' static > > ,
190
190
new_template_processed : bool ,
191
191
channel_factory : Arc < Mutex < PoolChannelFactory > > ,
192
192
last_prev_hash_template_id : u64 ,
@@ -242,7 +242,7 @@ impl Downstream {
242
242
} )
243
243
. await
244
244
{
245
- error ! ( "Encountered Error but status channel is down: {}" , e) ;
245
+ error ! ( "Encountered Error but status channel is down: {:? }" , e) ;
246
246
}
247
247
248
248
return ;
@@ -491,13 +491,13 @@ impl Pool {
491
491
492
492
async fn on_new_prev_hash (
493
493
self_ : Arc < Mutex < Self > > ,
494
- rx : Receiver < SetNewPrevHash < ' static > > ,
495
- sender_message_received_signal : Sender < ( ) > ,
494
+ mut rx : tokio :: sync :: mpsc :: Receiver < SetNewPrevHash < ' static > > ,
495
+ sender_message_received_signal : tokio :: sync :: broadcast :: Sender < ( ) > ,
496
496
) -> PoolResult < ( ) > {
497
497
let status_tx = self_
498
498
. safe_lock ( |s| s. status_tx . clone ( ) )
499
499
. map_err ( |e| PoolError :: PoisonLock ( e. to_string ( ) ) ) ?;
500
- while let Ok ( new_prev_hash) = rx. recv ( ) . await {
500
+ while let Some ( new_prev_hash) = rx. recv ( ) . await {
501
501
debug ! ( "New prev hash received: {:?}" , new_prev_hash) ;
502
502
let res = self_
503
503
. safe_lock ( |s| {
@@ -537,7 +537,7 @@ impl Pool {
537
537
. await ;
538
538
handle_result ! ( status_tx, res) ;
539
539
}
540
- handle_result ! ( status_tx, sender_message_received_signal. send( ( ) ) . await ) ;
540
+ handle_result ! ( status_tx, sender_message_received_signal. send( ( ) ) ) ;
541
541
}
542
542
Err ( _) => todo ! ( ) ,
543
543
}
@@ -547,12 +547,12 @@ impl Pool {
547
547
548
548
async fn on_new_template (
549
549
self_ : Arc < Mutex < Self > > ,
550
- rx : Receiver < NewTemplate < ' static > > ,
551
- sender_message_received_signal : Sender < ( ) > ,
550
+ mut rx : tokio :: sync :: mpsc :: Receiver < NewTemplate < ' static > > ,
551
+ sender_message_received_signal : tokio :: sync :: broadcast :: Sender < ( ) > ,
552
552
) -> PoolResult < ( ) > {
553
553
let status_tx = self_. safe_lock ( |s| s. status_tx . clone ( ) ) ?;
554
554
let channel_factory = self_. safe_lock ( |s| s. channel_factory . clone ( ) ) ?;
555
- while let Ok ( mut new_template) = rx. recv ( ) . await {
555
+ while let Some ( mut new_template) = rx. recv ( ) . await {
556
556
debug ! (
557
557
"New template received, creating a new mining job(s): {:?}" ,
558
558
new_template
@@ -584,17 +584,17 @@ impl Pool {
584
584
. map_err ( |e| PoolError :: PoisonLock ( e. to_string ( ) ) ) ;
585
585
handle_result ! ( status_tx, res) ;
586
586
587
- handle_result ! ( status_tx, sender_message_received_signal. send( ( ) ) . await ) ;
587
+ handle_result ! ( status_tx, sender_message_received_signal. send( ( ) ) ) ;
588
588
}
589
589
Ok ( ( ) )
590
590
}
591
591
592
592
pub fn start (
593
593
config : Configuration ,
594
- new_template_rx : Receiver < NewTemplate < ' static > > ,
595
- new_prev_hash_rx : Receiver < SetNewPrevHash < ' static > > ,
596
- solution_sender : Sender < SubmitSolution < ' static > > ,
597
- sender_message_received_signal : Sender < ( ) > ,
594
+ new_template_rx : tokio :: sync :: mpsc :: Receiver < NewTemplate < ' static > > ,
595
+ new_prev_hash_rx : tokio :: sync :: mpsc :: Receiver < SetNewPrevHash < ' static > > ,
596
+ solution_sender : tokio :: sync :: mpsc :: Sender < SubmitSolution < ' static > > ,
597
+ sender_message_received_signal : tokio :: sync :: broadcast :: Sender < ( ) > ,
598
598
status_tx : status:: Sender ,
599
599
) -> Arc < Mutex < Self > > {
600
600
let extranonce_len = 32 ;
@@ -744,8 +744,8 @@ impl Pool {
744
744
745
745
// use super::Configuration;
746
746
747
- // // this test is used to verify the `coinbase_tx_prefix` and `coinbase_tx_suffix` values tested
748
- // // against in message generator
747
+ // // this test is used to verify the `coinbase_tx_prefix` and `coinbase_tx_suffix` values
748
+ // tested // against in message generator
749
749
// // `stratum/test/message-generator/test/pool-sri-test-extended.json`
750
750
// #[test]
751
751
// fn test_coinbase_outputs_from_config() {
@@ -778,9 +778,9 @@ impl Pool {
778
778
// let _coinbase_tx_value_remaining: u64 = 625000000;
779
779
// let _coinbase_tx_outputs_count = 0;
780
780
// let coinbase_tx_locktime = 0;
781
- // let coinbase_tx_outputs: Vec<bitcoin::TxOut> = super::get_coinbase_output(&config).unwrap();
782
- // // extranonce len set to max_extranonce_size in `ChannelFactory::new_extended_channel()`
783
- // let extranonce_len = 32;
781
+ // let coinbase_tx_outputs: Vec<bitcoin::TxOut> =
782
+ // super::get_coinbase_output(&config).unwrap(); // extranonce len set to
783
+ // max_extranonce_size in `ChannelFactory::new_extended_channel()` let extranonce_len = 32;
784
784
785
785
// // build coinbase TX from 'job_creator::coinbase()'
786
786
@@ -813,9 +813,9 @@ impl Pool {
813
813
// coinbase_tx_prefix
814
814
// == [
815
815
// 2, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
816
- // 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 56, 3, 76, 163, 38,
817
- // 0, 83, 116, 114, 97, 116, 117, 109, 32, 118, 50, 32, 83, 82, 73, 32, 80, 111 ,
818
- // 111, 108
816
+ // 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 56, 3, 76, 163,
817
+ // 38, 0, 83, 116, 114, 97, 116, 117, 109, 32, 118, 50, 32, 83, 82, 73, 32, 80,
818
+ // 111, 111, 108
819
819
// ]
820
820
// .to_vec()
821
821
// .try_into()
@@ -827,8 +827,8 @@ impl Pool {
827
827
// == [
828
828
// 255, 255, 255, 255, 1, 0, 0, 0, 0, 0, 0, 0, 0, 22, 0, 20, 235, 225, 183, 220,
829
829
// 194, 147, 204, 170, 14, 231, 67, 168, 111, 137, 223, 130, 88, 194, 8, 252, 1,
830
- // 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
831
- // 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
830
+ // 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
831
+ // 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
832
832
// ]
833
833
// .to_vec()
834
834
// .try_into()
@@ -840,8 +840,8 @@ impl Pool {
840
840
// // copied from roles-logic-sv2::job_creator
841
841
// fn coinbase_tx_prefix(coinbase: &Transaction, script_prefix_len: usize) -> B064K<'static> {
842
842
// let encoded = coinbase.serialize();
843
- // // If script_prefix_len is not 0 we are not in a test enviornment and the coinbase have the
844
- // // 0 witness
843
+ // // If script_prefix_len is not 0 we are not in a test enviornment and the coinbase have
844
+ // the // 0 witness
845
845
// let segwit_bytes = match script_prefix_len {
846
846
// 0 => 0,
847
847
// _ => 2,
@@ -864,8 +864,8 @@ impl Pool {
864
864
// script_prefix_len: usize,
865
865
// ) -> B064K<'static> {
866
866
// let encoded = coinbase.serialize();
867
- // // If script_prefix_len is not 0 we are not in a test enviornment and the coinbase have the
868
- // // 0 witness
867
+ // // If script_prefix_len is not 0 we are not in a test enviornment and the coinbase have
868
+ // the // 0 witness
869
869
// let segwit_bytes = match script_prefix_len {
870
870
// 0 => 0,
871
871
// _ => 2,
@@ -877,8 +877,7 @@ impl Pool {
877
877
// + 4 // index
878
878
// + 1 // bytes in script TODO can be also 3
879
879
// + script_prefix_len // bip34_bytes
880
- // + (extranonce_len as usize)..]
881
- // .to_vec();
880
+ // + (extranonce_len as usize)..] .to_vec();
882
881
// r.try_into().unwrap()
883
882
// }
884
883
0 commit comments