|
|
@@ -141,6 +141,20 @@ func (cfg *CloudBrainConfig) ToDB() ([]byte, error) { |
|
|
|
return json.Marshal(cfg) |
|
|
|
} |
|
|
|
|
|
|
|
type BlockChainConfig struct { |
|
|
|
EnableBlockChain bool |
|
|
|
} |
|
|
|
|
|
|
|
// FromDB fills up a CloudBrainConfig from serialized format. |
|
|
|
func (cfg *BlockChainConfig) FromDB(bs []byte) error { |
|
|
|
return json.Unmarshal(bs, &cfg) |
|
|
|
} |
|
|
|
|
|
|
|
// ToDB exports a CloudBrainConfig to a serialized format. |
|
|
|
func (cfg *BlockChainConfig) ToDB() ([]byte, error) { |
|
|
|
return json.Marshal(cfg) |
|
|
|
} |
|
|
|
|
|
|
|
// BeforeSet is invoked from XORM before setting the value of a field of this object. |
|
|
|
func (r *RepoUnit) BeforeSet(colName string, val xorm.Cell) { |
|
|
|
switch colName { |
|
|
@@ -160,6 +174,8 @@ func (r *RepoUnit) BeforeSet(colName string, val xorm.Cell) { |
|
|
|
r.Config = new(DatasetConfig) |
|
|
|
case UnitTypeCloudBrain: |
|
|
|
r.Config = new(CloudBrainConfig) |
|
|
|
case UnitTypeBlockChain: |
|
|
|
r.Config = new(BlockChainConfig) |
|
|
|
default: |
|
|
|
panic("unrecognized repo unit type: " + com.ToStr(*val)) |
|
|
|
} |
|
|
|