Skip to content
This repository has been archived by the owner on Apr 17, 2019. It is now read-only.

Feature/rejected txs index #1846

Merged
merged 7 commits into from
Nov 16, 2018

Conversation

kamilsa
Copy link
Contributor

@kamilsa kamilsa commented Nov 13, 2018

Description of the Change

We should be able to check whether transaction has been processed by ledger, even if it was rejected. This PR adds this functionality by adding hasRejectedTxWithHash query in block query. In future it can be used by committed transactions cache.

Benefits

Now we have all means to implement fair implementation of committed transactions cache

Possible Drawbacks

None

Usage Examples or Tests

Corresponding tests on block query were provided

Copy link
Contributor

@igor-egorov igor-egorov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please consider avoidance of having to separate methods for checking the same single transaction. Details are described in a review comments.

If you insist on the current implementation, then let me know - I will approve.

@@ -39,6 +39,15 @@ namespace {
return (base % hash.hex() % height).str();
}

std::string makeRejectedTxHashIndex(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest a bit different naming - storeRejectedTxHash

Otherwise make index sounds like CREATE INDEX index_name ON table_name (column1, column2, ...); will be executed under the hood :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with you. My intention was to keep the naming consisted with other methods here. I can add the task to provide better naming for that function

const shared_model::crypto::Hash &hash) {
return getBlockId(hash) != boost::none;
}

bool PostgresBlockQuery::hasRejectedTxWithHash(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why should we separate hashes storage on two methods?
Why could we not store both kinds of hashes in the same table with different markers in a separate column?

something like:

+-----+----------------+--------------------+-----+
| ... | hash           | committed/rejected | ... |
+-----+----------------+--------------------+-----+
|     | 2ac7b67ca6b76c | committed          |     |
+-----+----------------+--------------------+-----+
|     | 89ac7b867a875a | rejected           |     |
+-----+----------------+--------------------+-----+

That approach will let us avoid looking up in two independent sources for the single transaction in the worst case.
Also, we will have only one method for a transaction look up.

Copy link
Contributor

@luckychess luckychess left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me but please consider possibility of @igor-egorov suggestion about using a single table.

@kamilsa kamilsa changed the base branch from dev to trunk/tx_persistent_cache November 16, 2018 08:19
@kamilsa kamilsa force-pushed the feature/rejected_txs_index branch from be3fcb4 to 39875f1 Compare November 16, 2018 08:19
Signed-off-by: kamilsa <[email protected]>
Signed-off-by: kamilsa <[email protected]>
Copy link
Contributor

@igor-egorov igor-egorov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@@ -508,6 +508,12 @@ CREATE TABLE IF NOT EXISTS height_by_hash (
hash varchar,
height text
);

CREATE TABLE IF NOT EXISTS height_by_rejected_hash (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add drop table please (somewhere)

@kamilsa kamilsa merged commit 025ed5d into trunk/tx_persistent_cache Nov 16, 2018
@kamilsa kamilsa deleted the feature/rejected_txs_index branch November 16, 2018 11:22
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants