Skip to content

Commit

Permalink
Merge branch 'master' into v1.4.x
Browse files Browse the repository at this point in the history
  • Loading branch information
monstrobishi authored Jan 13, 2021
2 parents 84c9594 + 3639d01 commit 4ecf5e6
Show file tree
Hide file tree
Showing 10 changed files with 104 additions and 89 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
# [1] https://docs.travis-ci.com/user/caching/#build-phases
# [2] https://docs.travis-ci.com/user/customizing-the-build#build-timeouts

dist: xenial
dist: bionic
os: linux
language: minimal
cache:
Expand Down
1 change: 1 addition & 0 deletions ci/test/00_setup_env_amd64_asan.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ export PACKAGES="clang llvm python3-zmq qtbase5-dev qttools5-dev-tools libssl1.0
export NO_DEPENDS=1
export GOAL="install"
export DEFI_CONFIG="--enable-zmq --with-incompatible-bdb CPPFLAGS=-DDEBUG_LOCKORDER --with-sanitizers=address,integer,undefined CC=clang CXX=clang++"
export RUN_CI_ON_HOST="1"
2 changes: 1 addition & 1 deletion ci/test/04_install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ if [ -z "$RUN_CI_ON_HOST" ]; then
else
echo "Running on host system without docker wrapper"
DOCKER_EXEC () {
bash -c "cd $PWD && $*"
sudo bash -c "cd $PWD && $*"
}
fi

Expand Down
11 changes: 2 additions & 9 deletions doc/setup-masternodes.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,9 @@ In this scenario, operator's address will be equal to the owner's (collateral) a

### Step 1 - Download and extract node software

The first step is to download the binaries. Here are links to binaries for Linux and Macosx:
The first step is to download the binaries. Here are links to binaries for Windows, Linux and Macosx (Please download the latest release):

