func (s *Service) SetSwap(swap Swap) {
	s.swap = swap
}
SetSwap sets the swap to notify.
package swapprotocol
import (
	"context"
	"encoding/json"
	"errors"
	"fmt"
	"math/big"
	"time"
	"github.com/ethereum/go-ethereum/common"
	"github.com/ethsana/sana/pkg/logging"
	"github.com/ethsana/sana/pkg/p2p"
	"github.com/ethsana/sana/pkg/p2p/protobuf"
	"github.com/ethsana/sana/pkg/settlement/swap/chequebook"
	swap "github.com/ethsana/sana/pkg/settlement/swap/headers"
	"github.com/ethsana/sana/pkg/settlement/swap/priceoracle"
	"github.com/ethsana/sana/pkg/settlement/swap/swapprotocol/pb"
	"github.com/ethsana/sana/pkg/swarm"
)
const (
	protocolName    = "swap"
	protocolVersion = "1.0.0"
	streamName      = "swap"  
)
var (
	ErrNegotiateRate      = errors.New("exchange rates mismatch")
	ErrNegotiateDeduction = errors.New("deduction values mismatch")
	ErrHaveDeduction      = errors.New("received deduction not zero")
)
type SendChequeFunc chequebook.SendChequeFunc
type IssueFunc func(ctx context.Context, beneficiary common.Address, amount *big.Int, sendChequeFunc chequebook.SendChequeFunc) (*big.Int, error)
type Interface interface {
	EmitCheque(ctx context.Context, peer swarm.Address, beneficiary common.Address, amount *big.Int, issue IssueFunc) (balance *big.Int, err error)
}
type Swap interface {
	ReceiveCheque(ctx context.Context, peer swarm.Address, cheque *chequebook.SignedCheque, exchangeRate, deduction *big.Int) error
	Handshake(peer swarm.Address, beneficiary common.Address) error
	GetDeductionForPeer(peer swarm.Address) (bool, error)
	GetDeductionByPeer(peer swarm.Address) (bool, error)
	AddDeductionByPeer(peer swarm.Address) error
}
type Service struct {
	streamer    p2p.Streamer
	logger      logging.Logger
	swap        Swap
	priceOracle priceoracle.Service
	beneficiary common.Address
}
func New(streamer p2p.Streamer, logger logging.Logger, beneficiary common.Address, priceOracle priceoracle.Service) *Service {
	return &Service{
		streamer:    streamer,
		logger:      logger,
		beneficiary: beneficiary,
		priceOracle: priceOracle,
	}
}