Merge pull request #2852 from filecoin-project/jeff

Jeff
This commit is contained in:
Łukasz Magiera
2020-08-06 13:01:14 +02:00
committed by GitHub
11 changed files with 167 additions and 11 deletions
+15 -3
View File
@@ -11,6 +11,7 @@ import (
"github.com/filecoin-project/lotus/api"
"github.com/filecoin-project/lotus/build"
"github.com/filecoin-project/lotus/chain"
"github.com/filecoin-project/lotus/chain/gen/slashfilter"
"github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/lotus/node/modules/dtypes"
)
@@ -18,9 +19,10 @@ import (
type SyncAPI struct {
fx.In
Syncer *chain.Syncer
PubSub *pubsub.PubSub
NetName dtypes.NetworkName
SlashFilter *slashfilter.SlashFilter
Syncer *chain.Syncer
PubSub *pubsub.PubSub
NetName dtypes.NetworkName
}
func (a *SyncAPI) SyncState(ctx context.Context) (*api.SyncState, error) {
@@ -44,6 +46,16 @@ func (a *SyncAPI) SyncState(ctx context.Context) (*api.SyncState, error) {
}
func (a *SyncAPI) SyncSubmitBlock(ctx context.Context, blk *types.BlockMsg) error {
parent, err := a.Syncer.ChainStore().GetBlock(blk.Header.Parents[0])
if err != nil {
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)
}
// TODO: should we have some sort of fast path to adding a local block?
bmsgs, err := a.Syncer.ChainStore().LoadMessagesFromCids(blk.BlsMessages)
if err != nil {