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

Commit

Permalink
swap: cast handshake message in run() function before using it in con…
Browse files Browse the repository at this point in the history
…structors.
  • Loading branch information
diegomasini authored and holisticode committed Aug 26, 2019
1 parent 00d5a41 commit 2ebe201
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions swap/protocol.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,19 +99,24 @@ func (s *Swap) verifyHandshake(msg interface{}) error {
func (s *Swap) run(p *p2p.Peer, rw p2p.MsgReadWriter) error {
protoPeer := protocols.NewPeer(p, rw, Spec)

answer, err := protoPeer.Handshake(context.TODO(), &HandshakeMsg{
handshake, err := protoPeer.Handshake(context.TODO(), &HandshakeMsg{
ContractAddress: s.owner.Contract,
}, s.verifyHandshake)
if err != nil {
return err
}

beneficiary, err := s.getContractOwner(context.TODO(), answer.(*HandshakeMsg).ContractAddress)
answer, ok := handshake.(*HandshakeMsg)
if !ok {
return ErrInvalidHandshakeMsg
}

beneficiary, err := s.getContractOwner(context.TODO(), answer.ContractAddress)
if err != nil {
return err
}

swapPeer := NewPeer(protoPeer, s, s.backend, beneficiary, answer.(*HandshakeMsg).ContractAddress)
swapPeer := NewPeer(protoPeer, s, s.backend, beneficiary, answer.ContractAddress)
s.addPeer(swapPeer)
defer s.removePeer(swapPeer)

Expand Down

0 comments on commit 2ebe201

Please sign in to comment.