* fix rescan wallet
* optimise
for {
time.Sleep(50 * time.Microsecond)
walletStatus := a.wallet.GetWalletStatusInfo()
for {
time.Sleep(50 * time.Microsecond)
walletStatus := a.wallet.GetWalletStatusInfo()
- if walletStatus.WorkHeight >= walletStatus.BestHeight {
+ if walletStatus.WorkHeight != walletStatus.BestHeight {
var walletInfoCmd = &cobra.Command{
Use: "wallet-info",
var walletInfoCmd = &cobra.Command{
Use: "wallet-info",
- Short: "Print the block information for wallet",
+ Short: "Print the information of wallet",
Args: cobra.NoArgs,
Run: func(cmd *cobra.Command, args []string) {
data, exitCode := util.ClientCall("/wallet-info")
Args: cobra.NoArgs,
Run: func(cmd *cobra.Command, args []string) {
data, exitCode := util.ClientCall("/wallet-info")
var rescanWalletCmd = &cobra.Command{
Use: "rescan-wallet",
var rescanWalletCmd = &cobra.Command{
Use: "rescan-wallet",
- Short: "Print the block information for wallet",
+ Short: "Trigger to rescan block information into related wallet",
Args: cobra.NoArgs,
Run: func(cmd *cobra.Command, args []string) {
if _, exitCode := util.ClientCall("/rescan-wallet"); exitCode != util.Success {
os.Exit(exitCode)
}
Args: cobra.NoArgs,
Run: func(cmd *cobra.Command, args []string) {
if _, exitCode := util.ClientCall("/rescan-wallet"); exitCode != util.Success {
os.Exit(exitCode)
}
- jww.FEEDBACK.Println("Successfully trigger rescan wallet")
+ jww.FEEDBACK.Println("Successfully trigger rescanning wallet")
block, _ := w.chain.GetBlockByHeight(w.status.WorkHeight + 1)
if block == nil {
block, _ := w.chain.GetBlockByHeight(w.status.WorkHeight + 1)
if block == nil {
- <-w.chain.BlockWaiter(w.status.WorkHeight + 1)
func (w *Wallet) getRescanNotification() {
select {
case <-w.rescanCh:
func (w *Wallet) getRescanNotification() {
select {
case <-w.rescanCh:
- block, _ := w.chain.GetBlockByHeight(0)
- w.status.WorkHash = bc.Hash{}
- w.AttachBlock(block)
+func (w *Wallet) setRescanStatus() {
+ block, _ := w.chain.GetBlockByHeight(0)
+ w.status.WorkHash = bc.Hash{}
+ w.AttachBlock(block)
+}
+
+func (w *Wallet) walletBlockWaiter() {
+ select {
+ case <-w.chain.BlockWaiter(w.status.WorkHeight + 1):
+ case <-w.rescanCh:
+ w.setRescanStatus()
+ }
+}
+
// GetNewTxCh return a unconfirmed transaction feed channel
func (w *Wallet) GetNewTxCh() chan *types.Tx {
return w.newTxCh
// GetNewTxCh return a unconfirmed transaction feed channel
func (w *Wallet) GetNewTxCh() chan *types.Tx {
return w.newTxCh