-
Notifications
You must be signed in to change notification settings - Fork 125
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
feat(statement-distribution):Implement FanIn approach to statement distribution #4406
base: feat/parachain
Are you sure you want to change the base?
feat(statement-distribution):Implement FanIn approach to statement distribution #4406
Conversation
@EclesioMeloJunior Currently, if i follow the implementation in pseudo code, we need to require passing all channels explicitly as function arguments, which can make the code less flexible and harder to maintain as new channels are added or removed. in run func (s StatementDistribution) Run(
ctx context.Context,
channels map[string]<-chan any,
) {
muxedChannel := FanIn(ctx, channels)
for {
select {
case muxedMsg := <-muxedChannel:
err := s.processMuxedMessage(muxedMsg)
if err != nil {
logger.Errorf("error processing muxed message: %v", err)
}
case <-ctx.Done():
logger.Infof("shutting down: %v", ctx.Err())
return
}
}
} fanIn Function func FanIn(
ctx context.Context,
channels map[string]<-chan any,
) <-chan MuxedMessage {
output := make(chan MuxedMessage)
go func() {
defer close(output)
for {
select {
case <-ctx.Done():
return
default:
// Iterate through channels
for source, ch := range channels {
select {
case msg, ok := <-ch:
if ok {
output <- MuxedMessage{Source: source, Message: msg}
}
default:
// Non-blocking check
}
}
}
}
}()
return output
} what do you think? |
@DanielDDHM using the for loop is too much given that the amount of channels don't change, also the Also you should define a timer to trigger the reputation aggregator to send the reputation changes. So what you can do is, instead of the Btw, I've changed the task to don't include the |
@EclesioMeloJunior could you take a look on the new approach? |
Changes
Implement FanIn approach to statement distribution
Tests
Unit Tests: Core logic is tested in isolation using testify for assertions
go test -tags integration github.com/ChainSafe/gossamer
Issues
FanIn
approach to statement distribution #4390