Skip to content

Commit

Permalink
Port rpc blockchain
Browse files Browse the repository at this point in the history
  • Loading branch information
timemarkovqtum committed Jul 5, 2024
1 parent 004a845 commit c931843
Show file tree
Hide file tree
Showing 7 changed files with 797 additions and 22 deletions.
778 changes: 769 additions & 9 deletions src/rpc/blockchain.cpp

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/rpc/external_signer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ static RPCHelpMan enumeratesigners()
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
{
const std::string command = gArgs.GetArg("-signer", "");
if (command == "") throw JSONRPCError(RPC_MISC_ERROR, "Error: restart bitcoind with -signer=<cmd>");
if (command == "") throw JSONRPCError(RPC_MISC_ERROR, "Error: restart qtumd with -signer=<cmd>");
const std::string chain = gArgs.GetChainTypeString();
UniValue signers_res = UniValue::VARR;
try {
Expand Down
18 changes: 9 additions & 9 deletions src/rpc/net.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -317,8 +317,8 @@ static RPCHelpMan addnode()
},
RPCResult{RPCResult::Type::NONE, "", ""},
RPCExamples{
HelpExampleCli("addnode", "\"192.168.0.6:8333\" \"onetry\" true")
+ HelpExampleRpc("addnode", "\"192.168.0.6:8333\", \"onetry\" true")
HelpExampleCli("addnode", "\"192.168.0.6:3888\" \"onetry\" true")
+ HelpExampleRpc("addnode", "\"192.168.0.6:3888\", \"onetry\" true")
},
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
{
Expand Down Expand Up @@ -380,8 +380,8 @@ static RPCHelpMan addconnection()
{ RPCResult::Type::STR, "connection_type", "Type of connection opened." },
}},
RPCExamples{
HelpExampleCli("addconnection", "\"192.168.0.6:8333\" \"outbound-full-relay\" true")
+ HelpExampleRpc("addconnection", "\"192.168.0.6:8333\" \"outbound-full-relay\" true")
HelpExampleCli("addconnection", "\"192.168.0.6:3888\" \"outbound-full-relay\" true")
+ HelpExampleRpc("addconnection", "\"192.168.0.6:3888\" \"outbound-full-relay\" true")
},
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
{
Expand Down Expand Up @@ -438,9 +438,9 @@ static RPCHelpMan disconnectnode()
},
RPCResult{RPCResult::Type::NONE, "", ""},
RPCExamples{
HelpExampleCli("disconnectnode", "\"192.168.0.6:8333\"")
HelpExampleCli("disconnectnode", "\"192.168.0.6:3888\"")
+ HelpExampleCli("disconnectnode", "\"\" 1")
+ HelpExampleRpc("disconnectnode", "\"192.168.0.6:8333\"")
+ HelpExampleRpc("disconnectnode", "\"192.168.0.6:3888\"")
+ HelpExampleRpc("disconnectnode", "\"\", 1")
},
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
Expand Down Expand Up @@ -491,7 +491,7 @@ static RPCHelpMan getaddednodeinfo()
{
{RPCResult::Type::OBJ, "", "",
{
{RPCResult::Type::STR, "address", "The bitcoin server IP and port we're connected to"},
{RPCResult::Type::STR, "address", "The qtum server IP and port we're connected to"},
{RPCResult::Type::STR, "connected", "connection, inbound or outbound"},
}},
}},
Expand Down Expand Up @@ -964,8 +964,8 @@ static RPCHelpMan addpeeraddress()
},
},
RPCExamples{
HelpExampleCli("addpeeraddress", "\"1.2.3.4\" 8333 true")
+ HelpExampleRpc("addpeeraddress", "\"1.2.3.4\", 8333, true")
HelpExampleCli("addpeeraddress", "\"1.2.3.4\" 3888 true")
+ HelpExampleRpc("addpeeraddress", "\"1.2.3.4\", 3888, true")
},
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
{
Expand Down
4 changes: 2 additions & 2 deletions src/util/fs_helpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ static GlobalMutex cs_dir_locks;
*/
static std::map<std::string, std::unique_ptr<fsbridge::FileLock>> dir_locks GUARDED_BY(cs_dir_locks);
namespace util {
LockResult LockDirectory(const fs::path& directory, const fs::path& lockfile_name, bool probe_only)
LockResult LockDirectory(const fs::path& directory, const fs::path& lockfile_name, bool probe_only, bool try_lock)
{
LOCK(cs_dir_locks);
fs::path pathLockFile = directory / lockfile_name;
Expand All @@ -68,7 +68,7 @@ LockResult LockDirectory(const fs::path& directory, const fs::path& lockfile_nam
return LockResult::ErrorWrite;
}
auto lock = std::make_unique<fsbridge::FileLock>(pathLockFile);
if (!lock->TryLock()) {
if (try_lock && !lock->TryLock()) {
error("Error while attempting to lock directory %s: %s", fs::PathToString(directory), lock->GetReason());
return LockResult::ErrorLock;
}
Expand Down
2 changes: 1 addition & 1 deletion src/util/fs_helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ enum class LockResult {
ErrorWrite,
ErrorLock,
};
[[nodiscard]] LockResult LockDirectory(const fs::path& directory, const fs::path& lockfile_name, bool probe_only = false);
[[nodiscard]] LockResult LockDirectory(const fs::path& directory, const fs::path& lockfile_name, bool probe_only = false, bool try_lock = true);
} // namespace util
void UnlockDirectory(const fs::path& directory, const fs::path& lockfile_name);
bool CheckDiskSpace(const fs::path& dir, uint64_t additional_bytes = 0);
Expand Down
10 changes: 10 additions & 0 deletions src/validation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6215,3 +6215,13 @@ bool GetAddressUnspent(uint256 addressHash, int type, std::vector<std::pair<CAdd
{
return {};
}

bool GetAddressWeight(uint256 addressHash, int type, const std::map<COutPoint, uint32_t>& immatureStakes, int32_t nHeight, uint64_t& nWeight, node::BlockManager& blockman)
{
return {};
}

std::map<COutPoint, uint32_t> GetImmatureStakes(ChainstateManager& chainman)
{
return {};
}
5 changes: 5 additions & 0 deletions src/validation.h
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,11 @@ static_assert(std::is_nothrow_destructible_v<CScriptCheck>);
bool GetAddressUnspent(uint256 addressHash, int type,
std::vector<std::pair<CAddressUnspentKey, CAddressUnspentValue> > &unspentOutputs, node::BlockManager& blockman);

bool GetAddressWeight(uint256 addressHash, int type, const std::map<COutPoint, uint32_t>& immatureStakes, int32_t nHeight, uint64_t& nWeight, node::BlockManager& blockman);

std::map<COutPoint, uint32_t> GetImmatureStakes(ChainstateManager& chainman);
/////////////////////////////////////////////////////////////////

/** Functions for validating blocks and updating the block tree */

/** Context-independent validity checks */
Expand Down

0 comments on commit c931843

Please sign in to comment.