Skip to content

Commit

Permalink
add better error wrapping / handling for CSN startup
Browse files Browse the repository at this point in the history
  • Loading branch information
adiabat committed Jan 13, 2021
1 parent ba535a0 commit fe368b8
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions csn/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func RunIBD(cfg *Config, sig chan bool) error {
// check on disk for pre-existing state and load it
pol, height, utxos, err := initCSNState()
if err != nil {
return err
return fmt.Errorf("initCSNState error: %s", err.Error())
}

pol.Lookahead = int32(cfg.lookAhead)
Expand All @@ -57,15 +57,15 @@ func RunIBD(cfg *Config, sig chan bool) error {

txChan, heightChan, err := c.Start(cfg, height, "compactstate", "", sig)
if err != nil {
return err
return fmt.Errorf("CSN start error: %s", err.Error())
}

var pkh [20]byte
if cfg.watchAddr != "" {
fmt.Printf("decode len %d %s\n", len(cfg.watchAddr), *watchAddr)
adrBytes, err := bech32.SegWitAddressDecode(cfg.watchAddr)
if err != nil {
return err
return fmt.Errorf("SegWitAddressDecode error: %s", err.Error())
}
if len(adrBytes) != 22 {
return fmt.Errorf("need a bech32 p2wpkh address, %s has %d bytes",
Expand Down Expand Up @@ -127,6 +127,7 @@ func initCSNState() (
fmt.Println("Has access to forestdata, resuming")
height, p, utxos, err = restorePollard()
if err != nil {
err = fmt.Errorf("restorePollard error: %s", err.Error())
return
}
} else {
Expand All @@ -137,6 +138,8 @@ func initCSNState() (
// Create file needed for pollard
_, err = os.OpenFile(PollardFilePath, os.O_CREATE, 0600)
if err != nil {
err = fmt.Errorf("Open pollard file %s error: %s",
PollardFilePath, err.Error())
return
}
}
Expand Down

0 comments on commit fe368b8

Please sign in to comment.