Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
# Conflicts:
#	static/lang/42.ini
  • Loading branch information
c-darwin committed Jun 1, 2016
2 parents 07eea1d + c195805 commit 4748ced
Show file tree
Hide file tree
Showing 42 changed files with 882 additions and 197 deletions.
2 changes: 1 addition & 1 deletion dcoinnotmobile.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func main() {
thrust.Start()
thrustWindow = thrust.NewWindow(thrust.WindowOptions{
RootUrl: "http://localhost:8989/loader.html",
// HasFrame: true,
HasFrame: winVer() != 6,
Title : "Dcoin",
Size: commands.SizeHW{Width:width, Height:height},
})
Expand Down
11 changes: 8 additions & 3 deletions dcoinwindows.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,18 @@ int w_ver() {
DWORD dwMajorVersion = 0;
DWORD dwVersion = 0;
dwVersion = GetVersion();
dwMajorVersion = (DWORD)(LOBYTE(LOWORD(dwVersion)));
return dwMajorVersion;
//dwMajorVersion = (DWORD)(LOBYTE(LOWORD(dwVersion)));
//return dwMajorVersion;
return dwVersion;
}*/
import "C"

func winVer() int {
return int(C.w_ver())
ver := int(C.w_ver())
if ver & 0xff == 6 && ( ver & 0xff00 ) >> 8 <= 1 {
return 6
}
return 7
}

func tray() {
Expand Down
2 changes: 1 addition & 1 deletion packages/consts/consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package consts


// текущая версия
const VERSION = "2.3.3b1"
const VERSION = "2.3.4b1"

// чтобы не выдавать одно и тоже голосование
const ASSIGN_TIME = 86400
Expand Down
2 changes: 2 additions & 0 deletions packages/controllers/statistic.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,8 @@ func (c *Controller) Statistic() (string, error) {
currencyPct[currencyId]["name"] = name
currencyPct[currencyId]["miner"] = utils.Float64ToStr(utils.Round((math.Pow(1+pct["miner"], 120)-1)*100, 6))
currencyPct[currencyId]["user"] = utils.Float64ToStr(utils.Round((math.Pow(1+pct["user"], 120)-1)*100, 6))
currencyPct[currencyId]["miner_year"] = utils.Float64ToStrPct(utils.Round((math.Pow(1+pct["miner"], 3600*24*365)-1)*100, 2))
currencyPct[currencyId]["user_year"] = utils.Float64ToStrPct(utils.Round((math.Pow(1+pct["user"], 3600*24*365)-1)*100, 2))
}

/*
Expand Down
18 changes: 9 additions & 9 deletions packages/controllers/updating_blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,22 @@ func (c *Controller) UpdatingBlockchain() (string, error) {
}

sleepTime := int64(1500)
var newVersion string

if c.dbInit {
community, err := c.GetCommunityUsers()
if err != nil {
return "", utils.ErrInfo(err)
}
if len(community) > 0 {
sleepTime = 5000
}
if len(community) == 0 || c.NodeAdmin {
if ver, _, err := utils.GetUpdVerAndUrl(consts.UPD_AND_VER_URL); err == nil {
if len(ver) > 0 {
newVersion = strings.Replace(c.Lang["new_version"], "[ver]", ver, -1)
}
}
}
}

Expand All @@ -151,15 +160,6 @@ func (c *Controller) UpdatingBlockchain() (string, error) {
b := new(bytes.Buffer)
standardInstall = configIni[`install_type`] == `standard`

var newVersion string
if community, err := c.DCDB.GetCommunityUsers(); err==nil && (len(community) == 0 || c.NodeAdmin){
if ver, _, err := utils.GetUpdVerAndUrl(consts.UPD_AND_VER_URL); err == nil {
if len(ver) > 0 {
newVersion = strings.Replace(c.Lang["new_version"], "[ver]", ver, -1)
}
}
}

t.Execute(b, &updatingBlockchainStruct{SleepTime: sleepTime, StandardInstall: standardInstall, RestartDb: restartDb, Lang: c.Lang,
WaitText: waitText, BlockId: blockId, BlockTime: blockTime, StartDaemons: startDaemons,
BlockMeter: blockMeter, CheckTime: checkTime, LastBlock: consts.LAST_BLOCK,
Expand Down
6 changes: 5 additions & 1 deletion packages/dcoin/dcoin.go
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,11 @@ func Start(dir string, thrustWindowLoder *window.Window) {
})
thrustWindow.HandleRemote(func(er commands.EventResult, this *window.Window) {
fmt.Println("RemoteMessage Recieved:", er.Message.Payload)
openBrowser(er.Message.Payload)
if er.Message.Payload[:7] == `mailto:` && runtime.GOOS == `windows` {
utils.ShellExecute(er.Message.Payload)
} else {
openBrowser(er.Message.Payload)
}
// Keep in mind once we have the message, lets say its json of some new type we made,
// We can unmarshal it to that type.
// Same goes for the other way around.
Expand Down
21 changes: 21 additions & 0 deletions packages/dcoin/migration.go
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,27 @@ func migration() {
schema_.S = s
schema_.PrintSchema()
}
if utils.VersionOrdinal(*utils.OldVersion) < utils.VersionOrdinal("2.3.3b2") {
schema_ := &schema.SchemaStruct{}
schema_.DbType = utils.DB.ConfigIni["db_type"]
schema_.DCDB = utils.DB
s := make(schema.Recmap)
s1 := make(schema.Recmap)
s2 := make(schema.Recmapi)
s2[0] = map[string]string{"name": "id", "mysql": "int(11) NOT NULL AUTO_INCREMENT DEFAULT '0'", "sqlite": "INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL", "postgresql": "int NOT NULL default nextval('notifications_id_seq')", "comment": ""}
s2[1] = map[string]string{"name": "user_id", "mysql": "bigint(20) unsigned NOT NULL DEFAULT '0'", "sqlite": "bigint(20) NOT NULL DEFAULT '0'", "postgresql": "bigint NOT NULL DEFAULT '0'", "comment": ""}
s2[2] = map[string]string{"name": "block_id", "mysql": "int(11) NOT NULL DEFAULT '0'", "sqlite": "int(11) NOT NULL DEFAULT '0'", "postgresql": "int NOT NULL DEFAULT '0'", "comment": ""}
s2[3] = map[string]string{"name": "cmd_id", "mysql": "tinyint(3) unsigned NOT NULL DEFAULT '0'", "sqlite": "tinyint(3) NOT NULL DEFAULT '0'", "postgresql": "smallint NOT NULL DEFAULT '0'", "comment": ""}
s2[4] = map[string]string{"name": "params", "mysql": "text CHARACTER SET utf8 NOT NULL DEFAULT ''", "sqlite": "text NOT NULL DEFAULT ''", "postgresql": "text NOT NULL DEFAULT ''", "comment": ""}

s1["fields"] = s2
s1["PRIMARY"] = []string{"id"}
s1["AI"] = "id"
s1["comment"] = ""
s["notifications"] = s1
schema_.S = s
schema_.PrintSchema()
}
}
}

1 change: 1 addition & 0 deletions packages/dcparser/admin_ban_miners.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ func (p *Parser) AdminBanMiners() error {
return p.ErrInfo(err)
}
}
p.nfyStatus(userId, `user`)
}

return nil
Expand Down
2 changes: 2 additions & 0 deletions packages/dcparser/admin_unban_miners.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ func (p *Parser) AdminUnbanMiners() error {
}
}
}
p.nfyStatus(userId, `miner`)

}

return nil
Expand Down
3 changes: 3 additions & 0 deletions packages/dcparser/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -2450,6 +2450,7 @@ func (p *Parser) updateRecipientWallet(toUserId, currencyId int64, amount float6
return p.ErrInfo(err)
}
}
p.nfyCame(toUserId, &utils.TypeNfyCame{from, fromId, amount, currencyId, comment, commentStatus} )
return nil
}

Expand Down Expand Up @@ -2519,6 +2520,7 @@ func (p *Parser) updateSenderWallet(fromUserId, currencyId int64, amount, commis
}
}
}
p.nfySent(fromUserId, &utils.TypeNfySent{from, toUserId, amount, commission, currencyId, comment, commentStatus} )
return nil
}

Expand Down Expand Up @@ -2553,6 +2555,7 @@ func (p *Parser) mydctxRollback() error {
return p.ErrInfo(err)
}
}
p.nfyRollback(p.BlockData.BlockId)
return nil
}

Expand Down
1 change: 1 addition & 0 deletions packages/dcparser/new_user.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ func (p *Parser) NewUser() error {
if p.TxUserID == myUserId && myBlockId <= p.BlockData.BlockId {
p.DCDB.ExecSql("UPDATE "+myPrefix+"my_new_users SET status ='approved', user_id = ? WHERE hex(public_key) = ?", newUserId, p.TxMap["public_key_hex"])
}
p.nfyStatus(newUserId, `user`)
return nil
}

Expand Down
57 changes: 57 additions & 0 deletions packages/dcparser/notifications.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// notifications
package dcparser

import (
"fmt"
"encoding/json"
"github.com/democratic-coin/dcoin-go/packages/utils"
)

func (p *Parser) isNotify() bool {
if val,ok := p.ConfigIni["notify"]; ok && val == `1`{
return true
}
return false
}

func (p *Parser) nfyRollback( blockId int64 ) {
if !p.isNotify() {
return
}
p.ExecSql( `delete from notifications where block_id=?`, blockId )
}


func (p *Parser) insertNotify( userId int64, cmdId int, params string) {
p.ExecSql("insert into notifications (user_id, block_id, cmd_id, params) VALUES (?, ?, ?, ?)",
userId, p.BlockData.BlockId, cmdId, params )
}

func (p *Parser) nfyStatus( userId int64, status string ) {
if !p.isNotify() {
return
}
p.insertNotify( userId, utils.ECMD_CHANGESTAT, fmt.Sprintf( `{"status": "%s"}`, status ))
}

func (p *Parser) nfySent( userId int64, tns *utils.TypeNfySent ) {
if !p.isNotify() {
return
}
params,err := json.Marshal( tns )
if err != nil {
params = []byte(fmt.Sprintf( `{"error": "%s"}`, err ))
}
p.insertNotify( userId, utils.ECMD_DCSENT, string(params))
}

func (p *Parser) nfyCame( userId int64, tnc *utils.TypeNfyCame ) {
if !p.isNotify() {
return
}
params,err := json.Marshal( tnc )
if err != nil {
params = []byte(fmt.Sprintf( `{"error": "%s"}`, err ))
}
p.insertNotify( userId, utils.ECMD_DCCAME, string(params))
}
7 changes: 5 additions & 2 deletions packages/dcparser/votes_miner.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func (p *Parser) VotesMinerFront() error {
}

func (p *Parser) VotesMiner() error {

var notify bool
// начисляем баллы
p.points(p.Variables.Int64["miner_points"])

Expand Down Expand Up @@ -128,6 +128,7 @@ func (p *Parser) VotesMiner() error {
if err != nil {
return p.ErrInfo(err)
}
notify = true
if minersData["user_id"] == myUserId {
minerData, err := p.OneRow("SELECT * FROM miners_data WHERE user_id = ?", minersData["user_id"]).String()
if err != nil {
Expand Down Expand Up @@ -182,7 +183,9 @@ func (p *Parser) VotesMiner() error {
return p.ErrInfo(err)
}
}

if notify {
p.nfyStatus(minersData["user_id"], `miner`)
}
return nil
}

Expand Down
7 changes: 5 additions & 2 deletions packages/dcparser/votes_sn_user.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func (p *Parser) VotesSnUserFront() error {
}

func (p *Parser) VotesSnUser() error {

var notify bool
// начисляем баллы
p.points(p.Variables.Int64["miner_points"])
// логируем, чтобы юзер {$this->tx_data['user_id']} не смог повторно проголосовать
Expand Down Expand Up @@ -123,6 +123,7 @@ func (p *Parser) VotesSnUser() error {
// перевесили голоса "за" или 1 голос от админа
if p.checkTrueVotes(data) {
err = p.selectiveLoggingAndUpd([]string{"status"}, []interface{}{"sn_user"}, "users", []string{"user_id"}, []string{utils.Int64ToStr(p.TxMaps.Int64["sn_user_id"])})
notify = true
if err != nil {
return p.ErrInfo(err)
}
Expand All @@ -145,7 +146,9 @@ func (p *Parser) VotesSnUser() error {
return p.ErrInfo(err)
}
}

if notify {
p.nfyStatus(data["user_id"], `sn_user`)
}
return nil
}

Expand Down
Loading

0 comments on commit 4748ced

Please sign in to comment.