diff --git a/pkg/chainsync/slashfilter/mysqldb.go b/pkg/chainsync/slashfilter/mysqldb.go index beac8b15ae..bd4a704734 100644 --- a/pkg/chainsync/slashfilter/mysqldb.go +++ b/pkg/chainsync/slashfilter/mysqldb.go @@ -22,17 +22,17 @@ type MysqlSlashFilter struct { _db *gorm.DB } -//MinedBlock record mined block +// MinedBlock record mined block type MinedBlock struct { ParentEpoch int64 `gorm:"column:parent_epoch;type:bigint(20);NOT NULL"` - ParentKey string `gorm:"column:parent_key;type:varchar(1000);NOT NULL"` + ParentKey string `gorm:"column:parent_key;type:varchar(2048);NOT NULL"` Epoch int64 `gorm:"column:epoch;type:bigint(20);NOT NULL"` Miner string `gorm:"column:miner;type:varchar(256);NOT NULL"` Cid string `gorm:"column:cid;type:varchar(256);NOT NULL"` } -//NewMysqlSlashFilter create a new slash filter base on mysql database +// NewMysqlSlashFilter create a new slash filter base on mysql database func NewMysqlSlashFilter(cfg config.MySQLConfig) (ISlashFilter, error) { db, err := gorm.Open(mysql.Open(cfg.ConnectionString)) if err != nil { @@ -65,7 +65,7 @@ func NewMysqlSlashFilter(cfg config.MySQLConfig) (ISlashFilter, error) { }, nil } -//checkSameHeightFault check whether the miner mined multi block on the same height +// checkSameHeightFault check whether the miner mined multi block on the same height func (f *MysqlSlashFilter) checkSameHeightFault(bh *types.BlockHeader) error { var bk MinedBlock err := f._db.Model(&MinedBlock{}).Take(&bk, "miner=? and epoch=?", bh.Miner.String(), bh.Height).Error @@ -86,7 +86,7 @@ func (f *MysqlSlashFilter) checkSameHeightFault(bh *types.BlockHeader) error { } -//checkSameParentFault check whether the miner mined block on the same parent +// checkSameParentFault check whether the miner mined block on the same parent func (f *MysqlSlashFilter) checkSameParentFault(bh *types.BlockHeader) error { var bk MinedBlock err := f._db.Model(&MinedBlock{}).Take(&bk, "miner=? and parent_key=?", bh.Miner.String(), types.NewTipSetKey(bh.Parents...).String()).Error @@ -107,7 +107,7 @@ func (f *MysqlSlashFilter) checkSameParentFault(bh *types.BlockHeader) error { } -//MinedBlock check whether the block mined is slash +// MinedBlock check whether the block mined is slash func (f *MysqlSlashFilter) MinedBlock(ctx context.Context, bh *types.BlockHeader, parentEpoch abi.ChainEpoch) error { if err := f.checkSameHeightFault(bh); err != nil { return err