rlp, trie, contracts, compression, consensus: improve comments (#14580)
This commit is contained in:
committed by
Felix Lange
parent
e3dfd55820
commit
061889d4ea
@ -49,7 +49,7 @@ import (
|
||||
// TODO(zelig): watch peer solvency and notify of bouncing cheques
|
||||
// TODO(zelig): enable paying with cheque by signing off
|
||||
|
||||
// Some functionality require interacting with the blockchain:
|
||||
// Some functionality requires interacting with the blockchain:
|
||||
// * setting current balance on peer's chequebook
|
||||
// * sending the transaction to cash the cheque
|
||||
// * depositing ether to the chequebook
|
||||
@ -100,13 +100,13 @@ type Chequebook struct {
|
||||
// persisted fields
|
||||
balance *big.Int // not synced with blockchain
|
||||
contractAddr common.Address // contract address
|
||||
sent map[common.Address]*big.Int //tallies for beneficiarys
|
||||
sent map[common.Address]*big.Int //tallies for beneficiaries
|
||||
|
||||
txhash string // tx hash of last deposit tx
|
||||
threshold *big.Int // threshold that triggers autodeposit if not nil
|
||||
buffer *big.Int // buffer to keep on top of balance for fork protection
|
||||
|
||||
log log.Logger // contextual logger with the contrac address embedded
|
||||
log log.Logger // contextual logger with the contract address embedded
|
||||
}
|
||||
|
||||
func (self *Chequebook) String() string {
|
||||
@ -442,7 +442,7 @@ type Inbox struct {
|
||||
maxUncashed *big.Int // threshold that triggers autocashing
|
||||
cashed *big.Int // cumulative amount cashed
|
||||
cheque *Cheque // last cheque, nil if none yet received
|
||||
log log.Logger // contextual logger with the contrac address embedded
|
||||
log log.Logger // contextual logger with the contract address embedded
|
||||
}
|
||||
|
||||
// NewInbox creates an Inbox. An Inboxes is not persisted, the cumulative sum is updated
|
||||
@ -509,9 +509,8 @@ func (self *Inbox) AutoCash(cashInterval time.Duration, maxUncashed *big.Int) {
|
||||
self.autoCash(cashInterval)
|
||||
}
|
||||
|
||||
// autoCash starts a loop that periodically clears the last check
|
||||
// autoCash starts a loop that periodically clears the last cheque
|
||||
// if the peer is trusted. Clearing period could be 24h or a week.
|
||||
//
|
||||
// The caller must hold self.lock.
|
||||
func (self *Inbox) autoCash(cashInterval time.Duration) {
|
||||
if self.quit != nil {
|
||||
@ -557,10 +556,10 @@ func (self *Inbox) Receive(promise swap.Promise) (*big.Int, error) {
|
||||
|
||||
var sum *big.Int
|
||||
if self.cheque == nil {
|
||||
// the sum is checked against the blockchain once a check is received
|
||||
// the sum is checked against the blockchain once a cheque is received
|
||||
tally, err := self.session.Sent(self.beneficiary)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("inbox: error calling backend to set amount: %v", err)
|
||||
return nil, fmt.Errorf("inbox: error calling backend to set amount: %v", err)
|
||||
}
|
||||
sum = tally
|
||||
} else {
|
||||
|
@ -414,21 +414,10 @@ func TestCash(t *testing.T) {
|
||||
t.Fatalf("expected no error, got %v", err)
|
||||
}
|
||||
backend.Commit()
|
||||
// expBalance := big.NewInt(2)
|
||||
// gotBalance := backend.BalanceAt(addr1)
|
||||
// if gotBalance.Cmp(expBalance) != 0 {
|
||||
// t.Fatalf("expected beneficiary balance %v, got %v", expBalance, gotBalance)
|
||||
// }
|
||||
// after 3x interval time and 2 cheques received, exactly one cashing tx is sent
|
||||
time.Sleep(4 * interval)
|
||||
backend.Commit()
|
||||
|
||||
// expBalance = big.NewInt(4)
|
||||
// gotBalance = backend.BalanceAt(addr1)
|
||||
// if gotBalance.Cmp(expBalance) != 0 {
|
||||
// t.Fatalf("expected beneficiary balance %v, got %v", expBalance, gotBalance)
|
||||
// }
|
||||
|
||||
// after stopping autocash no more tx are sent
|
||||
ch2, err := chbook.Issue(addr1, amount)
|
||||
if err != nil {
|
||||
@ -441,11 +430,6 @@ func TestCash(t *testing.T) {
|
||||
}
|
||||
time.Sleep(2 * interval)
|
||||
backend.Commit()
|
||||
// expBalance = big.NewInt(4)
|
||||
// gotBalance = backend.BalanceAt(addr1)
|
||||
// if gotBalance.Cmp(expBalance) != 0 {
|
||||
// t.Fatalf("expected beneficiary balance %v, got %v", expBalance, gotBalance)
|
||||
// }
|
||||
|
||||
// autocash below 1
|
||||
chbook.balance = big.NewInt(2)
|
||||
@ -456,11 +440,6 @@ func TestCash(t *testing.T) {
|
||||
t.Fatalf("expected no error, got %v", err)
|
||||
}
|
||||
backend.Commit()
|
||||
// expBalance = big.NewInt(4)
|
||||
// gotBalance = backend.BalanceAt(addr1)
|
||||
// if gotBalance.Cmp(expBalance) != 0 {
|
||||
// t.Fatalf("expected beneficiary balance %v, got %v", expBalance, gotBalance)
|
||||
// }
|
||||
|
||||
ch4, err := chbook.Issue(addr1, amount)
|
||||
if err != nil {
|
||||
@ -479,13 +458,6 @@ func TestCash(t *testing.T) {
|
||||
}
|
||||
backend.Commit()
|
||||
|
||||
// 2 checks of amount 1 received, exactly 1 tx is sent
|
||||
// expBalance = big.NewInt(6)
|
||||
// gotBalance = backend.BalanceAt(addr1)
|
||||
// if gotBalance.Cmp(expBalance) != 0 {
|
||||
// t.Fatalf("expected beneficiary balance %v, got %v", expBalance, gotBalance)
|
||||
// }
|
||||
|
||||
// autochash on receipt when maxUncashed is 0
|
||||
chbook.balance = new(big.Int).Set(common.Big2)
|
||||
chbox.AutoCash(0, common.Big0)
|
||||
@ -495,11 +467,6 @@ func TestCash(t *testing.T) {
|
||||
t.Fatalf("expected no error, got %v", err)
|
||||
}
|
||||
backend.Commit()
|
||||
// expBalance = big.NewInt(5)
|
||||
// gotBalance = backend.BalanceAt(addr1)
|
||||
// if gotBalance.Cmp(expBalance) != 0 {
|
||||
// t.Fatalf("expected beneficiary balance %v, got %v", expBalance, gotBalance)
|
||||
// }
|
||||
|
||||
ch6, err := chbook.Issue(addr1, amount)
|
||||
if err != nil {
|
||||
@ -511,21 +478,11 @@ func TestCash(t *testing.T) {
|
||||
t.Fatalf("expected no error, got %v", err)
|
||||
}
|
||||
backend.Commit()
|
||||
// expBalance = big.NewInt(4)
|
||||
// gotBalance = backend.BalanceAt(addr1)
|
||||
// if gotBalance.Cmp(expBalance) != 0 {
|
||||
// t.Fatalf("expected beneficiary balance %v, got %v", expBalance, gotBalance)
|
||||
// }
|
||||
|
||||
_, err = chbox.Receive(ch6)
|
||||
if err != nil {
|
||||
t.Fatalf("expected no error, got %v", err)
|
||||
}
|
||||
backend.Commit()
|
||||
// expBalance = big.NewInt(6)
|
||||
// gotBalance = backend.BalanceAt(addr1)
|
||||
// if gotBalance.Cmp(expBalance) != 0 {
|
||||
// t.Fatalf("expected beneficiary balance %v, got %v", expBalance, gotBalance)
|
||||
// }
|
||||
|
||||
}
|
||||
|
@ -3,12 +3,12 @@
|
||||
## Usage
|
||||
|
||||
Full documentation for the Ethereum Name Service [can be found as EIP 137](https://github.com/ethereum/EIPs/issues/137).
|
||||
This package offers a simple binding that streamlines the registration arbitrary utf8 domain names to swarm content hashes.
|
||||
This package offers a simple binding that streamlines the registration of arbitrary UTF8 domain names to swarm content hashes.
|
||||
|
||||
## Development
|
||||
|
||||
The SOL file in contract subdirectory implements the ENS root registry, a simple
|
||||
first-in-first-served registrar for the root namespace, and a simple resolver contract;
|
||||
first-in, first-served registrar for the root namespace, and a simple resolver contract;
|
||||
they're used in tests, and can be used to deploy these contracts for your own purposes.
|
||||
|
||||
The solidity source code can be found at [github.com/arachnid/ens/](https://github.com/arachnid/ens/).
|
||||
|
@ -52,7 +52,7 @@ func NewENS(transactOpts *bind.TransactOpts, contractAddr common.Address, contra
|
||||
}, nil
|
||||
}
|
||||
|
||||
// DeployENS deploys an instance of the ENS nameservice, with a 'first in first served' root registrar.
|
||||
// DeployENS deploys an instance of the ENS nameservice, with a 'first-in, first-served' root registrar.
|
||||
func DeployENS(transactOpts *bind.TransactOpts, contractBackend bind.ContractBackend) (*ENS, error) {
|
||||
// Deploy the ENS registry
|
||||
ensAddr, _, _, err := contract.DeployENS(transactOpts, contractBackend, transactOpts.From)
|
||||
|
@ -79,7 +79,7 @@ func TestSignerPromotion(t *testing.T) {
|
||||
// Gradually promote the keys, until all are authorized
|
||||
keys = append([]*ecdsa.PrivateKey{key}, keys...)
|
||||
for i := 1; i < len(keys); i++ {
|
||||
// Check that no votes are accepted from the not yet authed user
|
||||
// Check that no votes are accepted from the not yet authorized user
|
||||
if _, err := oracle.Promote(bind.NewKeyedTransactor(keys[i]), common.Address{}); err != nil {
|
||||
t.Fatalf("Iter #%d: failed invalid promotion attempt: %v", i, err)
|
||||
}
|
||||
@ -216,7 +216,7 @@ func TestVersionRelease(t *testing.T) {
|
||||
// Gradually push releases, always requiring more signers than previously
|
||||
keys = append([]*ecdsa.PrivateKey{key}, keys...)
|
||||
for i := 1; i < len(keys); i++ {
|
||||
// Check that no votes are accepted from the not yet authed user
|
||||
// Check that no votes are accepted from the not yet authorized user
|
||||
if _, err := oracle.Release(bind.NewKeyedTransactor(keys[i]), 0, 0, 0, [20]byte{0}); err != nil {
|
||||
t.Fatalf("Iter #%d: failed invalid release attempt: %v", i, err)
|
||||
}
|
||||
|
Reference in New Issue
Block a user