chain: Cleanup consensus logic

This commit is contained in:
Łukasz Magiera
2021-09-02 18:09:37 +02:00
parent 5831a6ba4a
commit 95b128b7bc
58 changed files with 1858 additions and 1492 deletions
+6 -4
View File
@@ -21,7 +21,7 @@ import (
type SyncAPI struct {
fx.In
SlashFilter *slashfilter.SlashFilter
SlashFilter *slashfilter.SlashFilter `optional:"true"`
Syncer *chain.Syncer
PubSub *pubsub.PubSub
NetName dtypes.NetworkName
@@ -56,9 +56,11 @@ func (a *SyncAPI) SyncSubmitBlock(ctx context.Context, blk *types.BlockMsg) erro
return xerrors.Errorf("loading parent block: %w", err)
}
if err := a.SlashFilter.MinedBlock(blk.Header, parent.Height); err != nil {
log.Errorf("<!!> SLASH FILTER ERROR: %s", err)
return xerrors.Errorf("<!!> SLASH FILTER ERROR: %w", err)
if a.SlashFilter != nil {
if err := a.SlashFilter.MinedBlock(blk.Header, parent.Height); err != nil {
log.Errorf("<!!> SLASH FILTER ERROR: %s", err)
return xerrors.Errorf("<!!> SLASH FILTER ERROR: %w", err)
}
}
// TODO: should we have some sort of fast path to adding a local block?