Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/cid-pk' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
457813723 committed Mar 7, 2024
2 parents 2fd6c2f + 1254af6 commit 0a9e015
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions http_server/handle/store_cid_pk.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ func (h *HttpHandle) doStoreCidPk(req *ReqStoreCidPk, apiResp *http_api.ApiResp)
signMsg := req.Msg
signature := req.Signature
address := signAddressHex.AddressHex
if address[:20] != hex.EncodeToString(common.CalculateCid1(req.Cid)) {
cid1 := common.CalculateCid1(req.Cid)
if address[:20] != hex.EncodeToString(cid1) {
apiResp.ApiRespErr(http_api.ApiCodeParamsInvalid, "cid err")
return nil
}
Expand All @@ -75,7 +76,7 @@ func (h *HttpHandle) doStoreCidPk(req *ReqStoreCidPk, apiResp *http_api.ApiResp)
var cidPk tables.TableCidPk
cidPk.OriginPk = sign.GetPkFromSignature(common.Hex2Bytes(signature))
cidPk.Pk = address[20:]
cidPk.Cid = req.Cid
cidPk.Cid = common.Bytes2Hex(cid1)
if err := h.dbDao.InsertCidPk(cidPk); err != nil {
apiResp.ApiRespErr(http_api.ApiCodeDbError, "InsertCidPk err")
return fmt.Errorf("InsertCidPk err: %s", err.Error())
Expand Down
2 changes: 1 addition & 1 deletion tables/t_cid_pk.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const (

type TableCidPk struct {
Id uint64 `json:"id" gorm:"column:id;primaryKey;type:bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT ''"`
Cid string `json:"cid" gorm:"column:cid; type:varchar(255) NOT NULL DEFAULT '0'"`
Cid string `json:"cid" gorm:"column:cid;uniqueIndex:uk_cid; type:varchar(255) NOT NULL DEFAULT '0'"`
Pk string `json:"pk" gorm:"column:pk; type:varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT '';"`
OriginPk string `json:"origin_pk" gorm:"column:origin_pk; type:varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT ''"`
EnableAuthorize IsEnableAuthorize `json:"enable_authorize" gorm:"column:enable_authorize; type:tinyint NOT NULL DEFAULT '0'"`
Expand Down

0 comments on commit 0a9e015

Please sign in to comment.