github.com/aergoio/aergo@v1.3.1/cmd/brick/exec/undoCommit.go (about)

     1  package exec
     2  
     3  import (
     4  	"fmt"
     5  
     6  	"github.com/aergoio/aergo/cmd/brick/context"
     7  )
     8  
     9  func init() {
    10  	registerExec(&undoCommit{})
    11  }
    12  
    13  type undoCommit struct{}
    14  
    15  func (c *undoCommit) Command() string {
    16  	return "undo"
    17  }
    18  
    19  func (c *undoCommit) Syntax() string {
    20  	return fmt.Sprintf("")
    21  }
    22  
    23  func (c *undoCommit) Usage() string {
    24  	return "undo"
    25  }
    26  
    27  func (c *undoCommit) Describe() string {
    28  	return "undo the previous transaction by disconnecting a block, which contains the tx"
    29  }
    30  
    31  func (c *undoCommit) Validate(args string) error {
    32  
    33  	if context.Get().BestBlockNo() == 0 {
    34  		return fmt.Errorf("There are no txs to undo")
    35  	}
    36  	return nil
    37  }
    38  
    39  func (c *undoCommit) Run(args string) (string, error) {
    40  	err := context.Get().DisConnectBlock()
    41  	if err != nil {
    42  		return "", err
    43  	}
    44  	return "Undo, Succesfully", nil
    45  }