本文整理汇总了Golang中github.com/c-darwin/dcoin-go/packages/utils.ErrInfo函数的典型用法代码示例。如果您正苦于以下问题:Golang ErrInfo函数的具体用法?Golang ErrInfo怎么用?Golang ErrInfo使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ErrInfo函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: Information
func (c *Controller) Information() (string, error) {
var err error
alertMessages_, err := c.GetAll(`SELECT * FROM alert_messages ORDER BY id DESC`, -1)
var alertMessages []map[string]string
for _, v := range alertMessages_ {
show := false
if v["currency_list"] != "ALL" {
// проверим, есть ли у нас обещнные суммы с такой валютой
amounts, err := c.Single("SELECT id FROM promised_amount WHERE currency_id IN (" + v["currency_list"] + ")").Int64()
if err != nil {
return "", utils.ErrInfo(err)
}
if amounts > 0 {
show = true
}
} else {
show = true
}
if show {
alertMessages = append(alertMessages, map[string]string{"id": v["id"], "message": v["message"]})
}
}
TemplateStr, err := makeTemplate("information", "information", &InformationPage{
Lang: c.Lang,
AlertMessages: alertMessages})
if err != nil {
return "", utils.ErrInfo(err)
}
return TemplateStr, nil
}
开发者ID:dzyk,项目名称:dcoin-go,代码行数:33,代码来源:information.go
示例2: Upgrade5
func (c *Controller) Upgrade5() (string, error) {
log.Debug("Upgrade5")
geolocationLat := ""
geolocationLon := ""
geolocation, err := c.Single("SELECT geolocation FROM " + c.MyPrefix + "my_table").String()
if err != nil {
return "", utils.ErrInfo(err)
}
if len(geolocation) > 0 {
x := strings.Split(geolocation, ", ")
if len(x) == 2 {
geolocationLat = x[0]
geolocationLon = x[1]
}
}
saveAndGotoStep := strings.Replace(c.Lang["save_and_goto_step"], "[num]", "7", -1)
upgradeMenu := utils.MakeUpgradeMenu(5)
TemplateStr, err := makeTemplate("upgrade_5", "upgrade5", &upgrade5Page{
Alert: c.Alert,
Lang: c.Lang,
SaveAndGotoStep: saveAndGotoStep,
UpgradeMenu: upgradeMenu,
GeolocationLat: geolocationLat,
GeolocationLon: geolocationLon,
UserId: c.SessUserId,
Mobile: utils.Mobile()})
if err != nil {
return "", utils.ErrInfo(err)
}
return TemplateStr, nil
}
开发者ID:dzyk,项目名称:dcoin-go,代码行数:35,代码来源:upgrade_5.go
示例3: SaveNotifications
func (c *Controller) SaveNotifications() (string, error) {
if c.SessRestricted != 0 {
return "", utils.ErrInfo(errors.New("Permission denied"))
}
c.r.ParseForm()
var data []map[string]interface{}
err := json.Unmarshal([]byte(c.r.PostFormValue("data")), &data)
if err != nil {
return "", utils.ErrInfo(err)
}
log.Debug("data:", data)
for k, _ := range data {
err := c.ExecSql(`
UPDATE `+c.MyPrefix+`my_notifications
SET email = ?,
sms = ?,
mobile = ?
WHERE name = ?
`, data[k]["email"].(float64), data[k]["sms"].(float64), data[k]["mobile"].(float64), data[k]["name"].(string))
if err != nil {
return "", utils.ErrInfo(err)
}
}
return `{"error":0}`, nil
}
开发者ID:dzyk,项目名称:dcoin-go,代码行数:31,代码来源:save_notifications.go
示例4: checkAvailableKey
func (a *AvailablekeyStruct) checkAvailableKey(key string) (int64, string, error) {
publicKeyAsn, err := utils.GetPublicFromPrivate(key)
if err != nil {
log.Debug("%v", err)
return 0, "", utils.ErrInfo(err)
}
log.Debug("publicKeyAsn: %s", publicKeyAsn)
userId, err := a.Single("SELECT user_id FROM users WHERE hex(public_key_0) = ?", publicKeyAsn).Int64()
if err != nil {
return 0, "", utils.ErrInfo(err)
}
log.Debug("userId: %s", userId)
if userId == 0 {
return 0, "", errors.New("null userId")
}
allTables, err := a.GetAllTables()
if err != nil {
return 0, "", utils.ErrInfo(err)
}
// может другой юзер уже начал смену ключа. актуально для пула
if utils.InSliceString(utils.Int64ToStr(userId)+"_my_table", allTables) {
return 0, "", errors.New("exists _my_table")
}
return userId, string(publicKeyAsn), nil
}
开发者ID:dzyk,项目名称:dcoin-go,代码行数:25,代码来源:availablekey.go
示例5: Signals
func Signals() {
SigChan = make(chan os.Signal, 1)
waitSig()
var Term os.Signal = syscall.SIGTERM
go func() {
signal.Notify(SigChan, os.Interrupt, os.Kill, Term)
<-SigChan
fmt.Println("KILL SIGNAL")
for _, ch := range utils.DaemonsChans {
fmt.Println("ch.ChBreaker<-true")
ch.ChBreaker <- true
}
for _, ch := range utils.DaemonsChans {
fmt.Println(<-ch.ChAnswer)
}
log.Debug("Daemons killed")
fmt.Println("Daemons killed")
if utils.DB != nil && utils.DB.DB != nil {
err := utils.DB.Close()
fmt.Println("DB Closed")
if err != nil {
log.Error("%v", utils.ErrInfo(err))
//panic(err)
}
}
err := os.Remove(*utils.Dir + "/dcoin.pid")
if err != nil {
log.Error("%v", utils.ErrInfo(err))
panic(err)
}
fmt.Println("removed " + *utils.Dir + "/dcoin.pid")
os.Exit(1)
}()
}
开发者ID:dzyk,项目名称:dcoin-go,代码行数:34,代码来源:notmobile.go
示例6: SaveUserCoords
func (c *Controller) SaveUserCoords() (string, error) {
if c.SessRestricted != 0 {
return "", utils.ErrInfo(errors.New("Permission denied"))
}
c.r.ParseForm()
coordsJson := c.r.FormValue("coords_json")
var coords [][2]int
err := json.Unmarshal([]byte(coordsJson), &coords)
if err != nil {
return "", err
}
coordsType := c.r.FormValue("type")
if coordsType != "face" && coordsType != "profile" {
return "", errors.New("Incorrect type")
}
coordsJson_, err := json.Marshal(coords)
if err != nil {
return "", err
}
err = c.ExecSql("UPDATE "+c.MyPrefix+"my_table SET "+coordsType+"_coords = ?", string(coordsJson_))
if err != nil {
return "", utils.ErrInfo(err)
}
return `{"success":"ok"}`, nil
}
开发者ID:dzyk,项目名称:dcoin-go,代码行数:27,代码来源:save_user_coords.go
示例7: SaveHost
func (c *Controller) SaveHost() (string, error) {
if c.SessRestricted != 0 {
return "", utils.ErrInfo(errors.New("Permission denied"))
}
c.r.ParseForm()
http_host := c.r.FormValue("http_host")
if len(http_host) > 0 && http_host[len(http_host)-1:] != "/" {
http_host += "/"
}
tcp_host := c.r.FormValue("tcp_host")
if !utils.CheckInputData(http_host, "http_host") {
return `{"error":"1"}`, nil
}
if !utils.CheckInputData(tcp_host, "tcp_host") {
return `{"error":"1"}`, nil
}
err := c.ExecSql("UPDATE "+c.MyPrefix+"my_table SET http_host = ?, tcp_host = ?", http_host, tcp_host)
if err != nil {
return "", utils.ErrInfo(err)
}
return `{"error":"0"}`, nil
}
开发者ID:dzyk,项目名称:dcoin-go,代码行数:27,代码来源:save_host.go
示例8: EData
func (c *Controller) EData() (string, error) {
c.w.Header().Set("Access-Control-Allow-Origin", "*")
// сколько всего продается DC
eOrders, err := c.GetAll(`SELECT sell_currency_id, sum(amount) as amount FROM e_orders WHERE sell_currency_id < 1000 AND empty_time = 0 GROUP BY sell_currency_id`, 100)
if err != nil {
return "", utils.ErrInfo(err)
}
values := ""
for _, data := range eOrders {
values += utils.ClearNull(data["amount"], 0) + ` d` + c.CurrencyList[utils.StrToInt64(data["sell_currency_id"])] + `, `
}
if len(values) > 0 {
values = values[:len(values)-2]
}
ps, err := c.Single(`SELECT value FROM e_config WHERE name = 'ps'`).String()
if err != nil {
return "", utils.ErrInfo(err)
}
jsonData, err := json.Marshal(map[string]string{"values": values, "ps": ps})
if err != nil {
return "", utils.ErrInfo(err)
}
return string(jsonData), nil
}
开发者ID:dzyk,项目名称:dcoin-go,代码行数:28,代码来源:e_data.go
示例9: CheckCfCurrency
func (c *Controller) CheckCfCurrency() (string, error) {
if c.SessRestricted != 0 {
return "", utils.ErrInfo(errors.New("Permission denied"))
}
c.r.ParseForm()
projectCurrencyName := c.r.FormValue("project_currency_name")
if !utils.CheckInputData(projectCurrencyName, "cf_currency_name") {
return "", errors.New("incorrect project_currency_name")
}
// проверим, не занято ли имя валюты
currency, err := c.Single("SELECT id FROM cf_projects WHERE project_currency_name = ? AND close_block_id = 0 AND del_block_id = 0", projectCurrencyName).Int64()
if err != nil {
return "", utils.ErrInfo(err)
}
if currency > 0 {
return `{"error":"` + c.Lang["currency_name_busy"] + `"}`, nil
}
// проверим, не занято ли имя валюты
currency, err = c.Single("SELECT id FROM cf_currency WHERE name = ?", projectCurrencyName).Int64()
if err != nil {
return "", utils.ErrInfo(err)
}
if currency > 0 {
return `{"error":"` + c.Lang["currency_name_busy"] + `"}`, nil
}
return `{"success":"` + c.Lang["name_is_not_occupied"] + `"}`, nil
}
开发者ID:dzyk,项目名称:dcoin-go,代码行数:32,代码来源:check_cf_currency.go
示例10: NewPhoto
func (c *Controller) NewPhoto() (string, error) {
c.r.ParseForm()
userId := int64(utils.StrToFloat64(c.r.FormValue("user_id")))
data, err := c.OneRow("SELECT photo_block_id, photo_max_miner_id, miners_keepers FROM miners_data WHERE user_id = ?", userId).String()
if err != nil {
return "", utils.ErrInfo(err)
}
// получим ID майнеров, у которых лежат фото нужного нам юзера
minersIds := utils.GetMinersKeepers(data["photo_block_id"], data["photo_max_miner_id"], data["miners_keepers"], true)
// берем 1 случайный из 10-и ID майнеров
k := utils.RandInt(0, len(minersIds))
minerId := minersIds[k]
host, err := c.Single("SELECT http_host FROM miners_data WHERE miner_id = ?", minerId).String()
if err != nil {
return "", utils.ErrInfo(err)
}
result, err := json.Marshal(map[string]string{"face": host + "public/face_" + utils.Int64ToStr(userId) + ".jpg", "profile": host + "public/profile_" + utils.Int64ToStr(userId) + ".jpg"})
if err != nil {
return "", utils.ErrInfo(err)
}
return string(result), nil
}
开发者ID:dzyk,项目名称:dcoin-go,代码行数:28,代码来源:new_photo.go
示例11: MoneyBackRequest
func (c *Controller) MoneyBackRequest() (string, error) {
txType := "MoneyBackRequest"
txTypeId := utils.TypeInt(txType)
timeNow := utils.Time()
orderId := int64(utils.StrToFloat64(c.Parameters["order_id"]))
order, err := c.OneRow("SELECT * FROM orders WHERE id = ?", orderId).String()
if err != nil {
return "", utils.ErrInfo(err)
}
TemplateStr, err := makeTemplate("money_back_request", "moneyBackRequest", &moneyBackRequestPage{
Alert: c.Alert,
Lang: c.Lang,
ShowSignData: c.ShowSignData,
SignData: "",
UserId: c.SessUserId,
OrderId: orderId,
Order: order,
CountSignArr: c.CountSignArr,
TimeNow: timeNow,
TxType: txType,
TxTypeId: txTypeId})
if err != nil {
return "", utils.ErrInfo(err)
}
return TemplateStr, nil
}
开发者ID:dzyk,项目名称:dcoin-go,代码行数:29,代码来源:money_back_request.go
示例12: Type7
func (t *TcpServer) Type7() {
/* Выдаем тело указанного блока
* запрос шлет демон blocksCollection и queue_parser_blocks через p.GetBlocks()
*/
buf := make([]byte, 4)
_, err := t.Conn.Read(buf)
if err != nil {
log.Error("%v", utils.ErrInfo(err))
return
}
blockId := utils.BinToDec(buf)
block, err := t.Single("SELECT data FROM block_chain WHERE id = ?", blockId).Bytes()
if err != nil {
log.Error("%v", utils.ErrInfo(err))
return
}
log.Debug("blockId %x", blockId)
log.Debug("block %x", block)
err = utils.WriteSizeAndData(block, t.Conn)
if err != nil {
log.Error("%v", utils.ErrInfo(err))
return
}
}
开发者ID:dzyk,项目名称:dcoin-go,代码行数:25,代码来源:type7.go
示例13: SaveEmailSms
func (c *Controller) SaveEmailSms() (string, error) {
if !c.NodeAdmin || c.SessRestricted != 0 {
return "", utils.ErrInfo(errors.New("Permission denied"))
}
c.r.ParseForm()
err := c.ExecSql(`
UPDATE `+c.MyPrefix+`my_table
SET email = ?,
smtp_server = ?,
use_smtp = ?,
smtp_port = ?,
smtp_ssl = ?,
smtp_auth = ?,
smtp_username = ?,
smtp_password = ?,
sms_http_get_request = ?
`, c.r.FormValue("email"), c.r.FormValue("smtp_server"), c.r.FormValue("use_smtp"), c.r.FormValue("smtp_port"), c.r.FormValue("smtp_ssl"), c.r.FormValue("smtp_auth"), c.r.FormValue("smtp_username"), c.r.FormValue("smtp_password"), c.r.FormValue("sms_http_get_request"))
if err != nil {
return "", utils.ErrInfo(err)
}
return "", nil
}
开发者ID:dzyk,项目名称:dcoin-go,代码行数:27,代码来源:save_email_sms.go
示例14: Chat
func (c *Controller) Chat() (string, error) {
myChatName := utils.Int64ToStr(c.SessUserId)
// возможно у отпарвителя есть ник
name, err := c.Single(`SELECT name FROM users WHERE user_id = ?`, c.SessUserId).String()
if err != nil {
return "", utils.ErrInfo(err)
}
if len(name) > 0 {
myChatName = name
}
TemplateStr, err := makeTemplate("chat", "chat", &chatPage{
Community: c.Community,
CountSignArr: c.CountSignArr,
CountSign: c.CountSign,
Lang: c.Lang,
ShowSignData: c.ShowSignData,
SignData: "",
MyChatName: myChatName,
UserId: c.SessUserId,
IOS: utils.IOS(),
Mobile: utils.Mobile()})
if err != nil {
return "", utils.ErrInfo(err)
}
return TemplateStr, nil
}
开发者ID:dzyk,项目名称:dcoin-go,代码行数:28,代码来源:chat.go
示例15: EPages
func (c *Controller) EPages() (string, error) {
var err error
var title, text string
if len(c.Parameters["page"]) > 0 {
if !utils.CheckInputData(c.Parameters["page"], "string") {
return "", utils.ErrInfo(err)
}
data, err := c.OneRow(`SELECT title, text from e_pages WHERE name = ? AND lang = ?`, c.Parameters["page"], c.LangInt).String()
if err != nil {
return "", utils.ErrInfo(err)
}
title = data["title"]
text = data["text"]
}
TemplateStr, err := makeTemplate("e_pages", "ePages", &ePages{
Lang: c.Lang,
Title: title,
Text: text})
if err != nil {
return "", utils.ErrInfo(err)
}
return TemplateStr, nil
}
开发者ID:dzyk,项目名称:dcoin-go,代码行数:26,代码来源:e_pages.go
示例16: EncryptChatMessage
func (c *Controller) EncryptChatMessage() (string, error) {
var err error
c.r.ParseForm()
receiver := c.r.FormValue("receiver")
message := c.r.FormValue("message")
if len(message) > 5120 {
return "", errors.New("incorrect message")
}
publicKey, err := c.Single("SELECT public_key_0 FROM users WHERE user_id = ?", receiver).Bytes()
if err != nil {
return "", utils.ErrInfo(err)
}
if len(publicKey) > 0 {
pub, err := utils.BinToRsaPubKey(publicKey)
if err != nil {
return "", utils.ErrInfo(err)
}
enc_, err := rsa.EncryptPKCS1v15(rand.Reader, pub, []byte(message))
if err != nil {
return "", utils.ErrInfo(err)
}
return utils.JsonAnswer(string(utils.BinToHex(enc_)), "success").String(), nil
} else {
return utils.JsonAnswer("Incorrect user_id", "error").String(), nil
}
}
开发者ID:dzyk,项目名称:dcoin-go,代码行数:32,代码来源:encrypt_chat_message.go
示例17: ELogin
func (c *Controller) ELogin() (string, error) {
c.r.ParseForm()
email := c.r.FormValue("email")
password := c.r.FormValue("password")
if len(password) > 50 || len(password) < 1 {
return "", errors.New(c.Lang["invalid_pass"])
}
data, err := c.OneRow("SELECT id, salt FROM e_users WHERE email = ?", email).String()
if err != nil {
return "", utils.ErrInfo(err)
}
if len(data) == 0 {
return "", errors.New(c.Lang["email_is_not_registered"])
}
// проверяем, верный ли пароль
passAndSalt := utils.Sha256(password + data["salt"])
userId, err := utils.DB.Single("SELECT id FROM e_users WHERE id = ? AND password = ?", data["id"], passAndSalt).Int64()
if err != nil {
return "", utils.ErrInfo(err)
}
if userId == 0 {
return "", errors.New(c.Lang["wrong_pass"])
}
c.sess.Set("e_user_id", userId)
return utils.JsonAnswer("success", "success").String(), nil
}
开发者ID:dzyk,项目名称:dcoin-go,代码行数:31,代码来源:e_login.go
示例18: ERedirect
func (c *Controller) ERedirect() (string, error) {
c.r.ParseForm()
token := c.r.FormValue("FormToken")
amount := c.r.FormValue("FormExAmount")
buyCurrencyId := utils.StrToInt64(c.r.FormValue("FormDC"))
if !utils.CheckInputData(token, "string") {
return "", errors.New("incorrect data")
}
// order_id занесем когда поуступят деньги в платежной системе
err := c.ExecSql(`UPDATE e_tokens SET buy_currency_id = ?, amount_fiat = ? WHERE token = ?`, buyCurrencyId, utils.StrToFloat64(c.r.FormValue("FormExAmount")), token)
if err != nil {
return "", utils.ErrInfo(err)
}
tokenId, err := c.Single(`SELECT id FROM e_tokens WHERE token = ?`, token).String()
if err != nil {
return "", utils.ErrInfo(err)
}
TemplateStr, err := makeTemplate("e_redirect", "eRedirect", &ERedirectPage{
Lang: c.Lang,
EConfig: c.EConfig,
TokenId: tokenId,
EURL: c.EURL,
MDesc: base64.StdEncoding.EncodeToString([]byte("token-" + tokenId)),
Amount: amount})
if err != nil {
return "", utils.ErrInfo(err)
}
return TemplateStr, nil
}
开发者ID:dzyk,项目名称:dcoin-go,代码行数:34,代码来源:e_redirect.go
示例19: EMyHistory
func (c *Controller) EMyHistory() (string, error) {
var err error
if c.SessUserId == 0 {
return `<script language="javascript"> window.location.href = "` + c.EURL + `"</script>If you are not redirected automatically, follow the <a href="` + c.EURL + `">` + c.EURL + `</a>`, nil
}
currencyList, err := utils.EGetCurrencyList()
if err != nil {
return "", utils.ErrInfo(err)
}
//fmt.Println("currencyList", currencyList)
var myHistory []*EmyHistory
rows, err := c.Query(c.FormatQuery(`
SELECT id, time, amount, sell_rate, sell_currency_id, buy_currency_id
FROM e_trade
WHERE user_id = ?
ORDER BY time DESC
LIMIT 40
`), c.SessUserId)
if err != nil {
return "", utils.ErrInfo(err)
}
defer rows.Close()
for rows.Next() {
myHist := new(EmyHistory)
err = rows.Scan(&myHist.Id, &myHist.Time, &myHist.Amount, &myHist.SellRate, &myHist.SellCurrencyId, &myHist.BuyCurrencyId)
if err != nil {
return "", utils.ErrInfo(err)
}
// определим тип ордера и пару
if myHist.SellCurrencyId < 1000 {
myHist.OrderType = "sell"
myHist.SellRate = 1 / myHist.SellRate
myHist.Total = myHist.Amount * myHist.SellRate
myHist.Amount = myHist.Amount
myHist.Pair = currencyList[myHist.SellCurrencyId] + "/" + currencyList[myHist.BuyCurrencyId]
} else {
myHist.OrderType = "buy"
myHist.Total = myHist.Amount
myHist.Amount = myHist.Amount * (1 / myHist.SellRate)
myHist.Pair = currencyList[myHist.BuyCurrencyId] + "/" + currencyList[myHist.SellCurrencyId]
}
myHistory = append(myHistory, myHist)
}
TemplateStr, err := makeTemplate("e_my_history", "eMyHistory", &eMyHistoryPage{
Lang: c.Lang,
UserId: c.SessUserId,
MyHistory: myHistory,
CurrencyList: currencyList})
if err != nil {
return "", utils.ErrInfo(err)
}
return TemplateStr, nil
}
开发者ID:dzyk,项目名称:dcoin-go,代码行数:60,代码来源:e_my_history.go
示例20: DelCfProject
func (c *Controller) DelCfProject() (string, error) {
var err error
txType := "DelCfProject"
txTypeId := utils.TypeInt(txType)
timeNow := utils.Time()
delId := int64(utils.StrToFloat64(c.Parameters["del_id"]))
projectCurrencyName, err := c.Single("SELECT project_currency_name FROM cf_projects WHERE id = ?", delId).String()
if err != nil {
return "", utils.ErrInfo(err)
}
TemplateStr, err := makeTemplate("del_cf_project", "delCfProject", &DelCfProjectPage{
Alert: c.Alert,
Lang: c.Lang,
CountSignArr: c.CountSignArr,
ShowSignData: c.ShowSignData,
SignData: fmt.Sprintf(`%d,%d,%d,%d`, txTypeId, timeNow, c.SessUserId, delId),
UserId: c.SessUserId,
TimeNow: timeNow,
TxType: txType,
TxTypeId: txTypeId,
DelId: delId,
ProjectCurrencyName: projectCurrencyName})
if err != nil {
return "", utils.ErrInfo(err)
}
return TemplateStr, nil
}
开发者ID:dzyk,项目名称:dcoin-go,代码行数:31,代码来源:del_cf_project.go
注:本文中的github.com/c-darwin/dcoin-go/packages/utils.ErrInfo函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论