-
Notifications
You must be signed in to change notification settings - Fork 8
Consensus separation - common components #85
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
Draft
ssd04
wants to merge
13
commits into
feat/consensus-separation
Choose a base branch
from
consensus-separation-components
base: feat/consensus-separation
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
c463adc
- added interfaces for p2p.Message, validator, epochStart ActionHandler
ssd04 3432869
fix core peer id reference
ssd04 d2813ba
added constants:
ssd04 a3b12c3
move IsContextDone from elrond-go to core
ssd04 eedf4fa
New fields on AccountQueryOptions.
andreibancioiu 3ab58f6
Adjust AccountQueryOptions.
andreibancioiu be24d29
Handle zero-values, as well.
andreibancioiu d498e11
Define optional values as structs.
andreibancioiu a7d8c4a
Fix type of fields.
andreibancioiu 093839d
Merge pull request #86 from ElrondNetwork/historical-balances
andreibancioiu 375b415
On AccountQueryOptions, add epoch hint.
andreibancioiu af2b26d
Merge pull request #88 from ElrondNetwork/historical-balances-older-e…
andreibancioiu e4b67c2
Merge branch 'rc/2022-july' into consensus-separation-components
ssd04 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 hidden or 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 hidden or 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,17 @@ | ||
package core | ||
|
||
import "context" | ||
|
||
// IsContextDone will return true if the provided context signals it is done | ||
func IsContextDone(ctx context.Context) bool { | ||
if ctx == nil { | ||
return true | ||
} | ||
|
||
select { | ||
case <-ctx.Done(): | ||
return true | ||
default: | ||
return false | ||
} | ||
} |
This file contains hidden or 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,46 @@ | ||
package core | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
// nolint | ||
func TestIsContextDone(t *testing.T) { | ||
t.Parallel() | ||
|
||
t.Run("valid context tests", func(t *testing.T) { | ||
numTests := 10 | ||
ctx, cancel := context.WithCancel(context.Background()) | ||
for i := 0; i < numTests; i++ { | ||
assert.False(t, IsContextDone(ctx)) | ||
} | ||
cancel() | ||
for i := 0; i < numTests; i++ { | ||
assert.True(t, IsContextDone(ctx)) | ||
} | ||
}) | ||
t.Run("nil context", func(t *testing.T) { | ||
assert.True(t, IsContextDone(nil)) | ||
}) | ||
} | ||
|
||
func BenchmarkIsContextDone_WhenDone(b *testing.B) { | ||
ctx, cancel := context.WithCancel(context.Background()) | ||
cancel() | ||
|
||
for i := 0; i < b.N; i++ { | ||
_ = IsContextDone(ctx) | ||
} | ||
} | ||
|
||
func BenchmarkIsContextDone_WhenNotDone(b *testing.B) { | ||
ctx, cancel := context.WithCancel(context.Background()) | ||
defer cancel() | ||
|
||
for i := 0; i < b.N; i++ { | ||
_ = IsContextDone(ctx) | ||
} | ||
} |
This file contains hidden or 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 hidden or 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,13 @@ | ||
package core | ||
|
||
// OptionalUint32 holds an optional uint32 value | ||
type OptionalUint32 struct { | ||
Value uint32 | ||
HasValue bool | ||
} | ||
|
||
// OptionalUint64 holds an optional uint64 value | ||
type OptionalUint64 struct { | ||
Value uint64 | ||
HasValue bool | ||
} |
This file contains hidden or 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.
mixed feelings about declaring this interface here. Also, for the Iterceptor and EpochStartActionHandler as they do not quite define the core business logic of elrond-go.
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.
will remain as it is, for now