Skip to content

Factor out start-a-libp2p-daemon!#21

Open
AlexKnauth wants to merge 3 commits into
vyzo:masterfrom
AlexKnauth:start-a-libp2p-daemon
Open

Factor out start-a-libp2p-daemon!#21
AlexKnauth wants to merge 3 commits into
vyzo:masterfrom
AlexKnauth:start-a-libp2p-daemon

Conversation

@AlexKnauth

@AlexKnauth AlexKnauth commented Mar 10, 2022

Copy link
Copy Markdown
Contributor
  • start-libp2p-daemon! for "a" daemon
  • stop-libp2p-daemon! for "a" daemon
  • start-the-libp2p-daemon! for "the" daemon in current-libp2p-daemon
  • stop-the-libp2p-daemon! for "the" daemon in current-libp2p-daemon

See also #20

to avoid current-libp2p-daemon problems

@bennewhall bennewhall left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If backwards compatibility is not an issue, I am personally in favor of removing current-libp2p-daemon entirely. I personally have not found much use for it in my own code since start-libp2p-daemon! returns a daemon. As far as the code goes LGTM

@fare fare left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like your proposed API changes as is. Or at least, you'll have to justify them.

Comment thread libp2p.ss
start-libp2p-daemon!
start-a-libp2p-daemon!
stop-libp2p-daemon!
stop-the-libp2p-daemon!

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is it start-a- and stop-the- ?

@AlexKnauth AlexKnauth Mar 11, 2022

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If backwards compatibility is a concern,
Current behavior has:

  • start-libp2p-daemon! for "the" daemon in current-libp2p-daemon
  • stop-libp2p-daemon! for "a" daemon, where current-libp2p-daemon doesn't matter

A better design would have:

  • start-libp2p-daemon! for "a" daemon
  • stop-libp2p-daemon! for "a" daemon
  • start-the-libp2p-daemon! for "the" daemon in current-libp2p-daemon
  • stop-the-libp2p-daemon! for "the" daemon in current-libp2p-daemon

The closest thing I could think of to that while maintaining backwards compatibility has:

  • start-a-libp2p-daemon! for "a daemon"
  • stop-libp2p-daemon! for "a" daemon as dictated by existing code
  • start-libp2p-daemon! for "the" daemon as dictated by existing code
  • stop-the-libp2p-daemon! for "the" daemon in current-libp2p-daemon

If backwards compatibility is not a concern, I could make it more consistent with only "the" and no "a", but I won't do that unless @vyzo says that's what he wants.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, I've changed the convention to make it more consistent with only "the" and no "a", and also added some documentation.

Comment thread libp2p/daemon.ss
(make-parameter #f))

;; Starts a new libp2p-daemon only if there is no existing current-libp2p-daemon,
;; and if so sets the current-libp2p-daemon to the new one.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe that should be renamed ensure-libp2p-daemon ?
Or, if we want backward-compatibility, a force: or new: boolean flag?

Comment thread libp2p/daemon.ss

(def (stop-the-libp2p-daemon!)
(stop-libp2p-daemon!)
(current-libp2p-daemon #f))

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't stop-libp2p-daemon! always call (current-libp2p-daemon #f) ? And then this function becomes unnecessary?

@vyzo

vyzo commented Mar 11, 2022

Copy link
Copy Markdown
Owner

Honestly, i am fine either way -- i'll let @fare drive this.

@AlexKnauth

Copy link
Copy Markdown
Contributor Author

Okay, I think I'll rename them to fit this convention:

  • start-libp2p-daemon! for "a" daemon
  • stop-libp2p-daemon! for "a" daemon
  • start-the-libp2p-daemon! for "the" daemon in current-libp2p-daemon
  • stop-the-libp2p-daemon! for "the" daemon in current-libp2p-daemon

convention: names with "the" libp2p-daemon convention for functions that deal with current-libp2p-daemon
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants