]> Sergey Matveev's repositories - btrtrc.git/commit
Create default constructor for Client (#567)
authorYenForYang <YenForYang@users.noreply.github.com>
Tue, 14 Sep 2021 13:01:20 +0000 (08:01 -0500)
committerGitHub <noreply@github.com>
Tue, 14 Sep 2021 13:01:20 +0000 (23:01 +1000)
commit29638d9e5deca0b0bf6b31d69c4b6b448daa6d3c
treecd3d3c6d4f2e4280bcc231ddd423dea904543a6f
parente80b989f8e48b487fd88fe3a055d4feeee25da37
Create default constructor for Client (#567)

Allow for certain values to always be properly initialized on construction -- namely the maps for now. I'm currently working on a change that requires a baseline constructor; this change would make the use of `chansync.BroadcastCond` and `chansync.SetOnce` obsolete -- i.e. one can have channel members without worrying about proper initialization/destruction of a `chan struct{}`.

As for why `makeClient` returns a value instead of a pointer: returning a value gives us more options -- you can always take a pointer from a value later on cheaply, and have things moved to the heap if they weren't already. The same can't be said about getting a value back from a pointer. GC also could potentially have less work to do. Plus I personally find ownership to be an important concept (semi-borrowed from rust) -- use of values make ownership clear.
client.go
client_test.go
peerconn_test.go
pexconn_test.go