|
|
|
@@ -28,14 +28,14 @@ const ( |
|
|
|
func BlockChainIndex(ctx *context.Context) { |
|
|
|
repo := ctx.Repo.Repository |
|
|
|
if repo.ContractAddress == "" || ctx.User.PublicKey == "" { |
|
|
|
log.Error("the repo(%d) or the user(%d) has not been initialized in block_chain", repo.RepoID, ctx.User.ID) |
|
|
|
log.Error("the repo(%d) or the user(%d) has not been initialized in block_chain", repo.RepoID, ctx.User.ID, ctx.Data["msgID"]) |
|
|
|
ctx.HTML(http.StatusInternalServerError, tplBlockChainIndex) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
res, err := blockchain.GetBalance(repo.ContractAddress, ctx.User.PublicKey) |
|
|
|
if err != nil { |
|
|
|
log.Error("GetBalance(%s) failed:%v", ctx.User.PublicKey, err) |
|
|
|
log.Error("GetBalance(%s) failed:%s", ctx.User.PublicKey, err, ctx.Data["msgID"]) |
|
|
|
ctx.HTML(http.StatusInternalServerError, tplBlockChainIndex) |
|
|
|
return |
|
|
|
} |
|
|
|
@@ -52,7 +52,7 @@ func HandleBlockChainInitNotify(ctx *context.Context) { |
|
|
|
|
|
|
|
repo, err := models.GetRepositoryByID(req.RepoId) |
|
|
|
if err != nil { |
|
|
|
log.Error("GetRepositoryByID failed:", err.Error()) |
|
|
|
log.Error("GetRepositoryByID failed:%v", err.Error(), ctx.Data["msgID"]) |
|
|
|
ctx.JSON(200, map[string]string{ |
|
|
|
"code": "-1", |
|
|
|
"message": "internal error", |
|
|
|
@@ -61,7 +61,7 @@ func HandleBlockChainInitNotify(ctx *context.Context) { |
|
|
|
} |
|
|
|
|
|
|
|
if repo.BlockChainStatus == models.RepoBlockChainSuccess && len(repo.ContractAddress) != 0 { |
|
|
|
log.Error("the repo has been RepoBlockChainSuccess:", req.RepoId) |
|
|
|
log.Error("the repo has been RepoBlockChainSuccess:%d", req.RepoId, ctx.Data["msgID"]) |
|
|
|
ctx.JSON(200, map[string]string{ |
|
|
|
"code": "-1", |
|
|
|
"message": "the repo has been RepoBlockChainSuccess", |
|
|
|
@@ -73,7 +73,7 @@ func HandleBlockChainInitNotify(ctx *context.Context) { |
|
|
|
repo.ContractAddress = req.ContractAddress |
|
|
|
|
|
|
|
if err = models.UpdateRepositoryCols(repo, "block_chain_status", "contract_address"); err != nil { |
|
|
|
log.Error("UpdateRepositoryCols failed:", err.Error()) |
|
|
|
log.Error("UpdateRepositoryCols failed:%v", err.Error(), ctx.Data["msgID"]) |
|
|
|
ctx.JSON(200, map[string]string{ |
|
|
|
"code": "-1", |
|
|
|
"message": "internal error", |
|
|
|
@@ -91,7 +91,7 @@ func HandleBlockChainCommitNotify(ctx *context.Context) { |
|
|
|
var req BlockChainCommitNotify |
|
|
|
data, _ := ctx.Req.Body().Bytes() |
|
|
|
if err := json.Unmarshal(data, &req); err != nil { |
|
|
|
log.Error("json.Unmarshal failed:", err.Error()) |
|
|
|
log.Error("json.Unmarshal failed:%v", err.Error(), ctx.Data["msgID"]) |
|
|
|
ctx.JSON(200, map[string]string{ |
|
|
|
"code": "-1", |
|
|
|
"message": "response data error", |
|
|
|
@@ -101,7 +101,7 @@ func HandleBlockChainCommitNotify(ctx *context.Context) { |
|
|
|
|
|
|
|
blockChain, err := models.GetBlockChainByCommitID(req.CommitID) |
|
|
|
if err != nil { |
|
|
|
log.Error("GetRepositoryByID failed:", err.Error()) |
|
|
|
log.Error("GetRepositoryByID failed:%v", err.Error(), ctx.Data["msgID"]) |
|
|
|
ctx.JSON(200, map[string]string{ |
|
|
|
"code": "-1", |
|
|
|
"message": "internal error", |
|
|
|
@@ -110,7 +110,7 @@ func HandleBlockChainCommitNotify(ctx *context.Context) { |
|
|
|
} |
|
|
|
|
|
|
|
if blockChain.Status == models.BlockChainCommitSuccess { |
|
|
|
log.Error("the commit has been BlockChainCommitReady:", blockChain.RepoID) |
|
|
|
log.Error("the commit has been BlockChainCommitReady:%s", blockChain.RepoID, ctx.Data["msgID"]) |
|
|
|
ctx.JSON(200, map[string]string{ |
|
|
|
"code": "-1", |
|
|
|
"message": "the commit has been BlockChainCommitReady", |
|
|
|
@@ -122,7 +122,7 @@ func HandleBlockChainCommitNotify(ctx *context.Context) { |
|
|
|
blockChain.TransactionHash = req.TransactionHash |
|
|
|
|
|
|
|
if err = models.UpdateBlockChainCols(blockChain, "status", "transaction_hash"); err != nil { |
|
|
|
log.Error("UpdateBlockChainCols failed:", err.Error()) |
|
|
|
log.Error("UpdateBlockChainCols failed:%v", err.Error(), ctx.Data["msgID"]) |
|
|
|
ctx.JSON(200, map[string]string{ |
|
|
|
"code": "-1", |
|
|
|
"message": "internal error", |
|
|
|
|