Creates a new state processor wired to the provided channels and state.
(
client: Client,
pending_blocks: Arc<ArcSwapOption<PendingBlocks>>,
max_depth: u64,
rx: Arc<Mutex<UnboundedReceiver<StateUpdate>>>,
sender: Sender<Arc<PendingB
| 227 | |
| 228 | /// Creates a new state processor wired to the provided channels and state. |
| 229 | pub fn new( |
| 230 | client: Client, |
| 231 | pending_blocks: Arc<ArcSwapOption<PendingBlocks>>, |
| 232 | max_depth: u64, |
| 233 | rx: Arc<Mutex<UnboundedReceiver<StateUpdate>>>, |
| 234 | sender: Sender<Arc<PendingBlocks>>, |
| 235 | ) -> Self { |
| 236 | let cache = client |
| 237 | .best_block_number() |
| 238 | .map_or_else(|_| FlashblockCache::new(0), FlashblockCache::new); |
| 239 | |
| 240 | Self { |
| 241 | pending_blocks, |
| 242 | client, |
| 243 | max_depth, |
| 244 | rx, |
| 245 | sender, |
| 246 | cache: Arc::new(Mutex::new(cache)), |
| 247 | live_state: StdMutex::new(None), |
| 248 | } |
| 249 | } |
| 250 | |
| 251 | /// Processes updates from the queue until the channel closes. |
| 252 | pub async fn start(&self) { |