[Linux v1.3.1](https://github.com/DeFiCh/ain/releases/download/v1.3.1/defichain-1.3.1-x86_64-pc-linux-gnu.tar.gz)
[Mac OSX v1.3.1](https://github.com/DeFiCh/ain/releases/download/v1.3.1/defichain-1.3.1-x86_64-apple-darwin11.tar.gz)

We can download this on Linux using the command:

```
wget https://github.com/DeFiCh/ain/releases/download/v1.3.1/defichain-1.3.1-x86_64-pc-linux-gnu.tar.gz
```
[Downloads](https://defichain.com/downloads/)

Following that we can extract the tar file by running:
```
Expand Down
6 changes: 4 additions & 2 deletions src/masternodes/masternodes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include <script/standard.h>
#include <validation.h>
#include <wallet/wallet.h>
#include <wallet/walletutil.h>

#include <algorithm>
#include <functional>
Expand Down Expand Up @@ -616,9 +617,10 @@ bool CRewardsHistoryStorage::Flush()
isminetype IsMineCached(CWallet const & wallet, CScript const & script)
{
static std::unordered_map<std::string, std::map<CScript, isminetype>> mineCached;
auto it = mineCached.find(wallet.GetName());
const auto& walletFilePath = wallet.GetLocation().GetFilePath();
auto it = mineCached.find(walletFilePath);
if (it == mineCached.end()) {
it = mineCached.emplace(wallet.GetName(), std::map<CScript, isminetype>{}).first;
it = mineCached.emplace(walletFilePath, std::map<CScript, isminetype>{}).first;
}
auto mIt = it->second.find(script);
if (mIt == it->second.end()) {
Expand Down
126 changes: 68 additions & 58 deletions src/masternodes/mn_rpc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4036,6 +4036,69 @@ UniValue sendtokenstoaddress(const JSONRPCRequest& request) {

}

static bool GetCustomTXInfo(const int nHeight, const CTransactionRef tx, CustomTxType& guess, Res& res, UniValue& txResults)
{
std::vector<unsigned char> metadata;
guess = GuessCustomTxType(*tx, metadata);
CCustomCSView mnview_dummy(*pcustomcsview);

switch (guess)
{
case CustomTxType::CreateMasternode:
res = ApplyCreateMasternodeTx(mnview_dummy, *tx, nHeight, metadata, &txResults);
break;
case CustomTxType::ResignMasternode:
res = ApplyResignMasternodeTx(mnview_dummy, ::ChainstateActive().CoinsTip(), *tx, nHeight, metadata, true, &txResults);
break;
case CustomTxType::CreateToken:
res = ApplyCreateTokenTx(mnview_dummy, ::ChainstateActive().CoinsTip(), *tx, nHeight, metadata, Params().GetConsensus(), true, &txResults);
break;
case CustomTxType::UpdateToken:
res = ApplyUpdateTokenTx(mnview_dummy, ::ChainstateActive().CoinsTip(), *tx, nHeight, metadata, Params().GetConsensus(), true, &txResults);
break;
case CustomTxType::UpdateTokenAny:
res = ApplyUpdateTokenAnyTx(mnview_dummy, ::ChainstateActive().CoinsTip(), *tx, nHeight, metadata, Params().GetConsensus(), true, &txResults);
break;
case CustomTxType::MintToken:
res = ApplyMintTokenTx(mnview_dummy, ::ChainstateActive().CoinsTip(), *tx, nHeight, metadata, Params().GetConsensus(), true, &txResults);
break;
case CustomTxType::CreatePoolPair:
res = ApplyCreatePoolPairTx(mnview_dummy, ::ChainstateActive().CoinsTip(), *tx, nHeight, metadata, Params().GetConsensus(), true, &txResults);
break;
case CustomTxType::UpdatePoolPair:
res = ApplyUpdatePoolPairTx(mnview_dummy, ::ChainstateActive().CoinsTip(), *tx, nHeight, metadata, Params().GetConsensus(), true, &txResults);
break;
case CustomTxType::PoolSwap:
res = ApplyPoolSwapTx(mnview_dummy, ::ChainstateActive().CoinsTip(), *tx, nHeight, metadata, Params().GetConsensus(), true, &txResults);
break;
case CustomTxType::AddPoolLiquidity:
res = ApplyAddPoolLiquidityTx(mnview_dummy, ::ChainstateActive().CoinsTip(), *tx, nHeight, metadata, Params().GetConsensus(), true, &txResults);
break;
case CustomTxType::RemovePoolLiquidity:
res = ApplyRemovePoolLiquidityTx(mnview_dummy, ::ChainstateActive().CoinsTip(), *tx, nHeight, metadata, Params().GetConsensus(), true, &txResults);
break;
case CustomTxType::UtxosToAccount:
res = ApplyUtxosToAccountTx(mnview_dummy, *tx, nHeight, metadata, Params().GetConsensus(), &txResults);
break;
case CustomTxType::AccountToUtxos:
res = ApplyAccountToUtxosTx(mnview_dummy, ::ChainstateActive().CoinsTip(), *tx, nHeight, metadata, Params().GetConsensus(), true, &txResults);
break;
case CustomTxType::AccountToAccount:
res = ApplyAccountToAccountTx(mnview_dummy, ::ChainstateActive().CoinsTip(), *tx, nHeight, metadata, Params().GetConsensus(), true, &txResults);
break;
case CustomTxType::SetGovVariable:
res = ApplySetGovernanceTx(mnview_dummy, ::ChainstateActive().CoinsTip(), *tx, nHeight, metadata, Params().GetConsensus(), true, &txResults);
break;
case CustomTxType::AnyAccountsToAccounts:
res = ApplyAnyAccountsToAccountsTx(mnview_dummy, ::ChainstateActive().CoinsTip(), *tx, nHeight, metadata, Params().GetConsensus(), true, &txResults);
break;
default:
return false;
}

return true;
}

static UniValue getcustomtx(const JSONRPCRequest& request)
{
std::shared_ptr<CWallet> const wallet = GetWalletForJSONRPCRequest(request);
Expand Down Expand Up @@ -4148,63 +4211,10 @@ static UniValue getcustomtx(const JSONRPCRequest& request)
return "Coinbase transaction. Not a custom transaction.";
}

std::vector<unsigned char> metadata;
guess = GuessCustomTxType(*tx, metadata);
CCustomCSView mnview_dummy(*pcustomcsview);

switch (guess)
{
case CustomTxType::CreateMasternode:
res = ApplyCreateMasternodeTx(mnview_dummy, *tx, nHeight, metadata, &txResults);
break;
case CustomTxType::ResignMasternode:
res = ApplyResignMasternodeTx(mnview_dummy, ::ChainstateActive().CoinsTip(), *tx, nHeight, metadata, true, &txResults);
break;
case CustomTxType::CreateToken:
res = ApplyCreateTokenTx(mnview_dummy, ::ChainstateActive().CoinsTip(), *tx, nHeight, metadata, Params().GetConsensus(), true, &txResults);
break;
case CustomTxType::UpdateToken:
res = ApplyUpdateTokenTx(mnview_dummy, ::ChainstateActive().CoinsTip(), *tx, nHeight, metadata, Params().GetConsensus(), true, &txResults);
break;
case CustomTxType::UpdateTokenAny:
res = ApplyUpdateTokenAnyTx(mnview_dummy, ::ChainstateActive().CoinsTip(), *tx, nHeight, metadata, Params().GetConsensus(), true, &txResults);
break;
case CustomTxType::MintToken:
res = ApplyMintTokenTx(mnview_dummy, ::ChainstateActive().CoinsTip(), *tx, nHeight, metadata, Params().GetConsensus(), true, &txResults);
break;
case CustomTxType::CreatePoolPair:
res = ApplyCreatePoolPairTx(mnview_dummy, ::ChainstateActive().CoinsTip(), *tx, nHeight, metadata, Params().GetConsensus(), true, &txResults);
break;
case CustomTxType::UpdatePoolPair:
res = ApplyUpdatePoolPairTx(mnview_dummy, ::ChainstateActive().CoinsTip(), *tx, nHeight, metadata, Params().GetConsensus(), true, &txResults);
break;
case CustomTxType::PoolSwap:
res = ApplyPoolSwapTx(mnview_dummy, ::ChainstateActive().CoinsTip(), *tx, nHeight, metadata, Params().GetConsensus(), true, &txResults);
break;
case CustomTxType::AddPoolLiquidity:
res = ApplyAddPoolLiquidityTx(mnview_dummy, ::ChainstateActive().CoinsTip(), *tx, nHeight, metadata, Params().GetConsensus(), true, &txResults);
break;
case CustomTxType::RemovePoolLiquidity:
res = ApplyRemovePoolLiquidityTx(mnview_dummy, ::ChainstateActive().CoinsTip(), *tx, nHeight, metadata, Params().GetConsensus(), true, &txResults);
break;
case CustomTxType::UtxosToAccount:
res = ApplyUtxosToAccountTx(mnview_dummy, *tx, nHeight, metadata, Params().GetConsensus(), &txResults);
break;
case CustomTxType::AccountToUtxos:
res = ApplyAccountToUtxosTx(mnview_dummy, ::ChainstateActive().CoinsTip(), *tx, nHeight, metadata, Params().GetConsensus(), true, &txResults);
break;
case CustomTxType::AccountToAccount:
res = ApplyAccountToAccountTx(mnview_dummy, ::ChainstateActive().CoinsTip(), *tx, nHeight, metadata, Params().GetConsensus(), true, &txResults);
break;
case CustomTxType::SetGovVariable:
res = ApplySetGovernanceTx(mnview_dummy, ::ChainstateActive().CoinsTip(), *tx, nHeight, metadata, Params().GetConsensus(), true, &txResults);
break;
case CustomTxType::AnyAccountsToAccounts:
res = ApplyAnyAccountsToAccountsTx(mnview_dummy, ::ChainstateActive().CoinsTip(), *tx, nHeight, metadata, Params().GetConsensus(), true, &txResults);
break;
default:
return "Not a custom transaction";
if (!GetCustomTXInfo(nHeight, tx, guess, res, txResults)) {
return "Not a custom transaction";
}

} else {
// Should not really get here without prior failure.
return "Could not find matching transaction.";
Expand All @@ -4231,8 +4241,8 @@ static UniValue getcustomtx(const JSONRPCRequest& request)

result.pushKV("blockhash", hashBlock.GetHex());
if (blockindex) {
result.pushKV("block height", blockindex->nHeight);
result.pushKV("blocktime", blockindex->GetBlockTime());
result.pushKV("blockHeight", blockindex->nHeight);
result.pushKV("blockTime", blockindex->GetBlockTime());
result.pushKV("confirmations", 1 + ::ChainActive().Height() - blockindex->nHeight);
} else {
result.pushKV("confirmations", 0);
Expand Down
3 changes: 3 additions & 0 deletions src/miner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -631,6 +631,9 @@ namespace pos {

if (!chainparams.GetConsensus().pos.allowMintingWithoutPeers && g_connman->GetNodeCount(CConnman::CONNECTIONS_ALL) == 0)
return Status::initWaiting;

if (::ChainstateActive().IsInitialBlockDownload())
return Status::initWaiting;
}

if (nLastSystemTime.time_since_epoch().count() != 0 && nLastSteadyTime.time_since_epoch().count() != 0) {
Expand Down
1 change: 1 addition & 0 deletions src/wallet/walletutil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ WalletLocation::WalletLocation(const std::string& name)
: m_name(name)
, m_path(fs::absolute(name, GetWalletDir()))
{
m_file_path = (m_path / m_name).string();
}

bool WalletLocation::Exists() const
Expand Down
7 changes: 6 additions & 1 deletion src/wallet/walletutil.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

#include <fs.h>

#include <string>
#include <vector>

//! Get the path of the wallet directory.
Expand All @@ -18,11 +19,12 @@ std::vector<fs::path> ListWalletDir();
//! The WalletLocation class provides wallet information.
class WalletLocation final
{
std::string m_file_path;
std::string m_name;
fs::path m_path;

public:
explicit WalletLocation() {}
WalletLocation() = default;
explicit WalletLocation(const std::string& name);

//! Get wallet name.
Expand All @@ -31,6 +33,9 @@ class WalletLocation final
//! Get wallet absolute path.
const fs::path& GetPath() const { return m_path; }

//! Get wallet absolute file path.
const std::string& GetFilePath() const { return m_file_path; }

//! Return whether the wallet exists.
bool Exists() const;
};
Expand Down
Loading

0 comments on commit 4ecf5e6

Please sign in to comment.