-
Notifications
You must be signed in to change notification settings - Fork 282
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(core-api): hasTransactionFinality() on connector API #812
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
packages/cactus-core/src/main/typescript/consensus-has-transaction-finality.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { | ||
ConsensusAlgorithmFamily, | ||
ConsensusAlgorithmFamiliesWithTxFinality, | ||
ConsensusAlgorithmFamiliesWithOutTxFinality, | ||
} from "@hyperledger/cactus-core-api"; | ||
|
||
export function consensusHasTransactionFinality( | ||
consensusAlgorithmFamily: ConsensusAlgorithmFamily, | ||
): boolean { | ||
const isInConsensusAlgorithmFamiliesWithTxFinality = (Object.values( | ||
ConsensusAlgorithmFamiliesWithTxFinality, | ||
) as string[]).includes(consensusAlgorithmFamily.toString()); | ||
|
||
const isInConsensusAlgorithmFamiliesWithOutTxFinality = (Object.values( | ||
ConsensusAlgorithmFamiliesWithOutTxFinality, | ||
) as string[]).includes(consensusAlgorithmFamily.toString()); | ||
|
||
const unrecognizedConsensusAlgorithmFamily = | ||
!isInConsensusAlgorithmFamiliesWithTxFinality && | ||
!isInConsensusAlgorithmFamiliesWithOutTxFinality; | ||
|
||
if (unrecognizedConsensusAlgorithmFamily) { | ||
throw new Error( | ||
`Unrecognized consensus algorithm family: ${consensusAlgorithmFamily}`, | ||
); | ||
} | ||
return isInConsensusAlgorithmFamiliesWithTxFinality; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just copy paste the implementation in those *-plugin-ledger-connectors. But I am not so sure, since it is just a stub, so maybe you would want just return false or do some other things?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's perfectly fine as it is IMO. The stub is just there to help with testing so the expectation is that if someone wants to use it to simulate different consensus algorithm families then they can either sub-class it or override the default behavior some other way.
The only thing I need now is the commits to be squashed into a single one so that there are no in-between states (every commit on the main branch should be valid, passing, tests, etc.
So if you squash and then force push (make sure to have the commit signed off) then I'll smash that approve button right after that. Thank you for the contribution and working with me on hammering out the details!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the help for my first pull request!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jscode017 About to approve and merge this, but I wanted to give one more piece of advice regarding the mechanics of how PR reviews are done:
If someone reviews the PR (e.g. when I literally click button submit review) from that point on it won't notify me until you hit the 're-request review' button (that little refresh icon next to my name in the top right corner among the reviewers).
This is not an actual issue, but I wanted to explain this anyway because I just saw by chance that you had fixed everything that I was asking for more than a week ago but I only noticed it now (otherwise I would've approved+merged the same day)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for that, I would hit the 're-request review' next time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No worries at all, thank you again for the PR!