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

swarm, swap: add addresses to logs #1806

Merged
merged 40 commits into from
Oct 14, 2019
Merged
Show file tree
Hide file tree
Changes from 30 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
ed9f561
swap: add selfAddress to swap logger context
mortelli Sep 20, 2019
7295408
swap: minor refactor in new function
mortelli Sep 20, 2019
f91233a
swap: update comments in newLogger function to comply with current co…
mortelli Sep 20, 2019
02ef574
Merge remote-tracking branch 'origin/master' into swap-logger-addresses
mortelli Sep 23, 2019
c10beae
swap: add peer ID to log entry in peer.sendCheque function
mortelli Sep 23, 2019
86bb6e7
swap: create separate logger variables for Swap and Peer structs
mortelli Sep 23, 2019
1632fdb
swap: reformat log context in peer calls
mortelli Sep 24, 2019
9d6eb39
swap: remove print, add missing error message in TestSwapLogToFile test
mortelli Sep 24, 2019
f1c3fc4
Merge remote-tracking branch 'origin/master' into swap-logger-addresses
mortelli Sep 24, 2019
b6086a1
swap: create different functions for swap and swap/peer loggers
mortelli Sep 24, 2019
c151daa
swap: remove auditLog variable
mortelli Sep 24, 2019
ecfec4c
swap: change logger functions to receive Swap struct as parameter
mortelli Sep 24, 2019
518ccf1
swap: add comments to logger vars and funcs
mortelli Sep 24, 2019
083cb4e
swap: update comments for logger vars and funcs
mortelli Sep 24, 2019
0746650
Merge remote-tracking branch 'origin/master' into swap-logger-addresses
mortelli Sep 25, 2019
0399110
Merge remote-tracking branch 'origin/master' into swap-logger-addresses
mortelli Sep 25, 2019
6a6c293
Merge remote-tracking branch 'origin/master' into swap-logger-addresses
mortelli Sep 25, 2019
e35dc65
Merge remote-tracking branch 'origin/master' into swap-logger-addresses
mortelli Sep 26, 2019
1100486
swap: refactor setLoggerHandler function
mortelli Sep 26, 2019
7be01a1
swap: minor comment expansion
mortelli Sep 26, 2019
272db7f
swarm, swap: add overlay address to swap params
mortelli Sep 26, 2019
f771aa2
Merge remote-tracking branch 'origin/master' into swap-logger-addresses
mortelli Sep 30, 2019
e424853
swap: add comment to new function
mortelli Sep 30, 2019
0d892a3
swap: expand swap log messages when retrying to deploy the chequebook…
mortelli Sep 30, 2019
a0238b7
Merge remote-tracking branch 'origin/master' into swap-logger-addresses
mortelli Oct 1, 2019
423ff3d
Merge remote-tracking branch 'origin/master' into swap-logger-addresses
mortelli Oct 2, 2019
f4e5156
Merge remote-tracking branch 'origin/master' into swap-logger-addresses
mortelli Oct 2, 2019
8c42e64
swap: minor change to swap cheque log
mortelli Oct 2, 2019
7989efc
Merge remote-tracking branch 'origin/master' into swap-logger-addresses
mortelli Oct 3, 2019
346edeb
Merge remote-tracking branch 'origin/master' into swap-logger-addresses
mortelli Oct 3, 2019
2d25f1f
Merge remote-tracking branch 'origin/master' into swap-logger-addresses
mortelli Oct 7, 2019
1f58276
swap: add t.Helper call to newDefaultParams function
mortelli Oct 7, 2019
edc9db0
swap: rename new function to newSwapInstance
mortelli Oct 7, 2019
481f5e0
swap: rename new function to newSwapInstance
mortelli Oct 7, 2019
d91d4a6
Merge remote-tracking branch 'origin/master' into swap-logger-addresses
mortelli Oct 8, 2019
43d8d45
Merge remote-tracking branch 'origin/master' into swap-logger-addresses
mortelli Oct 9, 2019
32af153
Merge remote-tracking branch 'origin/master' into swap-logger-addresses
mortelli Oct 11, 2019
48dc81b
swap: change the swap logger back to a global variable
mortelli Oct 11, 2019
c49d7cb
Merge remote-tracking branch 'origin/master' into swap-logger-addresses
mortelli Oct 11, 2019
6ebda39
Merge remote-tracking branch 'origin/master' into swap-logger-addresses
mortelli Oct 14, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions swap/peer.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"sync"

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/log"
"github.com/ethersphere/swarm/p2p/protocols"
)

