Browse Source

mod

tags/v1.21.12.1
yuyuanshifu 4 years ago
parent
commit
cfd243b4e5
2 changed files with 6 additions and 5 deletions
  1. +5
    -3
      modules/blockchain/resty.go
  2. +1
    -2
      routers/repo/blockchain.go

+ 5
- 3
modules/blockchain/resty.go View File

@@ -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)


+ 1
- 2
routers/repo/blockchain.go View File

@@ -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)
}


Loading…
Cancel
Save