Skip to content
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

Add FindRelatedTransactions Function for Block Storage #290

Merged
merged 14 commits into from
Feb 19, 2021

Conversation

varunpcb
Copy link
Contributor

@varunpcb varunpcb commented Jan 8, 2021

Motivation

This change adds the FindRelatedTransactions function to block storage, which will allow for related transaction processing in the future. This change also adds a duplicate check for related transactions to the asserter.

Solution

By checking all forward and backward relations, FindRelatedTransactions finds the highest block that must be confirmed to confirm a given transaction.

Open questions

@varunpcb varunpcb changed the title add FindRelatedTransactions function [WIP] add FindRelatedTransactions function Jan 8, 2021

_, err := db.Scan(
ctx,
getBackwardRelationKey(tx.TransactionIdentifier, nil),
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a lot cleaner than maintaining a separate prefix function. We should probably go back and remove any ...prefix() functions in another PR.

@varunpcb varunpcb closed this Jan 13, 2021
@varunpcb varunpcb reopened this Jan 13, 2021
@varunpcb varunpcb changed the title [WIP] add FindRelatedTransactions function Add FindRelatedTransactions Function for Block Storage Jan 14, 2021
asserter/block.go Outdated Show resolved Hide resolved
asserter/block.go Outdated Show resolved Hide resolved
storage/modules/block_storage.go Outdated Show resolved Hide resolved
storage/modules/block_storage.go Outdated Show resolved Hide resolved
storage/modules/block_storage.go Outdated Show resolved Hide resolved
storage/modules/block_storage.go Outdated Show resolved Hide resolved
@@ -1084,6 +1184,108 @@ func (b *BlockStorage) FindTransaction(
return newestBlock, newestTransaction, nil
}

func (b *BlockStorage) FindRelatedTransactions(
Copy link
Contributor

Choose a reason for hiding this comment

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

If this method is supposed to return only forward related transactions, we should make it obvious in the name. Something like FindForwardRelatedTransactions. 🙏 🙏

Let's also pl add a comment describing what it does and its return values.
For instance, we should mention that it collects entire chains of forward relations, however many levels deep.
And that it considers transactions that point to the passed transactionIdentifier via backward relationship, as forward relations.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this function is meant to fetch all related txs. It currently handles both forward and backward relations. I think the name is fitting as any expansion will require further subroutines regardless.

storage/modules/block_storage.go Outdated Show resolved Hide resolved
storage/modules/block_storage.go Show resolved Hide resolved
storage/modules/block_storage.go Show resolved Hide resolved
@varunpcb varunpcb requested a review from septerr February 17, 2021 20:54
@septerr septerr merged commit 2522314 into coinbase:master Feb 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

5 participants