From cfd243b4e5ecb2c98811eea9f53480286ba0f5f1 Mon Sep 17 00:00:00 2001 From: yuyuanshifu <747342561@qq.com> Date: Wed, 20 Jan 2021 10:18:17 +0800 Subject: [PATCH] mod --- modules/blockchain/resty.go | 8 +++++--- routers/repo/blockchain.go | 3 +-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/modules/blockchain/resty.go b/modules/blockchain/resty.go index 060d63144..4a736a4f1 100755 --- a/modules/blockchain/resty.go +++ b/modules/blockchain/resty.go @@ -2,6 +2,7 @@ package blockchain import ( "fmt" + "strconv" "code.gitea.io/gitea/modules/setting" "github.com/go-resty/resty/v2" @@ -43,7 +44,7 @@ type NewRepoResult struct { type ContributeResult struct { Code int `json:"code"` Msg string `json:"message"` - Payload map[string]interface{} `json:"data"` + //Payload map[string]interface{} `json:"data"` } func getRestyClient() *resty.Client { @@ -122,10 +123,11 @@ func GetBalance(contractAddress, contributor string) (*GetBalanceResult, error) return &result, nil } -func Contribute(contractAddress, contributor, action, commitId string, codeLine int) (*ContributeResult, error) { +func Contribute(contractAddress, contributor, action, commitId string, codeLine int64) (*ContributeResult, error) { client := getRestyClient() var result ContributeResult + amount := strconv.FormatInt(codeLine, 10) res, err := client.R(). SetHeader("Accept", "application/json"). SetQueryParams(map[string]string{ @@ -133,7 +135,7 @@ func Contribute(contractAddress, contributor, action, commitId string, codeLine "contributor" : contributor, "action" : action, "commitId": commitId, - "amount": string(codeLine), + "amount": amount, }). SetResult(&result). Get(setting.BlockChainHost + UrlContribute) diff --git a/routers/repo/blockchain.go b/routers/repo/blockchain.go index 9aa705574..f6ced9194 100755 --- a/routers/repo/blockchain.go +++ b/routers/repo/blockchain.go @@ -130,7 +130,6 @@ func HandleBlockChainUnSuccessRepos() { continue } strRepoID := strconv.FormatInt(repo.ID, 10) - log.Info(strRepoID) _, err = blockchain.NewRepo(strRepoID, repo.Owner.PublicKey, repo.Name) if err != nil { log.Error("blockchain.NewRepo(%s) failed:%v", strRepoID, err) @@ -148,7 +147,7 @@ func HandleBlockChainUnSuccessCommits() { } for _, block_chain := range blockChains { - _, err = blockchain.Contribute(block_chain.ContractAddress, block_chain.Contributor, blockchain.ActionCommit, block_chain.CommitID, int(block_chain.Amount)) + _, err = blockchain.Contribute(block_chain.ContractAddress, block_chain.Contributor, blockchain.ActionCommit, block_chain.CommitID, block_chain.Amount) if err != nil { log.Error("blockchain.Contribute(%s) failed:%v", block_chain.CommitID, err) }