js-libp2p icon indicating copy to clipboard operation
js-libp2p copied to clipboard

Atomic and transactional read/write

Open bakhshandeh opened this issue 2 years ago • 3 comments

I want to implement a global lock in Libp2p. Is it possible? any way to atomically read/write DHT records?

bakhshandeh avatar Aug 29 '22 08:08 bakhshandeh

Could you expand a little more on your use case? Presumably you'd need to handle failures, rollback, prevent deadlocks, etc.

This isn't something we have planned currently.

achingbrain avatar Sep 06 '22 15:09 achingbrain

Could you expand a little more on your use case? Presumably you'd need to handle failures, rollback, prevent deadlocks, etc.

This isn't something we have planned currently.

Something like this: https://redis.io/commands/setnx/

There is a network with N nodes. One node can acquire a lock for T seconds to run an operation. While the lock is not expired, other nodes can't acquire the lock.

Deadlocks and rollback could be handled by the application. I just want to know that this use case is feasible or not?

bakhshandeh avatar Sep 18 '22 20:09 bakhshandeh

If you're talking about an application-level lock, it sounds like you'd need to implement a custom protocol that does the lock operations which is totally feasible.

If this is something that would meet your needs, you could look at the fetch protocol for an example - it's a very simple request/response protocol that sends and receives messages between peers - you'd design your locking protocol to operate in a similar way.

achingbrain avatar Sep 20 '22 16:09 achingbrain

Oops, seems like we needed more information for this issue, please comment with more details or this issue will be closed in 7 days.

github-actions[bot] avatar Sep 27 '22 02:09 github-actions[bot]

This issue was closed because it is missing author input.

github-actions[bot] avatar Oct 05 '22 02:10 github-actions[bot]