@@ -38,8 +38,7 @@ use std::hash::{Hash, Hasher};
38
38
use std:: thread:: sleep;
39
39
use std:: time:: Duration ;
40
40
41
- #[ derive( Default , Builder , Debug ) ]
42
- #[ builder( default ) ]
41
+ #[ derive( Default , Debug ) ]
43
42
struct InjectNodes < D , F >
44
43
// TODO: remove trait bound Default when this issue is fixed:
45
44
// https://github.com/colin-kiegel/rust-derive-builder/issues/93
@@ -108,28 +107,59 @@ where
108
107
109
108
( gs, peers, topic_hashes)
110
109
}
111
- }
112
110
113
- impl < D , F > InjectNodesBuilder < D , F >
114
- where
115
- D : DataTransform + Default + Clone + Send + ' static ,
116
- F : TopicSubscriptionFilter + Clone + Default + Send + ' static ,
117
- {
118
- pub fn create_network ( & self ) -> ( Gossipsub < D , F > , Vec < PeerId > , Vec < TopicHash > ) {
119
- self . build ( ) . unwrap ( ) . create_network ( )
111
+ fn peer_no ( mut self , peer_no : usize ) -> Self {
112
+ self . peer_no = peer_no;
113
+ self
114
+ }
115
+
116
+ fn topics ( mut self , topics : Vec < String > ) -> Self {
117
+ self . topics = topics;
118
+ self
119
+ }
120
+
121
+ #[ allow( clippy:: wrong_self_convention) ]
122
+ fn to_subscribe ( mut self , to_subscribe : bool ) -> Self {
123
+ self . to_subscribe = to_subscribe;
124
+ self
125
+ }
126
+
127
+ fn gs_config ( mut self , gs_config : GossipsubConfig ) -> Self {
128
+ self . gs_config = gs_config;
129
+ self
130
+ }
131
+
132
+ fn explicit ( mut self , explicit : usize ) -> Self {
133
+ self . explicit = explicit;
134
+ self
135
+ }
136
+
137
+ fn outbound ( mut self , outbound : usize ) -> Self {
138
+ self . outbound = outbound;
139
+ self
140
+ }
141
+
142
+ fn scoring ( mut self , scoring : Option < ( PeerScoreParams , PeerScoreThresholds ) > ) -> Self {
143
+ self . scoring = scoring;
144
+ self
145
+ }
146
+
147
+ fn subscription_filter ( mut self , subscription_filter : F ) -> Self {
148
+ self . subscription_filter = subscription_filter;
149
+ self
120
150
}
121
151
}
122
152
123
- fn inject_nodes < D , F > ( ) -> InjectNodesBuilder < D , F >
153
+ fn inject_nodes < D , F > ( ) -> InjectNodes < D , F >
124
154
where
125
155
D : DataTransform + Default + Clone + Send + ' static ,
126
156
F : TopicSubscriptionFilter + Clone + Default + Send + ' static ,
127
157
{
128
- InjectNodesBuilder :: default ( )
158
+ InjectNodes :: default ( )
129
159
}
130
160
131
- fn inject_nodes1 ( ) -> InjectNodesBuilder < IdentityTransform , AllowAllSubscriptionFilter > {
132
- inject_nodes ( )
161
+ fn inject_nodes1 ( ) -> InjectNodes < IdentityTransform , AllowAllSubscriptionFilter > {
162
+ InjectNodes :: < IdentityTransform , AllowAllSubscriptionFilter > :: default ( )
133
163
}
134
164
135
165
// helper functions for testing
0 commit comments