@@ -47,62 +47,6 @@ impl<'b, B: DerefMut<Target=dyn BlockSource + 'b> + Sized + Sync + Send> Poll<'b
47
47
}
48
48
}
49
49
50
- pub struct MultipleChainPoller < ' a , B : DerefMut < Target =dyn BlockSource + ' a > + Sized + Sync + Send > {
51
- pollers : Vec < ( ChainPoller < ' a , B > , BlockSourceError ) > ,
52
- }
53
-
54
- impl < ' a , B : DerefMut < Target =dyn BlockSource + ' a > + Sized + Sync + Send > MultipleChainPoller < ' a , B > {
55
- pub fn new ( mut block_sources : Vec < B > ) -> Self {
56
- let pollers = block_sources. drain ( ..) . map ( |block_source| {
57
- ( ChainPoller :: new ( block_source) , BlockSourceError :: Transient )
58
- } ) . collect ( ) ;
59
- Self { pollers }
60
- }
61
- }
62
-
63
- impl < ' b , B : DerefMut < Target =dyn BlockSource + ' b > + Sized + Sync + Send > Poll < ' b , B > for MultipleChainPoller < ' b , B > {
64
- fn poll_chain_tip < ' a > ( & ' a mut self , best_chain_tip : BlockHeaderData ) ->
65
- AsyncBlockSourceResult < ' a , ( ChainTip , & ' a mut B :: Target ) >
66
- where ' b : ' a {
67
- Box :: pin ( async move {
68
- let mut heaviest_chain_tip = best_chain_tip;
69
- let mut best_result = Err ( BlockSourceError :: Persistent ) ;
70
- for ( poller, error) in self . pollers . iter_mut ( ) {
71
- if let BlockSourceError :: Persistent = error {
72
- continue ;
73
- }
74
-
75
- let result = poller. poll_chain_tip ( heaviest_chain_tip) . await ;
76
- match result {
77
- Err ( BlockSourceError :: Persistent ) => {
78
- * error = BlockSourceError :: Persistent ;
79
- } ,
80
- Err ( BlockSourceError :: Transient ) => {
81
- if best_result. is_err ( ) {
82
- best_result = result;
83
- }
84
- } ,
85
- Ok ( ( ChainTip :: Common , source) ) => {
86
- if let Ok ( ( ChainTip :: Better ( _, _) , _) ) = best_result { } else {
87
- best_result = Ok ( ( ChainTip :: Common , source) ) ;
88
- }
89
- } ,
90
- Ok ( ( ChainTip :: Better ( _, header) , _) ) => {
91
- best_result = result;
92
- heaviest_chain_tip = header;
93
- } ,
94
- Ok ( ( ChainTip :: Worse ( _, _) , _) ) => {
95
- if best_result. is_err ( ) {
96
- best_result = result;
97
- }
98
- } ,
99
- }
100
- }
101
- best_result
102
- } )
103
- }
104
- }
105
-
106
50
pub struct ChainMultiplexer < ' b , B : DerefMut < Target =dyn BlockSource + ' b > + Sized + Sync + Send > {
107
51
block_sources : Vec < ( B , BlockSourceError ) > ,
108
52
backup_block_sources : Vec < ( B , BlockSourceError ) > ,
0 commit comments