Commit 7029765a authored by heyubin's avatar heyubin Committed by vipwzw

add by hyb for issues109

parent 96f56d71
...@@ -212,8 +212,8 @@ func (client *Client) setTicket(tlist *ty.ReplyTicketList, privmap map[string]cr ...@@ -212,8 +212,8 @@ func (client *Client) setTicket(tlist *ty.ReplyTicketList, privmap map[string]cr
func (client *Client) flushTicket() error { func (client *Client) flushTicket() error {
//list accounts //list accounts
tickets, privs, err := client.getTickets() tickets, privs, err := client.getTickets()
if err == types.ErrMinerNotStared { if err == types.ErrMinerNotStared || err == types.ErrWalletIsLocked {
tlog.Error("flushTicket error", "err", "wallet miner not start") tlog.Error("flushTicket error", "err", "wallet miner not start or wallet ss locked")
client.setTicket(nil, nil) client.setTicket(nil, nil)
return nil return nil
} }
......
...@@ -221,6 +221,7 @@ func (policy *ticketPolicy) SignTransaction(key crypto.PrivKey, req *types.ReqSi ...@@ -221,6 +221,7 @@ func (policy *ticketPolicy) SignTransaction(key crypto.PrivKey, req *types.ReqSi
func (policy *ticketPolicy) OnWalletLocked() { func (policy *ticketPolicy) OnWalletLocked() {
// 钱包锁住时,不允许挖矿 // 钱包锁住时,不允许挖矿
atomic.CompareAndSwapInt32(&policy.isTicketLocked, 0, 1) atomic.CompareAndSwapInt32(&policy.isTicketLocked, 0, 1)
FlushTicket(policy.getAPI())
} }
//解锁超时处理,需要区分整个钱包的解锁或者只挖矿的解锁 //解锁超时处理,需要区分整个钱包的解锁或者只挖矿的解锁
...@@ -392,10 +393,14 @@ func (policy *ticketPolicy) getTicketsByStatus(status int32) ([]*ty.Ticket, [][] ...@@ -392,10 +393,14 @@ func (policy *ticketPolicy) getTicketsByStatus(status int32) ([]*ty.Ticket, [][]
} }
operater.GetMutex().Lock() operater.GetMutex().Lock()
defer operater.GetMutex().Unlock() defer operater.GetMutex().Unlock()
ok, err := operater.CheckWalletStatus() ok, err := operater.CheckWalletStatus()
if !ok && err != types.ErrOnlyTicketUnLocked { if !ok && err != types.ErrOnlyTicketUnLocked {
return nil, nil, err return nil, nil, err
} }
if !policy.IsAutoMining() {
return nil, nil, types.ErrMinerNotStared
}
//循环遍历所有的账户-->保证钱包已经解锁 //循环遍历所有的账户-->保证钱包已经解锁
var tickets []*ty.Ticket var tickets []*ty.Ticket
var privs [][]byte var privs [][]byte
......
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