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

Refactor/waku.doc #1950

Merged
merged 7 commits into from Apr 23, 2020
Merged

Refactor/waku.doc #1950

merged 7 commits into from Apr 23, 2020

Conversation

Samyoul
Copy link
Member

@Samyoul Samyoul commented Apr 23, 2020

Why make the change?

waku/doc.go is a hangover from https://github.com/ethereum/go-ethereum/blob/master/whisper/whisperv6/doc.go and has become a bit of a dumping ground for any miscellaneous waku functionality or structs.

Additionally the golang docs convention reserves the doc.go file for housing only docs.

another convention for packages that need large amounts of introductory documentation: the package comment is placed in its own file, doc.go, which contains only those comments and a package clause.

What has changed?

  • Removal of doc.go and doc_test.go
  • Moved package consts to const.go
  • Moved EnvelopeError{} to envelope.go
  • Renamed mailserver_response.go to mailserver.go
  • Moved MailServer{} interface to mailserver.go
  • Moved MailServerResponse{} to mailserver.go
  • Moved MessagesRequest{}, MessagesResponse{}, MultiVersionResponse{}, Version1MessageResponse{} and NewMessagesResponse() to message.go
  • Moved TestEncodeDecodeVersionedResponse{} to message_test.go
  • Moved RateLimits{} to rate_limiter.go

The same changes were also applied to the whisper package.

Moved out all code from docs.go, placed much of the seemingly misc code into much more closely related files, created a dedicated const file for housing all the package consts.
@status-github-bot
Copy link

status-github-bot bot commented Apr 23, 2020

Pull Request Checklist

  • Have you updated the documentation, if impacted (e.g. docs.status.im)?

@status-im-auto
Copy link
Member

status-im-auto commented Apr 23, 2020

Jenkins Builds

Click to see older builds (6)
Commit #️⃣ Finished (UTC) Duration Platform Result
✔️ 1a5baa5 #1 2020-04-23 14:06:17 ~52 sec linux 📦zip
✔️ 1a5baa5 #1 2020-04-23 14:11:07 ~5 min ios 📦zip
✔️ 1a5baa5 #1 2020-04-23 14:14:14 ~8 min android 📦aar
✔️ ab45dbb #2 2020-04-23 15:15:32 ~46 sec linux 📦zip
✔️ ab45dbb #2 2020-04-23 15:18:29 ~3 min ios 📦zip
✔️ ab45dbb #2 2020-04-23 15:21:37 ~6 min android 📦aar
Commit #️⃣ Finished (UTC) Duration Platform Result
✔️ 04413b9 #3 2020-04-23 16:18:12 ~41 sec linux 📦zip
✔️ 04413b9 #3 2020-04-23 16:22:58 ~5 min ios 📦zip
✔️ 04413b9 #3 2020-04-23 16:25:59 ~8 min android 📦aar
✔️ 2680f60 #4 2020-04-23 16:46:45 ~39 sec linux 📦zip
✔️ 2680f60 #4 2020-04-23 16:48:53 ~2 min ios 📦zip
✔️ 2680f60 #4 2020-04-23 16:52:38 ~6 min android 📦aar

Comment on lines -185 to -187
if err != nil {
t.Fatalf("failed Wrap with seed %d: %s.", seed, err)
}
Copy link
Member Author

@Samyoul Samyoul Apr 23, 2020

Choose a reason for hiding this comment

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

Just so I'm not trying to sneak this through, I want to point out the I've removed this because the condition is always false because err is always nil. The err is tested on line 181 and doesn't change after that check and before the check I've removed.

Comment on lines +500 to +504
b, err := rlp.EncodeToBytes(response)
require.NoError(t, err)

var mresponse MultiVersionResponse
require.NoError(t, rlp.DecodeBytes(b, &mresponse))
Copy link
Member Author

Choose a reason for hiding this comment

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

I've also changed bytes to b to remove the type name / variable name collision.

@cammellos cammellos assigned Samyoul and unassigned cammellos and jakubgs Apr 23, 2020
Copy link
Member

@cammellos cammellos left a comment

Choose a reason for hiding this comment

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

Linter fails, but looks good!

@Samyoul
Copy link
Member Author

Samyoul commented Apr 23, 2020

File formatting lint fail. The worst of all lint fails 😭

@Samyoul
Copy link
Member Author

Samyoul commented Apr 23, 2020

@cammellos codeclimate is complaining also because there is duplication of code between Whisper and Waku. I know we are in the middle of refactoring everything, is it possible to ignore these warnings from codeclimate and address it in a separate PR?

@cammellos
Copy link
Member

@Samyoul yes, codeclimate is not required, so they can safely be ignored.
I tried goimports -w message_test.go but did not show any diff, maybe some difference in versions?

Copy link
Member

@jakubgs jakubgs left a comment

Choose a reason for hiding this comment

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

LGTM, but do we care that whisper/doc.go has the same issue?

@Samyoul
Copy link
Member Author

Samyoul commented Apr 23, 2020

do we care that whisper/doc.go has the same issue?

Yes, I care. @jakubgs would it make sense to update this in a new PR?

@jakubgs
Copy link
Member

jakubgs commented Apr 23, 2020

Don't see the point of a separate PR. Separate commit is just fine.

@Samyoul
Copy link
Member Author

Samyoul commented Apr 23, 2020

@cammellos , I'm going to restart the tests and see if that makes any kind of difference (it has before in race condition fails).

I'm working on the whisper/doc.go refactor, once done I'll commit and see if there's any change to the mood the linter is in 😆 .

Copy link
Member

@jakubgs jakubgs left a comment

Choose a reason for hiding this comment

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

Nice.

I also spotted a load of redundant type casting and fixed some of them
@Samyoul Samyoul merged commit cc8d577 into develop Apr 23, 2020
@delete-merged-branch delete-merged-branch bot deleted the refactor/waku.doc branch April 23, 2020 19:54
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.

None yet

4 participants