Skip to content

Commit

Permalink
Merge remote-tracking branch 'simelo_alt/stdevAntiD2ta_t295_Slow_load…
Browse files Browse the repository at this point in the history
…_times' into stdevAntiD2ta_t295_Slow_load_times
  • Loading branch information
olemis committed Feb 14, 2020
2 parents a44a398 + 1c9b5ff commit 796baac
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 10 deletions.
3 changes: 2 additions & 1 deletion src/coin/skycoin/models/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ func (p *SkyFiberPlugin) LoadTransactionAPI(netType string) (core.BlockchainTran
if netType != "MainNet" {
return nil, errors.ErrInvalidNetworkType
}
return NewSkycoinBlockchain(config.GetDataRefreshTimeout()), nil
refreshTimeOut := config.GetDataRefreshTimeout()
return NewSkycoinBlockchain(refreshTimeOut*(1000000000)), nil
}

// LoadSignService sign service entry point
Expand Down
3 changes: 2 additions & 1 deletion src/coin/skycoin/models/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,8 @@ func (spex *SkycoinPEX) GetTxnPool() (core.TransactionIterator, error) {
}
skycoinTxns := make([]core.Transaction, 0)
for _, txn := range txns {
skycoinTxns = append(skycoinTxns, &SkycoinPendingTransaction{Transaction: &txn})
t := txn
skycoinTxns = append(skycoinTxns, &SkycoinPendingTransaction{Transaction: &t})
}
return NewSkycoinTransactionIterator(skycoinTxns), nil
}
Expand Down
2 changes: 1 addition & 1 deletion src/models/history/historyManager.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func (hm *HistoryManager) init() {
hm.txnForAddresses = make(map[string][]core.Transaction, 0)
hm.newTxn = make(map[string][]core.Transaction, 0)
updateTime := config.GetDataUpdateTime()
uptimeTicker := time.NewTicker(time.Duration(updateTime) * time.Microsecond * 2)
uptimeTicker := time.NewTicker(time.Duration(updateTime) * time.Second)
historyManager = hm
hm.txnFinded = make(map[string]struct{}, 0)
go func() {
Expand Down
2 changes: 1 addition & 1 deletion src/models/modelWallets.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func (m *ModelWallets) init() {

m.WalletEnv = walletsEnvs[0]
go func() {
uptimeTicker := time.NewTicker(time.Duration(config.GetDataUpdateTime()) * time.Microsecond)
uptimeTicker := time.NewTicker(time.Duration(config.GetDataUpdateTime()) * time.Second)

for range uptimeTicker.C {
go m.loadModel()
Expand Down
6 changes: 4 additions & 2 deletions src/models/pending/PendingModel.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ func (model *PendingTransactionList) getAll() {
}
ptModels := make([]*PendingTransaction, 0)
for txns.Next() {
ptModel := TransactionToPendingTransaction(txns.Value())
t := txns.Value()
ptModel := TransactionToPendingTransaction(t)
ptModel.SetMine(0)
ptModels = append(ptModels, ptModel)
}
Expand All @@ -96,7 +97,8 @@ func (model *PendingTransactionList) getMine() {
}
ptModels := make([]*PendingTransaction, 0)
for wallets.Next() {
account := wallets.Value().GetCryptoAccount()
wlt := wallets.Value()
account := wlt.GetCryptoAccount()
txns, err := account.ListPendingTransactions()
if err != nil {
//display an error in qml app when Mine is selected
Expand Down
18 changes: 16 additions & 2 deletions src/models/walletsManager.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ type WalletManager struct {
transactionAPI core.BlockchainTransactionAPI
walletsIterator core.WalletIterator
updaterChannel chan *updateWalletInfo
timerUpdate chan time.Duration

_ func() `slot:"updateWalletEnvs"`
_ func(wltId, address string) `slot:"updateOutputs"`
Expand Down Expand Up @@ -152,10 +153,20 @@ func (walletM *WalletManager) init() {
logWalletManager.Debug("Finish wallets")
walletM.wallets = qWallets
go func() {
logWalletManager.Debug("Update time is :=> ", time.Duration(config.GetDataUpdateTime())*time.Microsecond)
uptimeTicker := time.NewTicker(time.Duration(config.GetDataUpdateTime()) * time.Microsecond)
updateTime := config.GetDataUpdateTime()
logWalletManager.Debug("Update time is :=> ", time.Duration(updateTime)*time.Second)
uptimeTicker := time.NewTicker(time.Duration(updateTime) * time.Second)

for {
select {
case <-uptimeTicker.C:
go walletM.updateWallets()
walletManager = walletM
break
case t := <-walletM.timerUpdate:
uptimeTicker = time.NewTicker(t)
break
}
<-uptimeTicker.C
go walletM.updateWallets()
walletManager = walletM
Expand Down Expand Up @@ -185,6 +196,9 @@ func (walletM *WalletManager) updateAll() {
walletM.updateSigner()
walletM.updateWalletEnvs()
skycoin.UpdateAltcoin()
updateTime := config.GetDataUpdateTime()
logWalletManager.Debug("Update time is :=> ", time.Duration(updateTime)*time.Second)
walletM.timerUpdate <- time.Duration(updateTime) * time.Second
}

func GetWalletEnv() core.WalletEnv {
Expand Down
4 changes: 2 additions & 2 deletions src/params/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package params

const (
// Default refresh timeout for API data
DataRefreshTimeout = 1000000 //FIXME: set correct value
DataUpdateTime = 5000000
DataRefreshTimeout = 10
DataUpdateTime = 5
OrganizationName = "Simelo.Tech"
OrganizationDomain = "simelo.tech"
ApplicationName = "FiberCryptoWallet"
Expand Down

0 comments on commit 796baac

Please sign in to comment.