github.com/ethersphere/bee/v2@v2.2.0/pkg/settlement/interface.go (about)

     1  // Copyright 2020 The Swarm Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package settlement
     6  
     7  import (
     8  	"errors"
     9  	"math/big"
    10  
    11  	"github.com/ethersphere/bee/v2/pkg/swarm"
    12  )
    13  
    14  var (
    15  	ErrPeerNoSettlements = errors.New("no settlements for peer")
    16  )
    17  
    18  // Interface is the interface used by Accounting to trigger settlement
    19  type Interface interface {
    20  	// TotalSent returns the total amount sent to a peer
    21  	TotalSent(peer swarm.Address) (totalSent *big.Int, err error)
    22  	// TotalReceived returns the total amount received from a peer
    23  	TotalReceived(peer swarm.Address) (totalSent *big.Int, err error)
    24  	// SettlementsSent returns sent settlements for each individual known peer
    25  	SettlementsSent() (map[string]*big.Int, error)
    26  	// SettlementsReceived returns received settlements for each individual known peer
    27  	SettlementsReceived() (map[string]*big.Int, error)
    28  }
    29  
    30  type Accounting interface {
    31  	PeerDebt(peer swarm.Address) (*big.Int, error)
    32  	NotifyPaymentReceived(peer swarm.Address, amount *big.Int) error
    33  	NotifyPaymentSent(peer swarm.Address, amount *big.Int, receivedError error)
    34  	NotifyRefreshmentReceived(peer swarm.Address, amount *big.Int, timestamp int64) error
    35  	NotifyRefreshmentSent(peer swarm.Address, attemptedAmount, amount *big.Int, timestamp, interval int64, receivedError error)
    36  	Connect(peer swarm.Address, fullNode bool)
    37  	Disconnect(peer swarm.Address)
    38  }