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