Golang implemented sidechain for Bytom
修订版 | 8a5b960a8ec548200960f408c25a458822eaccf6 (tree) |
---|---|
时间 | 2019-10-23 21:17:58 |
作者 | wz <mars@byto...> |
Commiter | wz |
fix
@@ -21,6 +21,7 @@ CREATE TABLE `chains` ( | ||
21 | 21 | `name` varchar(64) NOT NULL, |
22 | 22 | `block_height` int(11) DEFAULT '0', |
23 | 23 | `block_hash` char(64) NOT NULL, |
24 | + `is_filter` tinyint(1) DEFAULT '0', | |
24 | 25 | `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, |
25 | 26 | `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, |
26 | 27 | PRIMARY KEY (`id`), |
@@ -77,12 +77,9 @@ func (s *Server) AddFilterAssetIDs(c *gin.Context, req *filterAssetIDReq) error | ||
77 | 77 | batch := s.db.Begin() |
78 | 78 | for _, assetID := range req.AssetIDs { |
79 | 79 | filterAsset := &orm.FilterAsset{AssetID: assetID} |
80 | - err := batch.Find(filterAsset).Error | |
81 | - if err == nil { | |
80 | + if err := batch.Find(filterAsset).Error; err == nil { | |
82 | 81 | continue |
83 | - } | |
84 | - | |
85 | - if err != gorm.ErrRecordNotFound { | |
82 | + } else if err != gorm.ErrRecordNotFound { | |
86 | 83 | return err |
87 | 84 | } |
88 | 85 |
@@ -375,7 +375,7 @@ func (m *mainchainKeeper) checkFilterAssetIDUpdate() error { | ||
375 | 375 | |
376 | 376 | func (m *mainchainKeeper) fillFilterAssetID() error { |
377 | 377 | filterAssets := []*orm.FilterAsset{} |
378 | - if err := m.db.Find(filterAssets).Order("id asc").Error; err != nil { | |
378 | + if err := m.db.Find(&filterAssets).Where("id > ?", len(m.filterAssets)).Order("id asc").Error; err != nil { | |
379 | 379 | return err |
380 | 380 | } |
381 | 381 |