Skip to content

Commit

Permalink
Merge pull request #389 from bittorrent/release_2.3.3
Browse files Browse the repository at this point in the history
Release 2.3.3
  • Loading branch information
imstevez authored Oct 10, 2023
2 parents e3cc0be + 987e72f commit 4fa1a40
Show file tree
Hide file tree
Showing 21 changed files with 1,021 additions and 18 deletions.
5 changes: 3 additions & 2 deletions chain/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ import (
"encoding/hex"
"errors"
"fmt"
"github.com/bittorrent/go-btfs/chain/tokencfg"
"io"
"math/big"
"strings"
"time"

"github.com/bittorrent/go-btfs/chain/tokencfg"

"github.com/bittorrent/go-btfs/accounting"
"github.com/bittorrent/go-btfs/chain/config"
"github.com/bittorrent/go-btfs/settlement"
Expand Down Expand Up @@ -348,7 +349,7 @@ func initSwap(
priceOracle := priceoracle.New(currentPriceOracleAddress, transactionService)
_, err := priceOracle.CheckNewPrice(tokencfg.GetWbttToken()) // CheckNewPrice when node starts
if err != nil {
return nil, nil, errors.New("CheckNewPrice " + err.Error())
return nil, nil, errors.New("CheckNewPrice error, it may happens when contract call failed if bttc chain rpc is down, please try again")
}

swapProtocol := swapprotocol.New(overlayEthAddress, priceOracle)
Expand Down
1 change: 1 addition & 0 deletions cmd/btfs/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -759,6 +759,7 @@ If the user need to start multiple nodes on the same machine, the configuration
spin.Analytics(api, cctx.ConfigRoot, node, version.CurrentVersionNumber, hValue)
spin.Hosts(node, env)
spin.Contracts(node, req, env, nodepb.ContractStat_HOST.String())
spin.RestartFixChequeCashOut()
}

// Give the user some immediate feedback when they hit C-c
Expand Down
26 changes: 26 additions & 0 deletions cmd/btfs/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"path/filepath"
"strconv"
"strings"
"time"

"github.com/bittorrent/go-btfs/assets"
"github.com/bittorrent/go-btfs/chain"
Expand All @@ -36,6 +37,7 @@ const (
rmOnUnpinOptionName = "rm-on-unpin"
seedOptionName = "seed"
simpleMode = "simple-mode"
recoveryOptionName = "recovery"
/*
passWordOptionName = "password"
passwordFileoptionName = "password-file"
Expand Down Expand Up @@ -72,6 +74,7 @@ environment variable:
cmds.BoolOption(rmOnUnpinOptionName, "r", "Remove unpinned files.").WithDefault(false),
cmds.StringOption(seedOptionName, "s", "Import seed phrase"),
cmds.BoolOption(simpleMode, "sm", "init with simple mode or not."),
cmds.StringOption(recoveryOptionName, "Recovery data from a backup"),
/*
cmds.StringOption(passWordOptionName, "", "password for decrypting keys."),
cmds.StringOption(passwordFileoptionName, "", "path to a file that contains password for decrypting keys"),
Expand Down Expand Up @@ -140,7 +143,30 @@ environment variable:
password, _ := req.Options[passWordOptionName].(string)
passwordFile, _ := req.Options[passwordFileoptionName].(string)
*/
backupPath, ok := req.Options[recoveryOptionName].(string)
if ok {
btfsPath := env.(*oldcmds.Context).ConfigRoot
dstPath := filepath.Dir(btfsPath)
if fsrepo.IsInitialized(btfsPath) {
newPath := filepath.Join(dstPath, fmt.Sprintf(".btfs_backup_%d", time.Now().Unix()))
// newPath := filepath.Join(filepath.Dir(btfsPath), backup)
err := os.Rename(btfsPath, newPath)
if err != nil {
return err
}
fmt.Println("btfs configuration file already exists!")
fmt.Println("We have renamed it to ", newPath)
}

if err := commands.UnTar(backupPath, dstPath); err != nil {
err = commands.UnZip(backupPath, dstPath)
if err != nil {
return errors.New("your file format is not tar.gz or zip, please check again")
}
}
fmt.Println("Recovery successful!")
return nil
}
return doInit(os.Stdout, cctx.ConfigRoot, empty, nBitsForKeypair, profile, conf, keyType, importKey, seedPhrase, rmOnUnpin, simpleModeIn)
},
}
Expand Down
Loading

0 comments on commit 4fa1a40

Please sign in to comment.