Expand All @@ -40,6 +41,7 @@ type Peer struct {
lastReceivedCheque *Cheque
lastSentCheque *Cheque
balance int64
logger log.Logger // logger for swap related messages and audit trail with peer identifier
}

// NewPeer creates a new swap Peer instance
Expand All @@ -49,6 +51,7 @@ func NewPeer(p *protocols.Peer, s *Swap, beneficiary common.Address, contractAdd
swap: s,
beneficiary: beneficiary,
contractAddress: contractAddress,
logger: newPeerLogger(s, p.ID()),
mortelli marked this conversation as resolved.
Show resolved Hide resolved
}

if peer.lastReceivedCheque, err = s.loadLastReceivedCheque(p.ID()); err != nil {
Expand Down Expand Up @@ -108,7 +111,7 @@ func (p *Peer) updateBalance(amount int64) error {
if err := p.setBalance(newBalance); err != nil {
return err
}
auditLog.Debug("balance for peer after accounting", "peer", p.ID().String(), "balance", strconv.FormatInt(newBalance, 10))
p.logger.Debug("updated balance", "balance", strconv.FormatInt(newBalance, 10))
return nil
}

Expand Down Expand Up @@ -164,7 +167,7 @@ func (p *Peer) sendCheque() error {
return err
}

auditLog.Info("sending cheque", "honey", cheque.Honey, "cumulativePayout", cheque.ChequeParams.CumulativePayout, "beneficiary", cheque.Beneficiary, "contract", cheque.Contract)
p.logger.Info("sending cheque to peer", "honey", cheque.Honey, "cumulativePayout", cheque.ChequeParams.CumulativePayout, "beneficiary", cheque.Beneficiary, "contract", cheque.Contract)
return p.Send(context.Background(), &EmitChequeMsg{
Cheque: cheque,
})
Expand Down
97 changes: 56 additions & 41 deletions swap/swap.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package swap
import (
"context"
"crypto/ecdsa"
"encoding/hex"
"encoding/json"
"errors"
"fmt"
Expand All @@ -45,8 +46,6 @@ import (
// ErrInvalidChequeSignature indicates the signature on the cheque was invalid
var ErrInvalidChequeSignature = errors.New("invalid cheque signature")

var auditLog log.Logger // logger for Swap related messages and audit trail

// swapLogLevel indicates filter level of log messages
const swapLogLevel = 3

Expand All @@ -63,6 +62,7 @@ type Swap struct {
params *Params // economic and operational parameters
contract swap.Contract // reference to the smart contract
honeyPriceOracle HoneyOracle // oracle which resolves the price of honey (in Wei)
logger log.Logger // logger for swap related messages and audit trail
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we not keep the swapLogger package wide and only do the peerLogger per instance?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i think we can, but i'm not sure i see reason to.

could you please explain why this would be preferable? in general i try to avoid global variables and the like.

Copy link
Contributor

Choose a reason for hiding this comment

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

Because the logger is shared, and is not in any way a property of Swap. Then we also don't need to pass it around methods.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it's a logger specifically for swap, but yes, maybe it doesn't belong in the struct itself (although if the logpath does, one could argue for this).

it certainly doesn't need to be there.

i've changed it back to a global variable.

}

// Owner encapsulates information related to accessing the contract
Expand All @@ -72,39 +72,52 @@ type Owner struct {
publicKey *ecdsa.PublicKey // public key
}

// Params encapsulates param
// Params encapsulates economic and operational parameters
type Params struct {
OverlayAddr []byte // this node's base address
Copy link
Contributor

Choose a reason for hiding this comment

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

To be honest Params is poorly designed and was meant as an organizing thing for economic parametrization (thresholds, cashing strategy, amounts, etc.).

We have been refactoring the Swap constructor all the time recently, that is why instead of making a huuuuuge constructor with maaaany parameters (resulting in many changes), we started adding mixed parameters to this generic Params struct.

I would like to see a refactoring of this, but it does not need to be in this PR. Conceptually OverlayAddr does not belong to this struct, but LogPath neither does.

Copy link
Contributor Author

@mortelli mortelli Oct 10, 2019

Choose a reason for hiding this comment

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

i agree.

i never really understood this Params business—indeed, i only placed OverlayAddr here since it seemed to fit in well next to logpath as an "infrastructure" sort of variable for the Swap struct 🤷‍♂️

we can have them moved to the Swap struct directly if you prefer, i don't mind.

or: we can revisit this issue later down the road, when refactoring as you say

Copy link
Contributor Author

@mortelli mortelli Oct 14, 2019

Choose a reason for hiding this comment

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

created issue #1877 for this

LogPath string // optional audit log path
PaymentThreshold int64 // honey amount at which a payment is triggered
DisconnectThreshold int64 // honey amount at which a peer disconnects
}

// newLogger returns a new logger
func newLogger(logpath string) log.Logger {
swapLogger := log.New("swaplog", "*")
// newSwapLogger returns a new logger for standard swap logs
func newSwapLogger(logPath string, overlayAddr []byte) log.Logger {
swapLogger := log.New("swaplog", "*", "base", hex.EncodeToString(overlayAddr)[:16])
setLoggerHandler(logPath, swapLogger)
return swapLogger
}

// newPeerLogger returns a new logger for swap logs with peer info
func newPeerLogger(s *Swap, peerID enode.ID) log.Logger {
peerLogger := log.New("swaplog", "*", "base", hex.EncodeToString(s.params.OverlayAddr)[:16], "peer", peerID.String()[:16])
setLoggerHandler(s.params.LogPath, peerLogger)
return peerLogger
}

// setLoggerHandler will set the logger handle to write logs to the specified path
// or use the default swarm logger in case this isn't specified or an error occurs
func setLoggerHandler(logpath string, logger log.Logger) {
lh := log.Root().GetHandler()

if logpath == "" {
swapLogger.SetHandler(lh)
return swapLogger
logger.SetHandler(lh)
return
}

rfh, err := swapRotatingFileHandler(logpath)

if err != nil {
log.Warn("RotatingFileHandler was not initialized", "logdir", logpath, "err", err)
//sets a fallback logger, it will use the swarm logger.
swapLogger.SetHandler(lh)
return swapLogger
// use the default swarm logger as a fallback
logger.SetHandler(lh)
return
}

//Filters messages with the correct logLevel for swap
// filter messages with the correct log level for swap
rfh = log.LvlFilterHandler(log.Lvl(swapLogLevel), rfh)

//Dispatches the logs to the default swarm log and also the filtered swap file logger.
swapLogger.SetHandler(log.MultiHandler(lh, rfh))

return swapLogger
// dispatch the logs to the default swarm log and also the filtered swap logger
logger.SetHandler(log.MultiHandler(lh, rfh))
}

// swapRotatingFileHandler returns a RotatingFileHandler this will split the logs into multiple files.
Expand All @@ -118,14 +131,15 @@ func swapRotatingFileHandler(logdir string) (log.Handler, error) {
}

// new - swap constructor without integrity check
func new(stateStore state.Store, owner *Owner, backend contract.Backend, params *Params) *Swap {
func new(stateStore state.Store, owner *Owner, backend contract.Backend, params *Params, logger log.Logger) *Swap {
Copy link
Contributor

Choose a reason for hiding this comment

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

This is not from this PR, but we need to rename this function, it creates a conflict with the builtin new keyword of go if it would be used inside this package.

Call it newInstance or something else you prefer. You can also create a different PR for this if you prefer.

Copy link
Contributor Author

@mortelli mortelli Oct 7, 2019

Choose a reason for hiding this comment

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

pushed this change and added it to the PR description. thanks

return &Swap{
store: stateStore,
peers: make(map[enode.ID]*Peer),
backend: backend,
owner: owner,
params: params,
honeyPriceOracle: NewHoneyPriceOracle(),
logger: logger,
}
}

Expand All @@ -136,13 +150,13 @@ func new(stateStore state.Store, owner *Owner, backend contract.Backend, params
// - verifies that we have not connected SWAP before on a different blockchain backend;
// - starts the chequebook; creates the swap instance
func New(dbPath string, prvkey *ecdsa.PrivateKey, backendURL string, params *Params, chequebookAddressFlag common.Address, initialDepositAmountFlag uint64) (swap *Swap, err error) {
// auditLog for swap-logging purposes
auditLog = newLogger(params.LogPath)
// swap log for auditing purposes
swapLogger := newSwapLogger(params.LogPath, params.OverlayAddr)
// verify that backendURL is not empty
if backendURL == "" {
return nil, errors.New("no backend URL given")
}
auditLog.Info("connecting to SWAP API", "url", backendURL)
swapLogger.Info("connecting to SWAP API", "url", backendURL)
// initialize the balances store
var stateStore state.Store
if stateStore, err = state.NewDBStore(filepath.Join(dbPath, "swap.db")); err != nil {
Expand All @@ -162,10 +176,10 @@ func New(dbPath string, prvkey *ecdsa.PrivateKey, backendURL string, params *Par
return nil, fmt.Errorf("error retrieving chainID from backendURL: %v", err)
}
// verify that we have not used SWAP before on a different chainID
if err := checkChainID(chainID.Uint64(), stateStore); err != nil {
if err := checkChainID(chainID.Uint64(), stateStore, swapLogger); err != nil {
return nil, err
}
auditLog.Info("Using backend network ID", "ID", chainID.Uint64())
swapLogger.Info("Using backend network ID", "ID", chainID.Uint64())
// create the owner of SWAP
owner := createOwner(prvkey)
// create the swap instance
Expand All @@ -174,6 +188,7 @@ func New(dbPath string, prvkey *ecdsa.PrivateKey, backendURL string, params *Par
owner,
backend,
params,
swapLogger,
)
// start the chequebook
if swap.contract, err = swap.StartChequebook(chequebookAddressFlag, initialDepositAmountFlag); err != nil {
Expand All @@ -191,7 +206,7 @@ const (
)

// checkChainID verifies whether we have initialized SWAP before and ensures that we are on the same backendNetworkID if this is the case
func checkChainID(currentChainID uint64, s state.Store) (err error) {
func checkChainID(currentChainID uint64, s state.Store, logger log.Logger) (err error) {
var connectedBlockchain uint64
err = s.Get(connectedBlockchainKey, &connectedBlockchain)
// error reading from database
Expand All @@ -203,7 +218,7 @@ func checkChainID(currentChainID uint64, s state.Store) (err error) {
return fmt.Errorf("statestore previously used on different backend network. Used before on network: %d, Attempting to connect on network %d", connectedBlockchain, currentChainID)
}
if err == state.ErrNotFound {
auditLog.Info("First time connected to SWAP. Storing chain ID", "ID", currentChainID)
logger.Info("First time connected to SWAP. Storing chain ID", "ID", currentChainID)
return s.Put(connectedBlockchainKey, currentChainID)
}
return nil
Expand Down Expand Up @@ -262,7 +277,7 @@ func (s *Swap) Add(amount int64, peer *protocols.Peer) (err error) {
// It is the peer with a negative balance who sends a cheque, thus we check
// that the balance is *below* the threshold
if swapPeer.getBalance() <= -s.params.PaymentThreshold {
auditLog.Info("balance for peer went over the payment threshold, sending cheque", "peer", peer.ID().String(), "payment threshold", s.params.PaymentThreshold)
swapPeer.logger.Info("balance for peer went over the payment threshold, sending cheque", "payment threshold", s.params.PaymentThreshold)
return swapPeer.sendCheque()
}

Expand All @@ -289,13 +304,13 @@ func (s *Swap) handleEmitChequeMsg(ctx context.Context, p *Peer, msg *EmitCheque
defer p.lock.Unlock()

cheque := msg.Cheque
auditLog.Info("received cheque from peer", "peer", p.ID().String(), "honey", cheque.Honey)
p.logger.Info("received cheque from peer", "honey", cheque.Honey)
_, err := s.processAndVerifyCheque(cheque, p)
if err != nil {
return err
}

auditLog.Debug("received cheque processed and verified", "peer", p.ID().String())
p.logger.Debug("processed and verified received cheque", "beneficiary", cheque.Beneficiary, "cumulative payout", cheque.CumulativePayout)

// reset balance by amount
// as this is done by the creditor, receiving the cheque, the amount should be negative,
Expand Down Expand Up @@ -337,17 +352,17 @@ func cashCheque(s *Swap, otherSwap contract.Contract, opts *bind.TransactOpts, c
if err != nil {
// TODO: do something with the error
// and we actually need to log this error as we are in an async routine; nobody is handling this error for now
auditLog.Error("error cashing cheque", "err", err)
s.logger.Error("error cashing cheque", "err", err)
return
}

if result.Bounced {
auditLog.Warn("cheque bounced", "tx", receipt.TxHash)
s.logger.Warn("cheque bounced", "tx", receipt.TxHash)
return
// TODO: do something here
}

auditLog.Debug("cash tx mined", "receipt", receipt)
s.logger.Debug("cash tx mined", "receipt", receipt)
}

// processAndVerifyCheque verifies the cheque and compares it with the last received cheque
Expand All @@ -371,7 +386,7 @@ func (s *Swap) processAndVerifyCheque(cheque *Cheque, p *Peer) (uint64, error) {
}

if err := p.setLastReceivedCheque(cheque); err != nil {
auditLog.Error("error while saving last received cheque", "peer", p.ID().String(), "err", err.Error())
p.logger.Error("error while saving last received cheque", "err", err.Error())
// TODO: what do we do here? Related issue: https://github.com/ethersphere/swarm/issues/1515
}

Expand Down Expand Up @@ -611,27 +626,27 @@ func (s *Swap) StartChequebook(chequebookAddrFlag common.Address, initialDeposit
if err := s.saveChequebook(contract.ContractParams().ContractAddress); err != nil {
return nil, err
}
auditLog.Info("Deployed chequebook", "contract address", contract.ContractParams().ContractAddress.Hex(), "deposit", toDeposit, "owner", s.owner.address)
s.logger.Info("Deployed chequebook", "contract address", contract.ContractParams().ContractAddress.Hex(), "deposit", toDeposit, "owner", s.owner.address)
// first time connecting by deploying a new chequebook
return contract, nil
}
// first time connecting with a chequebookAddress passed in
if chequebookAddrFlag != (common.Address{}) {
return bindToContractAt(chequebookAddrFlag, s.backend)
return s.bindToContractAt(chequebookAddrFlag)
}
// reconnecting with contract read from statestore
return bindToContractAt(previouslyUsedChequebook, s.backend)
return s.bindToContractAt(previouslyUsedChequebook)
}

// BindToContractAt binds to an instance of an already existing chequebook contract at address
func bindToContractAt(address common.Address, backend contract.Backend) (contract.Contract, error) {
func (s *Swap) bindToContractAt(address common.Address) (contract.Contract, error) {
// validate whether address is a chequebook
if err := contract.ValidateCode(context.Background(), backend, address); err != nil {
if err := contract.ValidateCode(context.Background(), s.backend, address); err != nil {
return nil, fmt.Errorf("contract validation for %v failed: %v", address.Hex(), err)
}
auditLog.Info("bound to chequebook", "chequebookAddr", address)
s.logger.Info("bound to chequebook", "chequebookAddr", address)
// get the instance
return contract.InstanceAt(address, backend)
return contract.InstanceAt(address, s.backend)
}

// Deploy deploys the Swap contract
Expand All @@ -640,7 +655,7 @@ func (s *Swap) Deploy(ctx context.Context, initialDepositAmount uint64) (contrac
// initial topup value
opts.Value = big.NewInt(int64(initialDepositAmount))
opts.Context = ctx
auditLog.Info("Deploying new swap", "owner", opts.From.Hex(), "deposit", opts.Value)
s.logger.Info("Deploying new swap", "owner", opts.From.Hex(), "deposit", opts.Value)
return s.deployLoop(opts, defaultHarddepositTimeoutDuration)
}

Expand All @@ -652,11 +667,11 @@ func (s *Swap) deployLoop(opts *bind.TransactOpts, defaultHarddepositTimeoutDura
time.Sleep(deployDelay)
}
if instance, tx, err = contract.Deploy(opts, s.backend, s.owner.address, defaultHarddepositTimeoutDuration); err != nil {
auditLog.Warn("can't send chequebook deploy tx", "try", try, "error", err)
s.logger.Warn("can't send chequebook deploy tx, retrying...", "try", try, "error", err)
continue
}
if _, err := bind.WaitDeployed(opts.Context, s.backend, tx); err != nil {
auditLog.Warn("chequebook deploy error", "try", try, "error", err)
s.logger.Warn("chequebook deploy error, retrying...", "try", try, "error", err)
continue
}
return instance, nil
Expand Down
23 changes: 16 additions & 7 deletions swap/swap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -621,7 +621,7 @@ func TestNewSwapFailure(t *testing.T) {
t.Error(err)
}

params := newDefaultParams()
params := newDefaultParams(t)
chequebookAddress := testChequeContract
InitialDeposit := uint64(1)

Expand Down Expand Up @@ -1103,8 +1103,14 @@ func testCashCheque(s *Swap, otherSwap cswap.Contract, opts *bind.TransactOpts,
}

// newDefaultParams creates a set of default params for tests
func newDefaultParams() *Params {
func newDefaultParams(t *testing.T) *Params {
holisticode marked this conversation as resolved.
Show resolved Hide resolved
baseKey := make([]byte, 32)
_, err := rand.Read(baseKey)
if err != nil {
t.Fatal(err)
}
return &Params{
OverlayAddr: baseKey,
LogPath: "",
PaymentThreshold: int64(DefaultPaymentThreshold),
DisconnectThreshold: int64(DefaultDisconnectThreshold),
Expand All @@ -1124,15 +1130,15 @@ func newBaseTestSwapWithParams(t *testing.T, key *ecdsa.PrivateKey, params *Para
}
log.Debug("creating simulated backend")
owner := createOwner(key)
auditLog = newLogger(params.LogPath)
swap := new(stateStore, owner, testBackend, params)
swapLogger := newSwapLogger(params.LogPath, params.OverlayAddr)
swap := new(stateStore, owner, testBackend, params, swapLogger)
return swap, dir
}

// create a test swap account with a backend
// creates a stateStore for persistence and a Swap account
func newBaseTestSwap(t *testing.T, key *ecdsa.PrivateKey) (*Swap, string) {
params := newDefaultParams()
params := newDefaultParams(t)
return newBaseTestSwapWithParams(t, key, params)
}

Expand Down Expand Up @@ -1686,7 +1692,7 @@ func TestSwapLogToFile(t *testing.T) {
defer os.RemoveAll(logDirDebitor)

// set the log dir to the params
params := newDefaultParams()
params := newDefaultParams(t)
params.LogPath = logDirDebitor

// create both test swap accounts
Expand Down Expand Up @@ -1743,9 +1749,12 @@ func TestSwapLogToFile(t *testing.T) {
}

files, err := ioutil.ReadDir(logDirDebitor)
if err != nil || len(files) == 0 {
if err != nil {
t.Fatal(err)
}
if len(files) == 0 {
t.Fatalf("expected at least 1 file in the log directory, found none")
}

logFile := path.Join(logDirDebitor, files[0].Name())

Expand Down
1 change: 1 addition & 0 deletions swarm.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ func NewSwarm(config *api.Config, mockStore *mock.NodeStore) (self *Swarm, err e
return nil, fmt.Errorf("swap can only be enabled under BZZ Network ID %d, found Network ID %d instead", swap.AllowedNetworkID, self.config.NetworkID)
}
swapParams := &swap.Params{
OverlayAddr: common.FromHex(self.config.BzzKey),
LogPath: self.config.SwapLogPath,
DisconnectThreshold: int64(self.config.SwapDisconnectThreshold),
PaymentThreshold: int64(self.config.SwapPaymentThreshold),
Expand Down