Commit 61acebbc authored by ligaishun's avatar ligaishun

Delete pai_latest.txt

parent 077ec185
package v1
import (
"os"
"path"
"os/exec"
"strings"
"net/http"
"chain33-pai/pkg/e"
"chain33-pai/pkg/app"
"github.com/gin-gonic/gin"
"chain33-pai/service/pai_service"
)
func GetDevdetail(c *gin.Context) {
appG := app.Gin{C: c}
var pai pai_service.Pai
ok := pai.GetConfig()
if !ok {
appG.Response(http.StatusOK, e.ERROR, nil)
}
appG.Response(http.StatusOK, e.SUCCESS, map[string]interface{}{
"serial": pai.Serial,
})
}
func GetDevstatus(c *gin.Context) {
appG := app.Gin{C: c}
var pai pai_service.Pai
err := pai.GetDevstatus()
if err != nil {
appG.Response(http.StatusOK, e.ERROR, nil)
}
appG.Response(http.StatusOK, e.SUCCESS, pai)
}
func ResetWallet(c *gin.Context) {
appG := app.Gin{C: c}
buffer:=app.GetProcessInfo("wallet.db")
if buffer.String()==""{
appG.Response(http.StatusInternalServerError, e.ERROR, gin.H{
"info":"node is not running",
})
return
}
record:=app.StrFilter(strings.Split(buffer.String()," "))
wallet:=app.ProcessInfo{
PName:record[0],
Pid: record[1],
User: record[2],
Path: path.Dir(path.Dir(record[8])),
}
cmd:=exec.Command("kill","-9",wallet.Pid)
err:=cmd.Start()
if err!=nil{
appG.Response(http.StatusInternalServerError, e.ERROR, gin.H{
"info":"failed to reset wallet",
})
return
}
err=os.RemoveAll(wallet.Path)
if err!=nil{
appG.Response(http.StatusInternalServerError, e.ERROR, gin.H{
"info":"failed to reset wallet",
})
return
}
cmd=exec.Command(path.Dir( wallet.Path)+"/"+wallet.PName)
err=cmd.Start()
if err!=nil{
appG.Response(http.StatusInternalServerError, e.ERROR, gin.H{
"info":"failed to restart node",
})
return
}
appG.Response(http.StatusOK, e.SUCCESS,nil)
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment