本文整理汇总了Golang中github.com/c-darwin/dcoin-go/packages/utils.Int64ToStr函数的典型用法代码示例。如果您正苦于以下问题:Golang Int64ToStr函数的具体用法?Golang Int64ToStr怎么用?Golang Int64ToStr使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Int64ToStr函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: RepaymentCreditRollback
func (p *Parser) RepaymentCreditRollback() error {
creditData, err := p.OneRow("SELECT to_user_id, currency_id FROM credits WHERE id = ?", p.TxMaps.Int64["credit_id"]).Int64()
if err != nil {
return p.ErrInfo(err)
}
err = p.generalRollback("wallets", p.TxUserID, "AND currency_id = "+utils.Int64ToStr(creditData["currency_id"]), false)
if err != nil {
return p.ErrInfo(err)
}
err = p.generalRollback("wallets", creditData["to_user_id"], "AND currency_id = "+utils.Int64ToStr(creditData["currency_id"]), false)
if err != nil {
return p.ErrInfo(err)
}
err = p.selectiveRollback([]string{"amount", "tx_hash", "tx_block_id"}, "credits", "id="+utils.Int64ToStr(p.TxMaps.Int64["credit_id"]), false)
if err != nil {
return p.ErrInfo(err)
}
// возможно нужно обновить таблицу points_status
err = p.pointsUpdateMain(creditData["to_user_id"])
if err != nil {
return p.ErrInfo(err)
}
// возможно нужно обновить таблицу points_status
err = p.pointsUpdateMain(p.TxUserID)
if err != nil {
return p.ErrInfo(err)
}
return nil
}
开发者ID:dzyk,项目名称:dcoin-go,代码行数:35,代码来源:repayment_credit.go
示例2: NewPromisedAmount
func (p *Parser) NewPromisedAmount() error {
addSqlNames := ""
addSqlValues := ""
if p.BlockData.BlockId > 27134 {
paymentSystemsIds := strings.Split(string(p.TxMaps.String["payment_systems_ids"]), ",")
for i, v := range paymentSystemsIds {
addSqlNames += fmt.Sprintf("ps%d,", (i + 1))
addSqlValues += fmt.Sprintf("%s,", v)
}
}
//добавляем promised_amount в БД
err := p.ExecSql(`
INSERT INTO promised_amount (
user_id,
amount,
currency_id,
` + addSqlNames + `
video_type,
video_url_id,
votes_start_time
)
VALUES (
` + utils.Int64ToStr(p.TxMaps.Int64["user_id"]) + `,
` + utils.Float64ToStr(p.TxMaps.Money["amount"]) + `,
` + utils.Int64ToStr(p.TxMaps.Int64["currency_id"]) + `,
` + addSqlValues + `
'` + p.TxMaps.String["video_type"] + `',
'` + p.TxMaps.String["video_url_id"] + `',
` + utils.Int64ToStr(p.BlockData.Time) + `
)`)
if err != nil {
return p.ErrInfo(err)
}
// проверим, не наш ли это user_id
myUserId, myBlockId, myPrefix, _, err := p.GetMyUserId(p.TxMaps.Int64["user_id"])
if err != nil {
return err
}
if p.TxUserID == myUserId && myBlockId <= p.BlockData.BlockId {
// Удалим, т.к. попало в блок
err = p.ExecSql("DELETE FROM "+myPrefix+"my_promised_amount WHERE amount = ? AND currency_id = ?", p.TxMaps.Money["amount"], p.TxMaps.Int64["currency_id"])
if err != nil {
return p.ErrInfo(err)
}
}
return nil
}
开发者ID:dzyk,项目名称:dcoin-go,代码行数:50,代码来源:new_promised_amount.go
示例3: 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
示例4: makeVcomplex
func makeVcomplex(json_data []byte) (*vComplex, error) {
vComplex := new(vComplex)
err := json.Unmarshal(json_data, &vComplex)
if err != nil {
vComplex_ := new(vComplex_)
err = json.Unmarshal(json_data, &vComplex_)
if err != nil {
vComplex__ := new(vComplex__)
err = json.Unmarshal(json_data, &vComplex__)
if err != nil {
return vComplex, err
}
vComplex.Referral = vComplex__.Referral
vComplex.Currency = vComplex__.Currency
vComplex.Admin = utils.StrToInt64(vComplex__.Admin)
} else {
vComplex.Referral = make(map[string]string)
for k, v := range vComplex_.Referral {
vComplex.Referral[k] = utils.Int64ToStr(v)
}
vComplex.Currency = vComplex_.Currency
vComplex.Admin = vComplex_.Admin
}
}
return vComplex, nil
}
开发者ID:dzyk,项目名称:dcoin-go,代码行数:26,代码来源:votes_complex.go
示例5: 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
示例6: 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
示例7: CfCatalog
func (c *Controller) CfCatalog() (string, error) {
var err error
log.Debug("CfCatalog")
categoryId := utils.Int64ToStr(int64(utils.StrToFloat64(c.Parameters["category_id"])))
log.Debug("categoryId", categoryId)
var curCategory string
addSql := ""
if categoryId != "0" {
addSql = `AND category_id = ` + categoryId
curCategory = c.Lang["cf_category_"+categoryId]
}
cfUrl := ""
projects := make(map[string]map[string]string)
cfProjects, err := c.GetAll(`
SELECT cf_projects.id, lang_id, blurb_img, country, city, currency_id, end_time, amount
FROM cf_projects
LEFT JOIN cf_projects_data ON cf_projects_data.project_id = cf_projects.id
WHERE del_block_id = 0 AND
end_time > ? AND
lang_id = ?
`+addSql+`
ORDER BY funders DESC
LIMIT 100
`, 100, utils.Time(), c.LangInt)
if err != nil {
return "", utils.ErrInfo(err)
}
for _, data := range cfProjects {
CfProjectData, err := c.GetCfProjectData(utils.StrToInt64(data["id"]), utils.StrToInt64(data["end_time"]), c.LangInt, utils.StrToFloat64(data["amount"]), cfUrl)
if err != nil {
return "", utils.ErrInfo(err)
}
for k, v := range CfProjectData {
data[k] = v
}
projects[data["id"]] = data
}
cfCategory := utils.MakeCfCategories(c.Lang)
TemplateStr, err := makeTemplate("cf_catalog", "cfCatalog", &cfCatalogPage{
Lang: c.Lang,
CfCategory: cfCategory,
CurrencyList: c.CurrencyList,
CurCategory: curCategory,
Projects: projects,
UserId: c.SessUserId,
CategoryId: categoryId,
CfUrl: cfUrl})
if err != nil {
return "", utils.ErrInfo(err)
}
return TemplateStr, nil
}
开发者ID:dzyk,项目名称:dcoin-go,代码行数:58,代码来源:cf_catalog.go
示例8: Upgrade1
func (c *Controller) Upgrade1() (string, error) {
log.Debug("Upgrade1")
userFace := ""
/*userProfile := ""
path := "public/"+utils.Int64ToStr(c.SessUserId)+"_user_profile.jpg"
if _, err := os.Stat(path); err == nil {
userProfile = path
}*/
path := *utils.Dir + "/public/" + utils.Int64ToStr(c.SessUserId) + "_user_face.jpg"
if _, err := os.Stat(path); err == nil {
userFace = "/public/" + utils.Int64ToStr(c.SessUserId) + "_user_face.jpg"
}
step := "1"
nextStep := "2"
photoType := "face"
photo := userFace
saveAndGotoStep := strings.Replace(c.Lang["save_and_goto_step"], "[num]", "3", -1)
upgradeMenu := utils.MakeUpgradeMenu(1)
TemplateStr, err := makeTemplate("upgrade_1_and_2", "upgrade1And2", &upgrade1Page{
Alert: c.Alert,
Lang: c.Lang,
CountSignArr: c.CountSignArr,
ShowSignData: c.ShowSignData,
SaveAndGotoStep: saveAndGotoStep,
UpgradeMenu: upgradeMenu,
UserId: c.SessUserId,
PhotoType: photoType,
Photo: photo,
Step: step,
NextStep: nextStep,
IOS: utils.IOS(),
Mobile: utils.Mobile()})
if err != nil {
return "", utils.ErrInfo(err)
}
return TemplateStr, nil
}
开发者ID:dzyk,项目名称:dcoin-go,代码行数:44,代码来源:upgrade_1.go
示例9: VotesPromisedAmountRollback
func (p *Parser) VotesPromisedAmountRollback() error {
// вычитаем баллы
p.pointsRollback(p.Variables.Int64["promised_amount_points"])
// удаляем логирование, чтобы юзер {$this->tx_data['user_id']} не смог повторно проголосовать
err := p.ExecSql("DELETE FROM log_votes WHERE user_id = ? AND voting_id = ? AND type = 'promised_amount'", p.TxMaps.Int64["user_id"], p.TxMaps.Int64["promised_amount_id"])
if err != nil {
return p.ErrInfo(err)
}
// обновляем голоса
err = p.ExecSql("UPDATE promised_amount SET votes_"+utils.Int64ToStr(p.TxMaps.Int64["result"])+" = votes_"+utils.Int64ToStr(p.TxMaps.Int64["result"])+" - 1 WHERE id = ?", p.TxMaps.Int64["promised_amount_id"])
if err != nil {
return p.ErrInfo(err)
}
data, err := p.OneRow("SELECT status, user_id, log_id FROM promised_amount WHERE id = ?", p.TxMaps.Int64["promised_amount_id"]).String()
if err != nil {
return p.ErrInfo(err)
}
// если статус mining или rejected, значит голос был решающим
if data["status"] == "mining" || data["status"] == "rejected" {
// восстановим из лога
logData, err := p.OneRow("SELECT status, start_time, tdc_amount_update, prev_log_id FROM log_promised_amount WHERE log_id = ?", data["log_id"]).String()
if err != nil {
return p.ErrInfo(err)
}
err = p.ExecSql("UPDATE promised_amount SET status = ?, start_time = ?, tdc_amount_update = ?, log_id = ? WHERE id = ?", logData["status"], logData["start_time"], logData["tdc_amount_update"], logData["prev_log_id"], p.TxMaps.Int64["promised_amount_id"])
if err != nil {
return p.ErrInfo(err)
}
// подчищаем _log
err = p.ExecSql("DELETE FROM log_promised_amount WHERE log_id = ?", data["log_id"])
if err != nil {
return p.ErrInfo(err)
}
p.rollbackAI("log_promised_amount", 1)
// был ли добавлен woc
woc, err := p.Single("SELECT id FROM promised_amount WHERE currency_id = 1 AND woc_block_id = ? AND user_id = ?", p.BlockData.BlockId, data["user_id"]).Int64()
if err != nil {
return p.ErrInfo(err)
}
if woc > 0 {
err = p.ExecSql("DELETE FROM promised_amount WHERE id = ?", woc)
if err != nil {
return p.ErrInfo(err)
}
p.rollbackAI("promised_amount", 1)
}
}
return nil
}
开发者ID:dzyk,项目名称:dcoin-go,代码行数:56,代码来源:votes_promised_amount.go
示例10: ChangeHost
func (c *Controller) ChangeHost() (string, error) {
txType := "ChangeHost"
txTypeId := utils.TypeInt(txType)
timeNow := utils.Time()
if !c.PoolAdmin || c.SessRestricted != 0 {
return "", utils.ErrInfo(errors.New("access denied"))
}
data, err := c.OneRow("SELECT http_host, tcp_host, host_status FROM " + c.MyPrefix + "my_table").String()
if err != nil {
return "", utils.ErrInfo(err)
}
data2, err := c.OneRow("SELECT http_host, tcp_host, e_host FROM miners_data WHERE user_id = ?", c.SessUserId).String()
if err != nil {
return "", utils.ErrInfo(err)
}
if len(data["http_host"]) == 0 {
data["http_host"] = data2["http_host"]
}
if len(data["tcp_host"]) == 0 {
data["tcp_host"] = data2["tcp_host"]
}
if len(data["e_host"]) == 0 {
data["e_host"] = data2["e_host"]
}
if data["e_host"] == "" {
data["e_host"] = "0"
}
statusArray := map[string]string{"my_pending": c.Lang["local_pending"], "approved": c.Lang["status_approved"]}
data["host_status"] = statusArray[data["host_status"]]
limitsText := strings.Replace(c.Lang["change_host_limits_text"], "[limit]", utils.Int64ToStr(c.Variables.Int64["limit_change_host"]), -1)
limitsText = strings.Replace(limitsText, "[period]", c.Periods[c.Variables.Int64["limit_change_host_period"]], -1)
TemplateStr, err := makeTemplate("change_host", "changeHost", &changeHostPage{
Alert: c.Alert,
UserId: c.SessUserId,
CountSignArr: c.CountSignArr,
Data: data,
TimeNow: timeNow,
TxType: txType,
TxTypeId: txTypeId,
LimitsText: limitsText,
ShowSignData: c.ShowSignData,
Community: c.Community,
SignData: "",
Lang: c.Lang})
if err != nil {
return "", utils.ErrInfo(err)
}
return TemplateStr, nil
}
开发者ID:dzyk,项目名称:dcoin-go,代码行数:55,代码来源:change_host.go
示例11: ChangeArbitratorConditionsRollback
func (p *Parser) ChangeArbitratorConditionsRollback() error {
err := p.selectiveRollback([]string{"url"}, "users", "user_id="+utils.Int64ToStr(p.TxUserID), false)
if err != nil {
return p.ErrInfo(err)
}
err = p.generalRollback("arbitrator_conditions", p.TxUserID, "", false)
if err != nil {
return p.ErrInfo(err)
}
return nil
}
开发者ID:dzyk,项目名称:dcoin-go,代码行数:11,代码来源:change_arbitrator_conditions.go
示例12: NewUserRollback
func (p *Parser) NewUserRollback() error {
// если работаем в режиме пула, то ищем тех, у кого записан такой ключ
community, err := p.DCDB.GetCommunityUsers()
if err != nil {
return p.ErrInfo(err)
}
if len(community) > 0 {
for _, userId := range community {
myPrefix := utils.Int64ToStr(userId) + "_"
// проверим, не наш ли это public_key, чтобы записать полученный user_id в my_table
myPublicKey, err := p.DCDB.Single("SELECT public_key FROM "+myPrefix+"my_keys WHERE hex(public_key) = ?", p.TxMap["public_key_hex"]).String()
if err != nil {
return p.ErrInfo(err)
}
if myPublicKey != "" {
// теперь у нас полноценный юзерский акк, и его можно апргрейдить до майнерского
err = p.DCDB.ExecSql("UPDATE " + myPrefix + "my_table SET user_id = 0, status = 'my_pending', notification_status = 0")
if err != nil {
return p.ErrInfo(err)
}
err = p.DCDB.ExecSql("UPDATE "+myPrefix+"my_keys SET block_id = 0 WHERE block_id = ?", p.BlockData.BlockId)
if err != nil {
return p.ErrInfo(err)
}
}
}
} else {
// проверим, не наш ли это public_key
myPublicKey, err := p.DCDB.Single("SELECT public_key FROM my_keys WHERE hex(public_key) = ?", p.TxMap["public_key_hex"]).String()
if err != nil {
return p.ErrInfo(err)
}
if myPublicKey != "" {
err = p.DCDB.ExecSql("UPDATE my_table SET user_id = 0, status = 'my_pending', notification_status = 0")
if err != nil {
return p.ErrInfo(err)
}
err = p.DCDB.ExecSql("UPDATE my_keys SET block_id = 0 WHERE block_id = ?", p.BlockData.BlockId)
if err != nil {
return p.ErrInfo(err)
}
}
}
err = p.DCDB.ExecSql("DELETE FROM users WHERE hex(public_key_0) = ?", p.TxMap["public_key_hex"])
if err != nil {
return p.ErrInfo(err)
}
err = p.rollbackAI("users", 1)
if err != nil {
return p.ErrInfo(err)
}
return nil
}
开发者ID:dzyk,项目名称:dcoin-go,代码行数:53,代码来源:new_user.go
示例13: UnbanNodes
func UnbanNodes(chBreaker chan bool, chAnswer chan string) {
defer func() {
if r := recover(); r != nil {
log.Error("daemon Recovered", r)
panic(r)
}
}()
GoroutineName := "UnbanNodes"
d := new(daemon)
d.DCDB = DbConnect(chBreaker, chAnswer, GoroutineName)
if d.DCDB == nil {
return
}
d.goRoutineName = GoroutineName
d.chAnswer = chAnswer
d.chBreaker = chBreaker
d.sleepTime = 3600
if !d.CheckInstall(chBreaker, chAnswer, GoroutineName) {
return
}
d.DCDB = DbConnect(chBreaker, chAnswer, GoroutineName)
if d.DCDB == nil {
return
}
BEGIN:
for {
log.Info(GoroutineName)
MonitorDaemonCh <- []string{GoroutineName, utils.Int64ToStr(utils.Time())}
// проверим, не нужно ли нам выйти из цикла
if CheckDaemonsRestart(chBreaker, chAnswer, GoroutineName) {
break BEGIN
}
err = d.ExecSql("DELETE FROM nodes_ban")
if err != nil {
if d.dPrintSleep(err, d.sleepTime) {
break BEGIN
}
continue BEGIN
}
if d.dSleep(d.sleepTime) {
break BEGIN
}
}
log.Debug("break BEGIN %v", GoroutineName)
}
开发者ID:dzyk,项目名称:dcoin-go,代码行数:50,代码来源:unban_nodes.go
示例14: DeleteVideo
func (c *Controller) DeleteVideo() (string, error) {
if !c.NodeAdmin || c.SessRestricted != 0 {
return "", utils.ErrInfo(errors.New("Permission denied"))
}
if c.r.FormValue("type") == "mp4" {
err := os.Remove(*utils.Dir + "/public/" + utils.Int64ToStr(c.SessUserId) + "_user_video.mp4")
if err != nil {
return "", utils.ErrInfo(err)
}
} else if c.r.FormValue("type") == "webm_ogg" {
err := os.Remove(*utils.Dir + "/public/" + utils.Int64ToStr(c.SessUserId) + "_user_video.ogv")
if err != nil {
return "", utils.ErrInfo(err)
}
err = os.Remove(*utils.Dir + "/public/" + utils.Int64ToStr(c.SessUserId) + "_user_video.webm")
if err != nil {
return "", utils.ErrInfo(err)
}
}
return ``, nil
}
开发者ID:dzyk,项目名称:dcoin-go,代码行数:24,代码来源:delete_video.go
示例15: CropPhoto
func (c *Controller) CropPhoto() (string, error) {
if c.SessRestricted != 0 {
return "", utils.ErrInfo(errors.New("Permission denied"))
}
c.r.ParseForm()
photo := strings.Split(c.r.FormValue("photo"), ",")
if len(photo) != 2 {
return "", errors.New("Incorrect photo")
}
binary, err := base64.StdEncoding.DecodeString(photo[1])
if err != nil {
return "", err
}
img, _, err := image.Decode(bytes.NewReader(binary))
if err != nil {
return "", err
}
path := ""
if c.r.FormValue("type") == "face" {
path = *utils.Dir + "/public/" + utils.Int64ToStr(c.SessUserId) + "_user_face.jpg"
} else {
path = *utils.Dir + "/public/" + utils.Int64ToStr(c.SessUserId) + "_user_profile.jpg"
}
out, err := os.Create(path)
if err != nil {
return "", err
}
err = jpeg.Encode(out, img, &jpeg.Options{85})
if err != nil {
return "", err
}
return `{"success":"ok"}`, nil
}
开发者ID:dzyk,项目名称:dcoin-go,代码行数:36,代码来源:crop_photo.go
示例16: Upgrade4
func (c *Controller) Upgrade4() (string, error) {
log.Debug("Upgrade4")
videoUrl := ""
// есть ли загруженное видео.
data, err := c.OneRow("SELECT video_url_id, video_type FROM " + c.MyPrefix + "my_table").String()
if err != nil {
return "", utils.ErrInfo(err)
}
switch data["video_type"] {
case "youtube":
videoUrl = "http://www.youtube.com/embed/" + data["video_url_id"]
case "vimeo":
videoUrl = "http://www.vimeo.com/embed/" + data["video_url_id"]
case "youku":
videoUrl = "http://www.youku.com/embed/" + data["video_url_id"]
}
saveAndGotoStep := strings.Replace(c.Lang["save_and_goto_step"], "[num]", "6", -1)
upgradeMenu := utils.MakeUpgradeMenu(4)
var userVideoMp4 string
path := *utils.Dir + "/public/" + utils.Int64ToStr(c.SessUserId) + "_user_video.mp4"
if _, err := os.Stat(path); err == nil {
userVideoMp4 = "/public/" + utils.Int64ToStr(c.SessUserId) + "_user_video.mp4"
}
var userVideoWebm string
path = *utils.Dir + "/public/" + utils.Int64ToStr(c.SessUserId) + "_user_video.webm"
if _, err := os.Stat(path); err == nil {
userVideoWebm = "/public/" + utils.Int64ToStr(c.SessUserId) + "_user_video.webm"
}
var userVideoOgg string
path = *utils.Dir + "/public/" + utils.Int64ToStr(c.SessUserId) + "_user_video.ogg"
if _, err := os.Stat(path); err == nil {
userVideoOgg = "/public/" + utils.Int64ToStr(c.SessUserId) + "_user_video.ogg"
}
TemplateStr, err := makeTemplate("upgrade_4", "upgrade4", &upgrade4Page{
Alert: c.Alert,
Lang: c.Lang,
SaveAndGotoStep: saveAndGotoStep,
UpgradeMenu: upgradeMenu,
VideoUrl: videoUrl,
UserVideoMp4: userVideoMp4,
UserVideoWebm: userVideoWebm,
UserVideoOgg: userVideoOgg,
Mobile: utils.Mobile(),
UserId: c.SessUserId})
if err != nil {
return "", utils.ErrInfo(err)
}
return TemplateStr, nil
}
开发者ID:dzyk,项目名称:dcoin-go,代码行数:55,代码来源:upgrade_4.go
示例17: MakeFrontTest
func (db *DCDB) MakeFrontTest(transactionArray []string, time int64, dataForSign string, txType string, userId int64) error {
var err error
nodeArr := []string{"new_admin", "votes_node_new_miner"}
MY_PREFIX := utils.Int64ToStr(userId) + "_"
var binSign []byte
if utils.InSliceString(txType, nodeArr) {
k, err := db.GetNodePrivateKey(MY_PREFIX)
privateKey, err := MakePrivateKey(k)
if err != nil {
return ErrInfo(err)
}
binSign, err = rsa.SignPKCS1v15(rand.Reader, privateKey, crypto.SHA1, utils.HashSha1(dataForSign))
} else {
k, err := db.GetPrivateKey(MY_PREFIX)
privateKey, err := MakePrivateKey(k)
if err != nil {
return ErrInfo(err)
}
binSign, err = rsa.SignPKCS1v15(rand.Reader, privateKey, crypto.SHA1, utils.HashSha1(dataForSign))
binSign = EncodeLengthPlusData(binSign)
}
transactionArray = append(transactionArray, binSign)
parser := new(Parser)
parser.DCDB = db
parser.GoroutineName = "test"
parser.TxSlice = transactionArray
parser.BlockData = &utils.BlockData{BlockId: 190006, Time: time, UserId: userId}
parser.TxHash = "111111111111111"
err0 := utils.CallMethod(parser, txType+"Init")
if i, ok := err0.(error); ok {
fmt.Println(err0.(error), i)
return err0.(error)
}
err0 := utils.CallMethod(parser, txType+"Front")
if i, ok := err0.(error); ok {
fmt.Println(err0.(error), i)
return err0.(error)
}
err0 := utils.CallMethod(parser, txType+"RollbackFront")
if i, ok := err0.(error); ok {
fmt.Println(err0.(error), i)
return err0.(error)
}
return nil
}
开发者ID:dzyk,项目名称:dcoin-go,代码行数:47,代码来源:utils.go
示例18: ChangeGeolocation
func (c *Controller) ChangeGeolocation() (string, error) {
var err error
txType := "ChangeGeolocation"
txTypeId := utils.TypeInt(txType)
timeNow := utils.Time()
myGeolocationStr, err := c.Single(`SELECT geolocation FROM ` + c.MyPrefix + `my_table`).String()
if len(myGeolocationStr) == 0 {
myGeolocationStr = "39.94887, -75.15005"
}
x := strings.Split(myGeolocationStr, ", ")
myGeolocation := make(map[string]string)
myGeolocation["lat"] = x[0]
myGeolocation["lon"] = x[1]
myCountry, err := c.Single("SELECT country FROM miners_data WHERE user_id = ?", c.SessUserId).Int()
if err != nil {
return "", utils.ErrInfo(err)
}
limitsText := strings.Replace(c.Lang["geolocation_limits_text"], "[limit]", utils.Int64ToStr(c.Variables.Int64["limit_change_geolocation"]), -1)
limitsText = strings.Replace(limitsText, "[period]", c.Periods[c.Variables.Int64["limit_change_geolocation_period"]], -1)
TemplateStr, err := makeTemplate("change_geolocation", "changeGeolocation", &changeGeolocationPage{
Alert: c.Alert,
Lang: c.Lang,
TxTypeId: txTypeId,
TimeNow: timeNow,
UserId: c.SessUserId,
CountSignArr: c.CountSignArr,
ShowSignData: c.ShowSignData,
SignData: "",
LimitsText: limitsText,
MyCountry: myCountry,
Countries: consts.Countries,
MyGeolocation: myGeolocation})
if err != nil {
return "", utils.ErrInfo(err)
}
return TemplateStr, nil
}
开发者ID:dzyk,项目名称:dcoin-go,代码行数:43,代码来源:change_geolocation.go
示例19: MyNoticeData
func (c *Controller) MyNoticeData() (string, error) {
if !c.dbInit {
return "", utils.ErrInfo(errors.New("Permission denied"))
}
c.r.ParseForm()
myNotice, err := c.GetMyNoticeData(c.SessRestricted, c.SessUserId, c.MyPrefix, c.Lang)
if err != nil {
return "", utils.ErrInfo(err)
}
var cashRequests int64
if c.SessRestricted == 0 {
myUserId, err := c.GetMyUserId(c.MyPrefix)
if err != nil {
return "", utils.ErrInfo(err)
}
cashRequests, err = c.Single("SELECT count(id) FROM cash_requests WHERE to_user_id = ? AND status = 'pending' AND for_repaid_del_block_id = 0 AND del_block_id = 0", myUserId).Int64()
if cashRequests > 0 {
cashRequests = 1
}
if err != nil {
return "", utils.ErrInfo(err)
}
}
result, err := json.Marshal(map[string]string{
"main_status": myNotice["main_status"],
"main_status_complete": myNotice["main_status_complete"],
"account_status": myNotice["account_status"],
"cur_block_id": myNotice["cur_block_id"],
"connections": myNotice["connections"],
"time_last_block": myNotice["time_last_block"],
"time_last_block_int": myNotice["time_last_block_int"],
"inbox": utils.Int64ToStr(cashRequests)})
if err != nil {
return "", utils.ErrInfo(err)
}
return string(result), nil
}
开发者ID:dzyk,项目名称:dcoin-go,代码行数:42,代码来源:my_notice.go
示例20: GetBlock
func (c *Controller) GetBlock() (string, error) {
c.r.ParseForm()
BlockId := int64(utils.StrToFloat64(c.r.FormValue("id")))
if BlockId == 0 {
return `{"error": "nil id"}`, nil
}
if len(c.r.FormValue("download")) > 0 {
c.w.Header().Set("Content-type", "application/octet-stream")
c.w.Header().Set("Content-Disposition", "attachment; filename=\""+utils.Int64ToStr(BlockId)+".binary\"")
}
block, err := c.Single("SELECT data FROM block_chain WHERE id = ?", BlockId).String()
if err != nil {
return "", utils.ErrInfo(err)
}
return block, nil
}
开发者ID:dzyk,项目名称:dcoin-go,代码行数:20,代码来源:get_block.go
注:本文中的github.com/c-darwin/dcoin-go/packages/utils.Int64ToStr函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论