Skip to content

Commit 921cedd

Browse files
committed
feat: handle IPC stream restarts
Signed-off-by: ljedrz <ljedrz@users.noreply.github.com>
1 parent bc9607f commit 921cedd

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

synthesizer/src/vm/helpers/sequential_op.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,11 @@ impl<N: Network, C: ConsensusStorage<N>> VM<N, C> {
4949
let ret = vm.add_next_block_inner(block);
5050
#[cfg(feature = "announce-blocks")]
5151
if ret.is_ok() {
52-
let _ = announce_block(&mut stream, ipc_payload);
52+
if let Err(e) = announce_block(&mut stream, ipc_payload) {
53+
error!("IPC error: {e}");
54+
// Attempt to restart the stream.
55+
stream = start_block_announcement_stream();
56+
}
5357
}
5458
SequentialOperationResult::AddNextBlock(ret)
5559
}
@@ -164,11 +168,11 @@ fn start_block_announcement_stream() -> Option<Stream> {
164168

165169
match Stream::connect(path) {
166170
Ok(stream) => {
167-
debug!("Successfully started the IPC stream for block announcements");
171+
debug!("Successfully (re)started the IPC stream for block announcements");
168172
Some(stream)
169173
}
170174
Err(e) => {
171-
warn!("Couldn't start the IPC stream for block announcements: {e}");
175+
warn!("Couldn't (re)start the IPC stream for block announcements: {e}");
172176
None
173177
}
174178
}

0 commit comments

Comments
 (0)