Commit 0d835e5a authored by Esad's avatar Esad Committed by GitHub

fix: deep source (#2281)

parent ea882b52
......@@ -49,7 +49,7 @@ type Service struct {
paymentThresholdObserver PaymentThresholdObserver
}
func New(streamer p2p.Streamer, logger logging.Logger, paymentThreshold *big.Int, minThreshold *big.Int) *Service {
func New(streamer p2p.Streamer, logger logging.Logger, paymentThreshold, minThreshold *big.Int) *Service {
return &Service{
streamer: streamer,
logger: logger,
......
......@@ -516,7 +516,7 @@ func newPeerSkipList() *peerSkipList {
}
}
func (l *peerSkipList) Add(peer swarm.Address, chunk swarm.Address, expire time.Duration) {
func (l *peerSkipList) Add(peer, chunk swarm.Address, expire time.Duration) {
l.Lock()
defer l.Unlock()
......
......@@ -239,7 +239,7 @@ func (s *Service) handler(ctx context.Context, p p2p.Peer, stream p2p.Stream) (e
}
// Pay initiates a payment to the given peer
func (s *Service) Pay(ctx context.Context, peer swarm.Address, amount *big.Int, checkAllowance *big.Int) (*big.Int, int64, error) {
func (s *Service) Pay(ctx context.Context, peer swarm.Address, amount, checkAllowance *big.Int) (*big.Int, int64, error) {
ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
defer cancel()
......
......@@ -41,7 +41,7 @@ type notifyPaymentSentCall struct {
err error
}
func newTestObserver(debtAmounts map[string]*big.Int, shadowBalanceAmounts map[string]*big.Int) *testObserver {
func newTestObserver(debtAmounts, shadowBalanceAmounts map[string]*big.Int) *testObserver {
return &testObserver{
receivedCalled: make(chan notifyPaymentReceivedCall, 1),
sentCalled: make(chan notifyPaymentSentCall, 1),
......
......@@ -41,7 +41,7 @@ var (
// ChequeStore handles the verification and storage of received cheques
type ChequeStore interface {
// ReceiveCheque verifies and stores a cheque. It returns the total amount earned.
ReceiveCheque(ctx context.Context, cheque *SignedCheque, exchangeRate *big.Int, deduction *big.Int) (*big.Int, error)
ReceiveCheque(ctx context.Context, cheque *SignedCheque, exchangeRate, deduction *big.Int) (*big.Int, error)
// LastCheque returns the last cheque we received from a specific chequebook.
LastCheque(chequebook common.Address) (*SignedCheque, error)
// LastCheques returns the last received cheques from every known chequebook.
......@@ -98,7 +98,7 @@ func (s *chequeStore) LastCheque(chequebook common.Address) (*SignedCheque, erro
}
// ReceiveCheque verifies and stores a cheque. It returns the totam amount earned.
func (s *chequeStore) ReceiveCheque(ctx context.Context, cheque *SignedCheque, exchangeRate *big.Int, deduction *big.Int) (*big.Int, error) {
func (s *chequeStore) ReceiveCheque(ctx context.Context, cheque *SignedCheque, exchangeRate, deduction *big.Int) (*big.Int, error) {
// verify we are the beneficiary
if cheque.Beneficiary != s.beneficiary {
return nil, ErrWrongBeneficiary
......
......@@ -141,7 +141,7 @@ LOOP:
return nil
}
func (c *factory) verifyChequebookAgainstFactory(ctx context.Context, factory common.Address, chequebook common.Address) (bool, error) {
func (c *factory) verifyChequebookAgainstFactory(ctx context.Context, factory, chequebook common.Address) (bool, error) {
callData, err := factoryABI.Pack("deployedContracts", chequebook)
if err != nil {
return false, err
......
......@@ -46,7 +46,7 @@ func NewChequeStore(opts ...Option) chequebook.ChequeStore {
return mock
}
func (s *Service) ReceiveCheque(ctx context.Context, cheque *chequebook.SignedCheque, exchangeRate *big.Int, deduction *big.Int) (*big.Int, error) {
func (s *Service) ReceiveCheque(ctx context.Context, cheque *chequebook.SignedCheque, exchangeRate, deduction *big.Int) (*big.Int, error) {
return s.receiveCheque(ctx, cheque, exchangeRate, deduction)
}
......
......@@ -33,7 +33,7 @@ func MakeSettlementHeaders(exchangeRate, deduction *big.Int) p2p.Headers {
}
}
func ParseSettlementResponseHeaders(receivedHeaders p2p.Headers) (exchange *big.Int, deduction *big.Int, err error) {
func ParseSettlementResponseHeaders(receivedHeaders p2p.Headers) (exchange, deduction *big.Int, err error) {
exchangeRate, err := ParseExchangeHeader(receivedHeaders)
if err != nil {
......
......@@ -247,7 +247,7 @@ func (s *Service) CashoutStatus(ctx context.Context, peer swarm.Address) (*chequ
return nil, nil
}
func (s *Service) ReceiveCheque(ctx context.Context, peer swarm.Address, cheque *chequebook.SignedCheque, exchangeRate *big.Int, deduction *big.Int) (err error) {
func (s *Service) ReceiveCheque(ctx context.Context, peer swarm.Address, cheque *chequebook.SignedCheque, exchangeRate, deduction *big.Int) (err error) {
defer func() {
if err == nil {
s.deductionForPeers[peer.String()] = struct{}{}
......
......@@ -16,7 +16,7 @@ type Service struct {
deduct *big.Int
}
func New(rate *big.Int, deduct *big.Int) Service {
func New(rate, deduct *big.Int) Service {
return Service{
rate: rate,
deduct: deduct,
......@@ -30,7 +30,7 @@ func (s Service) GetPrice(ctx context.Context) (*big.Int, *big.Int, error) {
return s.rate, s.deduct, nil
}
func (s Service) CurrentRates() (exchangeRate *big.Int, deduction *big.Int, err error) {
func (s Service) CurrentRates() (exchangeRate, deduction *big.Int, err error) {
return s.rate, s.deduct, nil
}
......@@ -42,7 +42,7 @@ func DiscoverPriceOracleAddress(chainID int64) (priceOracleAddress common.Addres
return common.Address{}, false
}
func (s Service) SetValues(rate *big.Int, deduct *big.Int) {
func (s Service) SetValues(rate, deduct *big.Int) {
s.rate = rate
s.deduct = deduct
}
......@@ -131,7 +131,7 @@ func (s *service) GetPrice(ctx context.Context) (*big.Int, *big.Int, error) {
return exchangeRate, deduction, nil
}
func (s *service) CurrentRates() (exchangeRate *big.Int, deduction *big.Int, err error) {
func (s *service) CurrentRates() (exchangeRate, deduction *big.Int, err error) {
if s.exchangeRate.Cmp(big.NewInt(0)) == 0 {
return nil, nil, errors.New("exchange rate not yet available")
}
......
......@@ -75,7 +75,7 @@ func New(proto swapprotocol.Interface, logger logging.Logger, store storage.Stat
}
// ReceiveCheque is called by the swap protocol if a cheque is received.
func (s *Service) ReceiveCheque(ctx context.Context, peer swarm.Address, cheque *chequebook.SignedCheque, exchangeRate *big.Int, deduction *big.Int) (err error) {
func (s *Service) ReceiveCheque(ctx context.Context, peer swarm.Address, cheque *chequebook.SignedCheque, exchangeRate, deduction *big.Int) (err error) {
// check this is the same chequebook for this peer as previously
expectedChequebook, known, err := s.addressbook.Chequebook(peer)
if err != nil {
......
......@@ -50,7 +50,7 @@ type Interface interface {
// Swap is the interface the settlement layer should implement to receive cheques.
type Swap interface {
// ReceiveCheque is called by the swap protocol if a cheque is received.
ReceiveCheque(ctx context.Context, peer swarm.Address, cheque *chequebook.SignedCheque, exchangeRate *big.Int, deduction *big.Int) error
ReceiveCheque(ctx context.Context, peer swarm.Address, cheque *chequebook.SignedCheque, exchangeRate, deduction *big.Int) error
// Handshake is called by the swap protocol when a handshake is received.
Handshake(peer swarm.Address, beneficiary common.Address) error
GetDeductionForPeer(peer swarm.Address) (bool, error)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment