-
-
Notifications
You must be signed in to change notification settings - Fork 0
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
More bugfixes & some suggested changes #11
Conversation
Aren't they both idiomatic? The docs seem to imply that they are, at least — possibly even encouraging folds as I read it 🤔 Googling around, it looks like there's some debate about which to use. Stylistically, I like that I'm sure that there's cases where each does better, but I've also seen a few benchmarks where iterator methods like |
Okay, sure. I personally found it harder to read, but I have pretty weak opinions on that one. |
Oh yeah, same here. I was just surprised by the claim! |
@@ -79,7 +80,7 @@ pub struct MemoryStore< | |||
V: varsig::Header<C> = varsig::header::Preset, | |||
C: Codec + TryFrom<u64> + Into<u64> = varsig::encoding::Preset, | |||
> { | |||
inner: Arc<RwLock<MemoryStoreInner<DID, V, C>>>, | |||
inner: Arc<Mutex<MemoryStoreInner<DID, V, C>>>, |
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.
To account for starvation I guess?
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.
Yeah, due to this conversation. I think RwLocks being able to cause deadlocks is... not great. Defaulting to Mutex seems like the better option 👍
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 @matheus23
This reverts commit c06e6de.
551ef37
to
d0fab39
Compare
I only rebased the same changes on the newest commits from the |
In this PR the individual commits should read really nicely!
So I'd recommend reviewing by commit.
There's mostly bugfixes, some solved
FIXME
s, which I'd expect be uncontroversial changes (ignoring possible bugs I've introduced).But there's also some changes that are more subjective:
command: &str
instead ofcommand: String
inStore::get_chain
: I think this makes sense, because get chain is mostly a lookup, it doesn't need ownership to construct the return value.Turn thereverted this, it's in the history should we need it :)Iterator::try_fold
call inInvocation::check
into afor
loop: I think that just reads slightly easier & is more idiomatic in rust.