Golang implemented sidechain for Bytom
Revision | e2174b7ab523687e0f7b0a630f045616962a1b62 (tree) |
---|---|
Time | 2019-06-12 18:02:23 |
Author | HAOYUatHZ <haoyu@prot...> |
Commiter | HAOYUatHZ |
fix asset create
@@ -112,8 +112,6 @@ func (m *mainchainKeeper) processBlock(block *btmTypes.Block) error { | ||
112 | 112 | } |
113 | 113 | |
114 | 114 | func (m *mainchainKeeper) processIssuing(txs []*btmTypes.Tx) error { |
115 | - var assets []*orm.Asset | |
116 | - | |
117 | 115 | for _, tx := range txs { |
118 | 116 | for _, input := range tx.Inputs { |
119 | 117 | switch inp := input.TypedInput.(type) { |
@@ -129,17 +127,13 @@ func (m *mainchainKeeper) processIssuing(txs []*btmTypes.Tx) error { | ||
129 | 127 | VMVersion: inp.VMVersion, |
130 | 128 | RawDefinitionByte: hex.EncodeToString(inp.AssetDefinition), |
131 | 129 | } |
132 | - assets = append(assets, asset) | |
133 | - } | |
134 | - } | |
135 | - } | |
130 | + if err := m.db.Create(asset).Error; err != nil { | |
131 | + return err | |
132 | + } | |
136 | 133 | |
137 | - for _, asset := range assets { | |
138 | - if err := m.db.Create(asset).Error; err != nil { | |
139 | - return err | |
134 | + m.assetCache.Add(asset.AssetID, asset) | |
135 | + } | |
140 | 136 | } |
141 | - | |
142 | - m.assetCache.Add(asset.AssetID, asset) | |
143 | 137 | } |
144 | 138 | |
145 | 139 | return nil |