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

Add file reading and writing #54

Merged
merged 22 commits into from
Dec 3, 2019
Merged

Add file reading and writing #54

merged 22 commits into from
Dec 3, 2019

Conversation

GregTheGreek
Copy link
Member

@GregTheGreek GregTheGreek commented Nov 29, 2019

New Features:

  • Writing strings to files
  • Reading file contents into a string
  • Return home directory
  • Parsing .toml to struct

Tests:

  • Cover all the above
  • Added helper method to perform a cleanup of tested files

Misc:

  • Reorganized clock tests under node/tests rather than being in the respective module
  • Marked certain methods under clock public

@ansermino
Copy link
Member

Please add toml support, we don't really need to read strings afaik.

@ec2
Copy link
Member

ec2 commented Nov 29, 2019

I think this might be for things like saving the peerID of yourself to a file?

@GregTheGreek
Copy link
Member Author

That is correct, I'll also add toml support

Copy link
Contributor

@austinabell austinabell left a comment

Choose a reason for hiding this comment

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

You didn't include this module in the lib.rs so it wasn't being compiled/tested.

Add:

pub mod utils;

to the node/src lib.rs file. You'll notice there are a few linting issues with private functions not being used

node/src/utils/mod.rs Outdated Show resolved Hide resolved
node/src/utils/mod.rs Outdated Show resolved Hide resolved
node/src/utils/mod.rs Outdated Show resolved Hide resolved
node/src/utils/test.rs Outdated Show resolved Hide resolved
@GregTheGreek GregTheGreek marked this pull request as ready for review December 3, 2019 06:55
node/Cargo.toml Show resolved Hide resolved
node/src/clock/mod.rs Outdated Show resolved Hide resolved
node/src/utils/mod.rs Outdated Show resolved Hide resolved
node/src/utils/mod.rs Outdated Show resolved Hide resolved
node/src/utils/mod.rs Outdated Show resolved Hide resolved
node/tests/utils_test.rs Outdated Show resolved Hide resolved
node/tests/utils_test.rs Outdated Show resolved Hide resolved
node/tests/utils_test.rs Outdated Show resolved Hide resolved
node/tests/utils_test.rs Outdated Show resolved Hide resolved
node/tests/utils_test.rs Outdated Show resolved Hide resolved
@ansermino
Copy link
Member

I think this might be for things like saving the peerID of yourself to a file?

Afaik keys are stored in raw bytes not strings

@GregTheGreek
Copy link
Member Author

Afaik keys are stored in raw bytes not strings

It doesn't seem we're actually using the key, rather only using the pubkey as a way to self identify. Which from what I know can be stored as a string
https://github.com/ChainSafe/ferret/blob/c03f05bcff6d88fb59f2037d7c07ce0cbc70a3db/node/ferret-libp2p/src/service.rs#L24

node/tests/utils_test.rs Outdated Show resolved Hide resolved
Copy link
Member

@ec2 ec2 left a comment

Choose a reason for hiding this comment

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

besides type as austin pointed out, lgtm

node/src/utils/mod.rs Outdated Show resolved Hide resolved
@GregTheGreek GregTheGreek merged commit 9fd58b8 into master Dec 3, 2019
@GregTheGreek GregTheGreek deleted the greg/net/id branch December 3, 2019 20:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants