diff --git a/contracts/swap/swap.go b/contracts/swap/swap.go index e4abdbd33c..0d4589fc37 100644 --- a/contracts/swap/swap.go +++ b/contracts/swap/swap.go @@ -43,7 +43,6 @@ var ( type Backend interface { bind.ContractBackend TransactionReceipt(ctx context.Context, txHash common.Hash) (*types.Receipt, error) - //TODO: needed? BalanceAt(ctx context.Context, address common.Address, blockNum *big.Int) (*big.Int, error) } // Deploy deploys an instance of the underlying contract and returns its `Contract` abstraction @@ -91,7 +90,6 @@ type Params struct { // ValidateCode checks that the on-chain code at address matches the expected swap // contract code. -// TODO: have this as a package level function and pass the SimpleSwapBin as argument func ValidateCode(ctx context.Context, b bind.ContractBackend, address common.Address) error { codeReadFromAddress, err := b.CodeAt(ctx, address, nil) if err != nil { diff --git a/swap/defaults.go b/swap/defaults.go index 2ed14f1bf3..1647b7b283 100644 --- a/swap/defaults.go +++ b/swap/defaults.go @@ -25,13 +25,11 @@ const ( DefaultPaymentThreshold = 1000000 DefaultDisconnectThreshold = 1500000 // DefaultInitialDepositAmount is the default amount to send to the contract when initially deploying - // TODO: deliberate value for now; needs experimentation + // NOTE: deliberate value for now; needs experimentation DefaultInitialDepositAmount = 0 - - deployRetries = 5 + deployRetries = 5 // delay between retries deployDelay = 1 * time.Second - // Default timeout until cashing in cheques is possible - TODO: deliberate value, experiment // Should be non-zero once we implement waivers defaultCashInDelay = uint64(0) // This is the amount of time in seconds which an issuer has to wait to decrease the harddeposit of a beneficiary. diff --git a/swap/oracle.go b/swap/oracle.go index 38b5250663..d60e35cb9f 100644 --- a/swap/oracle.go +++ b/swap/oracle.go @@ -22,7 +22,6 @@ type PriceOracle interface { } // NewPriceOracle returns the actual oracle to be used for discovering the price -// TODO: Add a config flag so that this can be configured via command line // For now it will return a default one func NewPriceOracle() PriceOracle { return &FixedPriceOracle{ diff --git a/swap/peer.go b/swap/peer.go index d51c3fbe52..1d847e8145 100644 --- a/swap/peer.go +++ b/swap/peer.go @@ -65,8 +65,6 @@ func (sp *Peer) handleMsg(ctx context.Context, msg interface{}) error { // handleEmitChequeMsg should be handled by the creditor when it receives // a cheque from a debitor -// TODO: validate the contract address in the cheque to match the address given at handshake -// TODO: this should not be blocking func (sp *Peer) handleEmitChequeMsg(ctx context.Context, msg *EmitChequeMsg) error { cheque := msg.Cheque log.Info("received cheque from peer", "peer", sp.ID().String()) @@ -108,14 +106,12 @@ func (sp *Peer) handleEmitChequeMsg(ctx context.Context, msg *EmitChequeMsg) err receipt, err = otherSwap.CashChequeBeneficiary(opts, sp.backend, sp.swap.owner.Contract, big.NewInt(int64(actualAmount))) if err != nil { - //TODO: do something with the error + // 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 log.Error("error cashing cheque", "err", err) return } log.Debug("cash tx mined", "receipt", receipt) - //TODO: after the cashCheque is done, we have to watch the blockchain for x amount (25) blocks for reorgs - //TODO: make sure we make a case where we listen to the possibility of the peer shutting down. log.Info("Cheque successfully submitted and cashed") }() return err @@ -143,7 +139,7 @@ func (sp *Peer) processAndVerifyCheque(cheque *Cheque) (uint64, error) { if err := sp.saveLastReceivedCheque(cheque); err != nil { log.Error("error while saving last received cheque", "peer", sp.ID().String(), "err", err.Error()) - // TODO: what do we do here? + // TODO: what do we do here? Related issue: https://github.com/ethersphere/swarm/issues/1515 } return actualAmount, nil @@ -190,7 +186,6 @@ func verifyChequeAgainstLast(cheque *Cheque, lastCheque *Cheque, expectedAmount actualAmount -= lastCheque.Amount } - // TODO: maybe allow some range around expectedAmount? if expectedAmount != actualAmount { return 0, fmt.Errorf("unexpected amount for honey, expected %d was %d", expectedAmount, actualAmount) } diff --git a/swap/protocol_test.go b/swap/protocol_test.go index f34ec6ee63..8ef738c931 100644 --- a/swap/protocol_test.go +++ b/swap/protocol_test.go @@ -216,7 +216,6 @@ func TestEmitCheque(t *testing.T) { t.Fatalf("Expected exactly one cheque at creditor, but there are %d:", len(creditorSwap.cheques)) } */ - } // TestTriggerPaymentThreshold is to test that the whole cheque protocol is triggered diff --git a/swap/swap.go b/swap/swap.go index 3882681c37..65bb25a8cc 100644 --- a/swap/swap.go +++ b/swap/swap.go @@ -220,7 +220,6 @@ func (s *Swap) sendCheque(peer enode.ID) error { s.cheques[peer] = cheque err = s.store.Put(sentChequeKey(peer), &cheque) - // TODO: error handling might be quite more complex if err != nil { return fmt.Errorf("error while storing the last cheque: %s", err.Error()) } @@ -230,7 +229,6 @@ func (s *Swap) sendCheque(peer enode.ID) error { } // reset balance; - // TODO: if sending fails it should actually be roll backed... err = s.resetBalance(peer, int64(cheque.Amount)) if err != nil { return err @@ -394,7 +392,6 @@ func (s *Swap) GetParams() *swap.Params { // Deploy deploys a new swap contract func (s *Swap) Deploy(ctx context.Context, backend swap.Backend, path string) error { - // TODO: What to do if the contract is already deployed? return s.deploy(ctx, backend, path) } diff --git a/swap/types.go b/swap/types.go index 64a1bc3f07..199ea1177b 100644 --- a/swap/types.go +++ b/swap/types.go @@ -20,9 +20,6 @@ import ( "github.com/ethereum/go-ethereum/common" ) -// TODO: add handshake protocol where we exchange last cheque (this is useful if one node disconnects) -// FIXME: Check the contract bytecode of the counterparty - // ChequeParams encapsulate all cheque parameters type ChequeParams struct { Contract common.Address // address of chequebook, needed to avoid cross-contract submission @@ -34,7 +31,6 @@ type ChequeParams struct { } // Cheque encapsulates the parameters and the signature -// TODO: There should be a request cheque struct that only gives the Serial type Cheque struct { ChequeParams Signature []byte // signature Sign(Keccak256(contract, beneficiary, amount), prvKey)