Skip to content

Commit

Permalink
GetTransactionStatus Should respect txn query with or without 0x. (#3795
Browse files Browse the repository at this point in the history
)
  • Loading branch information
saeed-zil committed Oct 2, 2023
1 parent 8890d55 commit 5b59c76
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/libRemoteStorageDB/RemoteStorageDB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ bool RemoteStorageDB::UpdateTxn(const string& txnhash, const TxnStatus status,
return true;
}

Json::Value RemoteStorageDB::QueryTxnHash(const std::string& txnhash) {
Json::Value RemoteStorageDB::QueryTxnHash(const dev::h256& txnhash) {
LOG_MARKER();
Json::Value _json{Json::Value::null};
if (!m_initialized) {
Expand All @@ -264,7 +264,7 @@ Json::Value RemoteStorageDB::QueryTxnHash(const std::string& txnhash) {
return _json;
}
auto txnCollection = conn.value()->database(m_dbName)[m_txnCollectionName];
auto cursor = txnCollection.find_one(make_document(kvp("ID", txnhash)));
auto cursor = txnCollection.find_one(make_document(kvp("ID", txnhash.hex())));
if (cursor) {
const auto& json_string = bsoncxx::to_json(cursor.value());
Json::Reader reader;
Expand Down
2 changes: 1 addition & 1 deletion src/libRemoteStorageDB/RemoteStorageDB.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class RemoteStorageDB : boost::noncopyable {
const uint64_t& epoch, const bool success = false);
bool UpdateTxn(const std::string& txnhash, const TxnStatus status,
const uint64_t& epoch, const bool success);
Json::Value QueryTxnHash(const std::string& txnhash);
Json::Value QueryTxnHash(const dev::h256& hash);
Json::Value QueryPendingTxns(const unsigned int txEpochFirstExclusive,
const unsigned int txEpochLastInclusive);
ModificationState GetModificationState(const TxnStatus status) const;
Expand Down
8 changes: 3 additions & 5 deletions src/libServer/LookupServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2122,12 +2122,10 @@ Json::Value LookupServer::GetTransactionStatus(const string& txnhash) {
if (!REMOTESTORAGE_DB_ENABLE) {
throw JsonRpcException(RPC_DATABASE_ERROR, "API not supported");
}
if (txnhash.size() != TRAN_HASH_SIZE * 2) {
throw JsonRpcException(RPC_INVALID_PARAMETER,
"Txn Hash size not appropriate");
}

const auto& result = RemoteStorageDB::GetInstance().QueryTxnHash(txnhash);
TxnHash tranHash(txnhash);

const auto& result = RemoteStorageDB::GetInstance().QueryTxnHash(tranHash);

if (result.isMember("error")) {
throw JsonRpcException(RPC_DATABASE_ERROR, "Internal database error");
Expand Down

0 comments on commit 5b59c76

Please sign in to comment.