-
Notifications
You must be signed in to change notification settings - Fork 129
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
fix(dot/core): Batch process transaction message. #1780
Merged
Merged
Changes from 15 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
2467e9a
Batch process transaction message.
arijitAD b27e3d5
add storageState lock in core.HandleTransactionMessage
noot a9b7a40
log for each msg
noot 6a9a5dc
get best block hash at start of HandleTransactionMessage
noot 4aa177b
Merge branch 'development' of github.com:ChainSafe/gossamer into noot…
noot cae4919
lint
noot 4c897de
fix
noot 1eef284
fix again
noot b8b7bf3
Add tests and minor fix.
arijitAD ae5279c
Merge branch 'noot/fix-kusama' into batch-process-transaction
arijitAD 9d01963
Merge remote-tracking branch 'origin/development' into batch-process-…
arijitAD 5f001e8
Self review.
arijitAD de3bae4
Address deepsource errors.
arijitAD a231264
Address comments.
arijitAD 00bcf6c
Address comments.
arijitAD 21ad3ca
Merge remote-tracking branch 'origin/development' into batch-process-…
arijitAD 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -119,6 +119,39 @@ func decodeTransactionHandshake(_ []byte) (Handshake, error) { | |
return &transactionHandshake{}, nil | ||
} | ||
|
||
func (s *Service) createBatchMessageHandler(txnBatch chan *batchMessage) NotificationsMessageBatchHandler { | ||
return func(peer peer.ID, msg NotificationsMessage) (msgs []*batchMessage, err error) { | ||
data := &batchMessage{ | ||
msg: msg, | ||
peer: peer, | ||
} | ||
txnBatch <- data | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. could we check if the channel is closed before send data? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This channel will never be closed. |
||
|
||
if len(txnBatch) < s.batchSize { | ||
return nil, nil | ||
} | ||
|
||
var propagateMsgs []*batchMessage | ||
for txnData := range txnBatch { | ||
propagate, err := s.handleTransactionMessage(txnData.peer, txnData.msg) | ||
if err != nil { | ||
continue | ||
} | ||
if propagate { | ||
propagateMsgs = append(propagateMsgs, &batchMessage{ | ||
msg: txnData.msg, | ||
peer: txnData.peer, | ||
}) | ||
} | ||
if len(txnBatch) == 0 { | ||
break | ||
} | ||
} | ||
// May be use error to compute peer score. | ||
return propagateMsgs, nil | ||
} | ||
} | ||
|
||
func validateTransactionHandshake(_ peer.ID, _ Handshake) error { | ||
return nil | ||
} | ||
|
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
Oops, something went wrong.
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.
does
txnBatch
channel need to be passed in here? seems it's only used within this function, so can it be declared in this function>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.
Yes, It can be but we need to provide the channel from outside for the test cases.
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.
nit: we could receive a
txnBatch chan<- *batchMessage