-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Feat/retrieval market #1552 #1565
Conversation
e8d58ce
to
c6ed95b
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.
So,
There are unfortunately a few problems here, and this turns out to be quite a bit more complicated than I'd imagined.
The problem here is that the payment channel manager is stateful, and intended to be used by multiple consumers, in different threads. That's why there's a mutex lock around GetPayCh in the payment channel manager.
So there are a couple problems this raises:
- First, behavior that was enclosed by the mutex is not now (your WaitFor methods)
- There's a much more serious problem though -- the entire architecture of GetPayCh relies on it being an atomic operation (including the wait) -- that's the origin of the TODO comment about waiting outside the store lock. The fact that you have it separated into independent methods raises various issues -- you're relying on the caller to call WaitFor -- what if they don't? Based on the fact that the manager is stateful, you still need to wait for the message and update the channel state somehow.
So, this starts to look like a more significant rearchitect. Probably I would propose something like this:
In the initial methods, get to the end, then kick off a go routine to wait for the message internally, save the results and release the mutex only when finished (so the contents of the WaitFor methods live in the go routine)
I would then remove the WaitFor methods on the PayCh manager.
Instead, in the retrieval adapter itself, I would just call StateWaitMessage directly, and in the case of create, read the returned address directly.
7c7947b
to
67468cb
Compare
67468cb
to
f07e75a
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 by me.
@magik6k we still weren't totally sure what to do about the locking mechanism here, so for the time being we've left it at basically replicating what was there before.
Btw, we're trying to have the markets modules block as little as possible on chain operations, so that we can get to the point of being able to resume in progress market transactions when a node shuts down and restarts. In this case, on a restarted retrieval deal, we do not want to add funds / create the channel again in the case where the message was already submitted.
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.
1 comment, then LGTM
…#1552 Feat/retrieval market #1552
Closes #1552
Support non-blocking creation of payment channel and adding funds via implementing the new go-fil-markets API, namely:
GetOrCreatePaymentChannel
now shouldaddress.Undef
+ message CID to wait forNew API methods:
WaitForPaymentChannelCreation, WaitForPaymentChannelAddFunds