Skip to content
This repository was archived by the owner on Aug 2, 2021. It is now read-only.

swap: cheque functions refactor#1678

Merged
mortelli merged 3 commits intoincentivesfrom
incentives_cheque-functions-refactor
Aug 16, 2019
Merged

swap: cheque functions refactor#1678
mortelli merged 3 commits intoincentivesfrom
incentives_cheque-functions-refactor

Conversation

@mortelli
Copy link
Copy Markdown
Contributor

This PR addresses the comments originally posted by @zelig in PR #1554:

this lookup is performed in createCheque too. Unnecessary, just pass the swapPeer to createCheque, not the id.

and

the argument should be swapPeer not id, see above

Also, for swap.go, I am renaming ID-typed variables called peerID to peer for nomenclature consistency.

swap/swap.go Outdated
return s.sendCheque(peer.ID())
swapPeer, ok := s.getPeer(peer.ID())
if !ok {
return fmt.Errorf("error while getting peer: %s", peer)
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.

This should actually be "no peer found", as we don't print any error in the text

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.

you mean something like return fmt.Errorf("peer %s not found", peer)?

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.

yes

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.

fixed, thanks

swap/swap.go Outdated
}
cheque, err := s.createCheque(peer)
func (s *Swap) sendCheque(swapPeer *Peer) error {
peer := swapPeer.Peer.ID()
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.

You should be able to just call swapPeer.ID() (Peer is embedded)

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.

fixed, thanks

swap/swap.go Outdated
if !ok {
return nil, fmt.Errorf("error while getting peer: %s", peer)
}
peer := swapPeer.Peer.ID()
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.

same here

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.

done

Copy link
Copy Markdown
Contributor

@holisticode holisticode left a comment

Choose a reason for hiding this comment

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

Just address the minor things commented and its good to go

@mortelli mortelli merged commit 85c1074 into incentives Aug 16, 2019
holisticode pushed a commit that referenced this pull request Aug 20, 2019
* swap: refactor createCheque and sendCheque functions to receive *Peer variables instead of IDs

* swap: rename peerID variables to peer for consistency in swap.go

* swap: change error message when failing to get peer in Add function, simplify swapPeer.Peer.ID() calls
holisticode pushed a commit that referenced this pull request Aug 26, 2019
* swap: refactor createCheque and sendCheque functions to receive *Peer variables instead of IDs

* swap: rename peerID variables to peer for consistency in swap.go

* swap: change error message when failing to get peer in Add function, simplify swapPeer.Peer.ID() calls
holisticode pushed a commit that referenced this pull request Aug 27, 2019
* swap: refactor createCheque and sendCheque functions to receive *Peer variables instead of IDs

* swap: rename peerID variables to peer for consistency in swap.go

* swap: change error message when failing to get peer in Add function, simplify swapPeer.Peer.ID() calls
@holisticode holisticode deleted the incentives_cheque-functions-refactor branch September 2, 2019 15:22
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants