OSDN Git Service

Define ErrInternalAsset (#249)
authoricodezjb <icodezjb@163.com>
Fri, 5 Jan 2018 08:13:11 +0000 (16:13 +0800)
committerPaladz <yzhu101@uottawa.ca>
Fri, 5 Jan 2018 08:13:11 +0000 (16:13 +0800)
blockchain/asset/asset.go
cmd/bytomcli/commands/account.go
cmd/bytomcli/commands/asset.go

index 7c842cb..c7c42ca 100755 (executable)
@@ -44,6 +44,7 @@ var (
        ErrSerializing    = errors.New("serializing asset definition")
        ErrMarshalAsset   = errors.New("failed marshal asset")
        ErrFindAsset      = errors.New("fail to find asset")
+       ErrInternalAsset  = errors.New("btm has been defined as the internal asset")
 )
 
 //NewRegistry create new registry
@@ -91,6 +92,10 @@ func (asset *Asset) RawDefinition() []byte {
 
 // Define defines a new Asset.
 func (reg *Registry) Define(ctx context.Context, xpubs []chainkd.XPub, quorum int, definition map[string]interface{}, alias string, tags map[string]interface{}, clientToken string) (*Asset, error) {
+       if alias == "btm" {
+               return nil, ErrInternalAsset
+       }
+
        if existed := reg.db.Get(aliasKey(alias)); existed != nil {
                return nil, ErrDuplicateAlias
        }
index 0aab322..772086a 100755 (executable)
@@ -107,10 +107,8 @@ var deleteAccountCmd = &cobra.Command{
 
 var updateAccountTagsCmd = &cobra.Command{
        Use:   "update-account-tags <accountID|alias>",
-       Short: "Add, update or delete the account tags",
-       Long: `If the tags match the pattern 'key:value', add or update them.
-If the tags match the pattern 'key:', delete them.`,
-       Args: cobra.ExactArgs(1),
+       Short: "Update the account tags",
+       Args:  cobra.ExactArgs(1),
        PreRun: func(cmd *cobra.Command, args []string) {
                cmd.MarkFlagRequired("tags")
        },
index 18b2892..4eae571 100755 (executable)
@@ -98,10 +98,8 @@ var listAssetsCmd = &cobra.Command{
 
 var updateAssetTagsCmd = &cobra.Command{
        Use:   "update-asset-tags <assetID|alias>",
-       Short: "Add, update or delete the asset tags",
-       Long: `If the tags match the pattern 'key:value', add or update them.
-If the tags match the pattern 'key:', delete them.`,
-       Args: cobra.ExactArgs(1),
+       Short: "Update the asset tags",
+       Args:  cobra.ExactArgs(1),
        PreRun: func(cmd *cobra.Command, args []string) {
                cmd.MarkFlagRequired("tags")
        },