-
Notifications
You must be signed in to change notification settings - Fork 178
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
[ledger] Ledger cleanups + make a test async #1073
Conversation
738f918
to
bb1a8ea
Compare
stopc chan struct{} | ||
wg sync.WaitGroup | ||
lm *lifecycle.LifecycleManager |
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.
🥳
bb1a8ea
to
52668c1
Compare
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.
LGTM
for observer := range c.observers { | ||
observer.OnComplete() | ||
} | ||
c.stopc <- struct{}{} |
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.
You may be interested in #1077, which will allow you to replace c.stopc
as well :)
@@ -289,7 +281,7 @@ func (p *TrieProof) String() string { | |||
interimIndex := 0 | |||
for j := 0; j < int(p.Steps); j++ { | |||
// if bit is set | |||
if p.Flags[j/8]&(1<<int(7-j%8)) != 0 { |
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.
@tarakby is this change okey?
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.
j
is an integer, %
has an integer codomain, and j % 8
<= 7 by specification
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.
That's correct, but we can replace this by Bit(p.Falgs, j)
using this tool 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.
I remembered Tarak recommended something about this part of the code and I was not remembering the details, that's why I asked.
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 flagging @ramtinms. You're right I made changes in the past to the Bit
function.
@@ -0,0 +1,8 @@ | |||
package observable | |||
|
|||
type Observable interface { |
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 wonder if we maybe should use some established library for this - https://github.com/ReactiveX/RxGo
Now the usecase is simple but it might grow
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'm familiar with RxGo and very much in favor, but I don't think we have scope for using it fully as a consequence of this PR alone.
The Observable API I put in modules right now is forward-compatible.
52668c1
to
c59c9cb
Compare
c59c9cb
to
ec51229
Compare
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 ledger tools and tests clean up!
Minor suggestions.
Out of curiosity, did you use a linter tool to find out the non-needed type casts or was it by manual review ?
ledger/common/encoding/encoding.go
Outdated
@@ -272,7 +272,7 @@ func DecodeValue(encodedValue []byte) (ledger.Value, error) { | |||
} | |||
|
|||
func decodeValue(inp []byte) (ledger.Value, error) { | |||
return ledger.Value(inp), nil | |||
return inp, nil |
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.
We could delete the function in this case. It also never errors.
@@ -289,7 +281,7 @@ func (p *TrieProof) String() string { | |||
interimIndex := 0 | |||
for j := 0; j < int(p.Steps); j++ { | |||
// if bit is set | |||
if p.Flags[j/8]&(1<<int(7-j%8)) != 0 { |
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.
That's correct, but we can replace this by Bit(p.Falgs, j)
using this tool function.
@tarakby I blasted the ones my IDE highlighted, but if we want to put that in CI, golang-ci supports unconvert: https://golangci-lint.run/usage/linters/ |
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.
Looks good now
superseded by defaultHashes at init
See //reactivex.io/documentation/observable.html
- introduces a most minima form of the Observable interface to modules/observable See: http://reactivex.io/documentation/observable.html - make the compactor test asynchronous
ec51229
to
cc95354
Compare
This reverts commit 845a00b. Reasons for reversal: - provided impetus for clearing out races (onflow#1073, onflow#1095) - network tests now pass with race detector on! - but those timings are preposterous
This reverts commit 845a00b. Reasons for reversal: - provided impetus for clearing out races (onflow#1073, onflow#1095) - network tests now pass with race detector on! - but those timings are preposterous
found while trying to read about / dig into the WAL:
Test_Compactor/Compactor_creates_checkpoints_eventually
asynchronous but deterministic,(introduces a minimalistic
Observable
interface that I know I'll reuse elsewhere, though not in this PR, see Networking test races #1020 )