Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: ♻️ Separate MSP and BSP specific functionalities in Blockchain Service #386

Merged
merged 15 commits into from
Feb 28, 2025

Conversation

ffarall
Copy link
Contributor

@ffarall ffarall commented Feb 27, 2025

This PR refactors some of the functionality in the handler.rs and utils.rs files of the Blockchain Service, to the new files handler_msp.rs and handler_bsp.rs. The goal is to keep BSP/MSP specific functionality better separated in the Blockchain Service.

@ffarall ffarall marked this pull request as ready for review February 28, 2025 18:23
Copy link
Contributor

@snowmead snowmead left a comment

Choose a reason for hiding this comment

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

Nice job!

Future improvement: I suggest we separate the blockchain service command/event handlers by actor (MSP/BSP) as to avoid having all events and commands being implemented in a single place. It would be much clearer to the which actor is interested in.

It is clear though the separation of the two actors, but harder to maintain the codebase since the context is global.

if forest_root_write_result.is_ok() {
    match managed_bsp_or_msp {
        ManagedProvider::Msp(_) => {
            self.msp_assign_forest_root_write_lock();
        }
        ManagedProvider::Bsp(_) => {
            self.bsp_assign_forest_root_write_lock();
        }
    }
}

We can avoid this handling by having individual handlers for each actor.

@ffarall
Copy link
Contributor Author

ffarall commented Feb 28, 2025

Future improvement: I suggest we separate the blockchain service command/event handlers by actor (MSP/BSP) as to avoid having all events and commands being implemented in a single place. It would be much clearer to the which actor is interested in.

@snowmead yeah I agree, I didn't want to over extend this PR, and the BSP/MSP specific commands was less of a problem in my view, than the other things I separated. But I agree, we can do that down the line too.

@ffarall ffarall merged commit 9010b83 into main Feb 28, 2025
9 checks passed
@ffarall ffarall deleted the refactor/separate-msp-and-bsp-in-blockchain-svc branch February 28, 2025 21:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants