Skip to content
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

persist node name across restarts #1522

Closed
noot opened this issue Apr 13, 2021 · 4 comments · Fixed by #1543
Closed

persist node name across restarts #1522

noot opened this issue Apr 13, 2021 · 4 comments · Fixed by #1543

Comments

@noot
Copy link
Contributor

noot commented Apr 13, 2021

Describe the bug

  • node currently generates a new random name every time it starts, but it should create a random name when it starts for the first time and use that name every time it starts up afterwards (can write it to the db)
@noot noot added the p3 label Apr 13, 2021
@EclesioMeloJunior
Copy link
Member

is it a good idea to put the node name into de config.toml? And then load the name from the file whenever the node initializes or reinitializes?

@noot
Copy link
Contributor Author

noot commented Apr 16, 2021

@EclesioMeloJunior the name can already be specified using the config file, this issue is so that a random name isn't generated every time the node restarts (if none is specified), the node should use the same name unless it becomes re-initialized

@EclesioMeloJunior
Copy link
Member

EclesioMeloJunior commented Apr 21, 2021

@noot I thought of the following logic:

  • If there's no flag name then try to retrieve the node name from the database.
  • If the database result returns data then use it as node global name
  • If the database result does not succeeded so generate a random name and store this one in the database

So, when the node initializes we will generate a random name and store it, and when the node reinitializes we will retrieve the persisted name.

But I have noticed that the method dot.InitNode calls the method state.Service.Initialize and this method executes

db.ClearAll()

So, if we store the node name in the database on initialization then when the node reinitialize the stored name will be lost?

@arijitAD
Copy link
Contributor

@noot I thought of the following logic:

  • If there's no flag name then try to retrieve the node name from the database.
  • If the database result returns data then use it as node global name
  • If the database result does not succeeded so generate a random name and store this one in the database

So, when the node initializes we will generate a random name and store it, and when the node reinitializes we will retrieve the persisted name.

But I have noticed that the method dot.InitNode calls the method state.Service.Initialize and this method executes

db.ClearAll()

So, if we store the node name in the database on initialization then when the node reinitialize the stored name will be lost?

We initialize the node once but we can run it multiple times. Initialization is only needed if you want to start fresh.

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 a pull request may close this issue.

4 participants