Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -133,14 +133,6 @@ impl BillChainEventProcessorApi for BillChainEventProcessor {
)
.await
{
if let Err(e) = self
.chain_event_store
.remove_chain_events(&bill_id.to_string(), BlockchainType::Bill)
.await
{
error!("Failed to invalidate old bill chain events during resync: {e}");
}

for data in chain_data.iter() {
let blocks: Vec<BillBlock> = data
.iter()
Expand Down Expand Up @@ -208,6 +200,16 @@ impl BillChainEventProcessorApi for BillChainEventProcessor {
return Err(e);
}

if let Err(e) = self
.chain_event_store
.remove_chain_events(&bill_id.to_string(), BlockchainType::Bill)
.await
{
Comment on lines +203 to +207
Copy link

Copilot AI Apr 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove_chain_events is now only invoked after a preferred remote chain has been validated and applied. There is an existing unit test (test_resync_chain_skips_non_preferred_chain) that currently sets an expectation that remove_chain_events is called even when no chain candidate is accepted; with this new control flow, that expectation should be updated (e.g., expect 0 calls, or explicitly assert it is not called).

Copilot uses AI. Check for mistakes.
error!(
"Failed to invalidate old bill chain events during resync: {e}"
);
}

for event_container in data.iter() {
let event = event_container.as_chain_store_event(
&bill_id.to_string(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,14 +144,6 @@ impl CompanyChainEventProcessorApi for CompanyChainEventProcessor {
)
.await
{
if let Err(e) = self
.chain_event_store
.remove_chain_events(&company_id.to_string(), BlockchainType::Company)
.await
{
error!("Failed to invalidate old company chain events during resync: {e}");
}

for data in chain_data.iter() {
let blocks: Vec<CompanyBlock> = data
.iter()
Expand Down Expand Up @@ -219,6 +211,19 @@ impl CompanyChainEventProcessorApi for CompanyChainEventProcessor {
return Err(e);
}

if let Err(e) = self
.chain_event_store
.remove_chain_events(
&company_id.to_string(),
BlockchainType::Company,
)
.await
{
error!(
"Failed to invalidate old company chain events during resync: {e}"
);
}

for event_container in data.iter() {
let event = event_container.as_chain_store_event(
&company_id.to_string(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,17 +101,6 @@ impl IdentityChainEventProcessorApi for IdentityChainEventProcessor {
)
.await
{
if let Err(e) = self
.chain_event_store
.remove_chain_events(
&identity.node_id.to_string(),
BlockchainType::Identity,
)
.await
{
error!("Failed to invalidate old identity chain events during resync: {e}");
}

for data in chain_data.iter() {
let blocks: Vec<IdentityBlock> = data
.iter()
Expand Down Expand Up @@ -167,6 +156,19 @@ impl IdentityChainEventProcessorApi for IdentityChainEventProcessor {
return Err(e);
}

if let Err(e) = self
.chain_event_store
.remove_chain_events(
&identity.node_id.to_string(),
BlockchainType::Identity,
)
.await
{
error!(
"Failed to invalidate old identity chain events during resync: {e}"
);
}

for event_container in data.iter() {
let event = event_container.as_chain_store_event(
&identity.node_id.to_string(),
Expand Down
Loading