Skip to content

Commit

Permalink
all: fix docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
holiman committed Oct 4, 2022
1 parent ea26fc8 commit ee301c7
Show file tree
Hide file tree
Showing 48 changed files with 110 additions and 95 deletions.
2 changes: 1 addition & 1 deletion cmd/devp2p/internal/ethtest/snap.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ type stRangesTest struct {
expSlots int
}

// TestSnapGetStorageRange various forms of GetStorageRanges requests.
// TestSnapGetStorageRanges various forms of GetStorageRanges requests.
func (s *Suite) TestSnapGetStorageRanges(t *utesting.T) {
var (
ffHash = common.HexToHash("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")
Expand Down
12 changes: 6 additions & 6 deletions cmd/devp2p/internal/v4test/discv4tests.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ const (
var (
// Remote node under test
Remote string
// IP where the first tester is listening, port will be assigned
// Listen1 is the IP where the first tester is listening, port will be assigned
Listen1 string = "127.0.0.1"
// IP where the second tester is listening, port will be assigned
// Listen2 is the IP where the second tester is listening, port will be assigned
// Before running the test, you may have to `sudo ifconfig lo0 add 127.0.0.2` (on MacOS at least)
Listen2 string = "127.0.0.2"
)
Expand Down Expand Up @@ -68,7 +68,7 @@ func futureExpiration() uint64 {
return uint64(time.Now().Add(expiration).Unix())
}

// This test just sends a PING packet and expects a response.
// BasicPing just sends a PING packet and expects a response.
func BasicPing(t *utesting.T) {
te := newTestEnv(Remote, Listen1, Listen2)
defer te.close()
Expand Down Expand Up @@ -137,7 +137,7 @@ func (te *testenv) checkPong(reply v4wire.Packet, pingHash []byte) error {
return nil
}

// This test sends a PING packet with wrong 'to' field and expects a PONG response.
// PingWrongTo sends a PING packet with wrong 'to' field and expects a PONG response.
func PingWrongTo(t *utesting.T) {
te := newTestEnv(Remote, Listen1, Listen2)
defer te.close()
Expand All @@ -154,7 +154,7 @@ func PingWrongTo(t *utesting.T) {
}
}

// This test sends a PING packet with wrong 'from' field and expects a PONG response.
// PingWrongFrom sends a PING packet with wrong 'from' field and expects a PONG response.
func PingWrongFrom(t *utesting.T) {
te := newTestEnv(Remote, Listen1, Listen2)
defer te.close()
Expand All @@ -172,7 +172,7 @@ func PingWrongFrom(t *utesting.T) {
}
}

// This test sends a PING packet with additional data at the end and expects a PONG
// PingExtraData This test sends a PING packet with additional data at the end and expects a PONG
// response. The remote node should respond because EIP-8 mandates ignoring additional
// trailing data.
func PingExtraData(t *utesting.T) {
Expand Down
14 changes: 7 additions & 7 deletions cmd/devp2p/internal/v5test/discv5tests.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func (s *Suite) AllTests() []utesting.Test {
}
}

// This test sends PING and expects a PONG response.
// TestPing sends PING and expects a PONG response.
func (s *Suite) TestPing(t *utesting.T) {
conn, l1 := s.listen1(t)
defer conn.close()
Expand All @@ -84,7 +84,7 @@ func checkPong(t *utesting.T, pong *v5wire.Pong, ping *v5wire.Ping, c net.Packet
}
}

// This test sends PING with a 9-byte request ID, which isn't allowed by the spec.
// TestPingLargeRequestID sends PING with a 9-byte request ID, which isn't allowed by the spec.
// The remote node should not respond.
func (s *Suite) TestPingLargeRequestID(t *utesting.T) {
conn, l1 := s.listen1(t)
Expand All @@ -103,7 +103,7 @@ func (s *Suite) TestPingLargeRequestID(t *utesting.T) {
}
}

// In this test, a session is established from one IP as usual. The session is then reused
// TestPingMultiIP establishes a session from one IP as usual. The session is then reused
// on another IP, which shouldn't work. The remote node should respond with WHOAREYOU for
// the attempt from a different IP.
func (s *Suite) TestPingMultiIP(t *utesting.T) {
Expand Down Expand Up @@ -153,7 +153,7 @@ func (s *Suite) TestPingMultiIP(t *utesting.T) {
}
}

// This test starts a handshake, but doesn't finish it and sends a second ordinary message
// TestPingHandshakeInterrupted starts a handshake, but doesn't finish it and sends a second ordinary message
// packet instead of a handshake message packet. The remote node should respond with
// another WHOAREYOU challenge for the second packet.
func (s *Suite) TestPingHandshakeInterrupted(t *utesting.T) {
Expand All @@ -180,7 +180,7 @@ func (s *Suite) TestPingHandshakeInterrupted(t *utesting.T) {
}
}

// This test sends TALKREQ and expects an empty TALKRESP response.
// TestTalkRequest sends TALKREQ and expects an empty TALKRESP response.
func (s *Suite) TestTalkRequest(t *utesting.T) {
conn, l1 := s.listen1(t)
defer conn.close()
Expand Down Expand Up @@ -215,7 +215,7 @@ func (s *Suite) TestTalkRequest(t *utesting.T) {
}
}

// This test checks that the remote node returns itself for FINDNODE with distance zero.
// TestFindnodeZeroDistance checks that the remote node returns itself for FINDNODE with distance zero.
func (s *Suite) TestFindnodeZeroDistance(t *utesting.T) {
conn, l1 := s.listen1(t)
defer conn.close()
Expand All @@ -232,7 +232,7 @@ func (s *Suite) TestFindnodeZeroDistance(t *utesting.T) {
}
}

// In this test, multiple nodes ping the node under test. After waiting for them to be
// TestFindnodeResults pings the node under test from multiple nodes. After waiting for them to be
// accepted into the remote table, the test checks that they are returned by FINDNODE.
func (s *Suite) TestFindnodeResults(t *utesting.T) {
// Create bystanders.
Expand Down
4 changes: 3 additions & 1 deletion core/rawdb/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,9 @@ var (
genesisPrefix = []byte("ethereum-genesis-") // genesis state prefix for the db

// Chain index prefixes (use `i` + single byte to avoid mixing data types).
BloomBitsIndexPrefix = []byte("iB") // BloomBitsIndexPrefix is the data table of a chain indexer to track its progress

// BloomBitsIndexPrefix is the data table of a chain indexer to track its progress
BloomBitsIndexPrefix = []byte("iB")

preimageCounter = metrics.NewRegisteredCounter("db/preimage/total", nil)
preimageHitCounter = metrics.NewRegisteredCounter("db/preimage/hits", nil)
Expand Down
2 changes: 1 addition & 1 deletion core/state/snapshot/snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -844,7 +844,7 @@ func (t *Tree) generating() (bool, error) {
return layer.genMarker != nil, nil
}

// diskRoot is a external helper function to return the disk layer root.
// DiskRoot is a external helper function to return the disk layer root.
func (t *Tree) DiskRoot() common.Hash {
t.lock.Lock()
defer t.lock.Unlock()
Expand Down
4 changes: 2 additions & 2 deletions core/state/state_object.go
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ func (s *stateObject) deepCopy(db *StateDB) *stateObject {
// Attribute accessors
//

// Returns the address of the contract/account
// Address returns the address of the contract/account
func (s *stateObject) Address() common.Address {
return s.address
}
Expand Down Expand Up @@ -527,7 +527,7 @@ func (s *stateObject) Nonce() uint64 {
return s.data.Nonce
}

// Never called, but must be present to allow stateObject to be used
// Value is never called, but must be present to allow stateObject to be used
// as a vm.Account interface that also satisfies the vm.ContractRef
// interface. Interfaces are awesome.
func (s *stateObject) Value() *big.Int {
Expand Down
2 changes: 2 additions & 0 deletions core/state_transition.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ import (

var emptyCodeHash = crypto.Keccak256Hash(nil)

// StateTransition represents a state transition.
//
// The State Transitioning Model
//
// A state transition is a change made when a transaction is applied to the current world
Expand Down
2 changes: 1 addition & 1 deletion core/tx_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -865,7 +865,7 @@ func (pool *TxPool) AddRemotes(txs []*types.Transaction) []error {
return pool.addTxs(txs, false, false)
}

// This is like AddRemotes, but waits for pool reorganization. Tests use this method.
// AddRemotesSync is like AddRemotes, but waits for pool reorganization. Tests use this method.
func (pool *TxPool) AddRemotesSync(txs []*types.Transaction) []error {
return pool.addTxs(txs, false, true)
}
Expand Down
4 changes: 3 additions & 1 deletion core/types/transaction_signing.go
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ func (s EIP155Signer) Hash(tx *Transaction) common.Hash {
})
}

// HomesteadTransaction implements TransactionInterface using the
// HomesteadSigner implements Signer interface using the
// homestead rules.
type HomesteadSigner struct{ FrontierSigner }

Expand All @@ -427,6 +427,8 @@ func (hs HomesteadSigner) Sender(tx *Transaction) (common.Address, error) {
return recoverPlain(hs.Hash(tx), r, s, v, true)
}

// FrontierSigner implements Signer interface using the
// frontier rules.
type FrontierSigner struct{}

func (s FrontierSigner) ChainID() *big.Int {
Expand Down
8 changes: 4 additions & 4 deletions core/vm/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,12 @@ type StateDB interface {
// CallContext provides a basic interface for the EVM calling conventions. The EVM
// depends on this context being implemented for doing subcalls and initialising new EVM contracts.
type CallContext interface {
// Call another contract
// Call calls another contract.
Call(env *EVM, me ContractRef, addr common.Address, data []byte, gas, value *big.Int) ([]byte, error)
// Take another's contract code and execute within our own context
// CallCode takes another contracts code and execute within our own context
CallCode(env *EVM, me ContractRef, addr common.Address, data []byte, gas, value *big.Int) ([]byte, error)
// Same as CallCode except sender and value is propagated from parent to child scope
// DelegateCall is same as CallCode except sender and value is propagated from parent to child scope
DelegateCall(env *EVM, me ContractRef, addr common.Address, data []byte, gas *big.Int) ([]byte, error)
// Create a new contract
// Create creates a new contract
Create(env *EVM, me ContractRef, data []byte, gas, value *big.Int) ([]byte, common.Address, error)
}
2 changes: 1 addition & 1 deletion eth/downloader/resultstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ func (r *resultStore) getFetchResult(headerNumber uint64) (item *fetchResult, in
return item, index, stale, throttle, nil
}

// hasCompletedItems returns true if there are processable items available
// HasCompletedItems returns true if there are processable items available
// this method is cheaper than countCompleted
func (r *resultStore) HasCompletedItems() bool {
r.lock.RLock()
Expand Down
2 changes: 1 addition & 1 deletion eth/filters/filter_system.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ const (
PendingTransactionsSubscription
// BlocksSubscription queries hashes for blocks that are imported
BlocksSubscription
// LastSubscription keeps track of the last index
// LastIndexSubscription keeps track of the last index
LastIndexSubscription
)

Expand Down
2 changes: 1 addition & 1 deletion eth/protocols/snap/peer.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func (p *Peer) RequestAccountRange(id uint64, root common.Hash, origin, limit co
})
}

// RequestStorageRange fetches a batch of storage slots belonging to one or more
// RequestStorageRanges fetches a batch of storage slots belonging to one or more
// accounts. If slots from only one account is requested, an origin marker may also
// be used to retrieve from there.
func (p *Peer) RequestStorageRanges(id uint64, root common.Hash, accounts []common.Hash, origin, limit []byte, bytes uint64) error {
Expand Down
2 changes: 1 addition & 1 deletion eth/tracers/js/goja.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ func (t *jsTracer) CaptureTxStart(gasLimit uint64) {
t.gasLimit = gasLimit
}

// CaptureTxStart implements the Tracer interface and is invoked at the end of
// CaptureTxEnd implements the Tracer interface and is invoked at the end of
// transaction processing.
func (t *jsTracer) CaptureTxEnd(restGas uint64) {}

Expand Down
2 changes: 1 addition & 1 deletion les/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ func (api *LightAPI) LatestCheckpoint() ([4]string, error) {
return res, nil
}

// GetLocalCheckpoint returns the specific local checkpoint package.
// GetCheckpoint returns the specific local checkpoint package.
//
// The checkpoint package consists of 3 strings:
//
Expand Down
2 changes: 1 addition & 1 deletion les/downloader/downloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// You should have received a copy of the GNU Lesser General Public License
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.

// This is a temporary package whilst working on the eth/66 blocking refactors.
// Package downloader is a temporary package whilst working on the eth/66 blocking refactors.
// After that work is done, les needs to be refactored to use the new package,
// or alternatively use a stripped down version of it. Either way, we need to
// keep the changes scoped so duplicating temporarily seems the sanest.
Expand Down
2 changes: 1 addition & 1 deletion les/downloader/resultstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ func (r *resultStore) getFetchResult(headerNumber uint64) (item *fetchResult, in
return item, index, stale, throttle, nil
}

// hasCompletedItems returns true if there are processable items available
// HasCompletedItems returns true if there are processable items available
// this method is cheaper than countCompleted
func (r *resultStore) HasCompletedItems() bool {
r.lock.RLock()
Expand Down
2 changes: 1 addition & 1 deletion les/fetcher/block_fetcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// You should have received a copy of the GNU Lesser General Public License
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.

// This is a temporary package whilst working on the eth/66 blocking refactors.
// Package fetcher is a temporary package whilst working on the eth/66 blocking refactors.
// After that work is done, les needs to be refactored to use the new package,
// or alternatively use a stripped down version of it. Either way, we need to
// keep the changes scoped so duplicating temporarily seems the sanest.
Expand Down
2 changes: 1 addition & 1 deletion les/flowcontrol/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ func (cm *ClientManager) SetRechargeCurve(curve PieceWiseLinear) {
}
}

// SetCapacityRaiseThreshold sets a threshold value used for raising capFactor.
// SetCapacityLimits sets a threshold value used for raising capFactor.
// Either if the difference between total allowed and connected capacity is less
// than this threshold or if their ratio is less than capacityRaiseThresholdRatio
// then capFactor is allowed to slowly raise.
Expand Down
18 changes: 9 additions & 9 deletions les/odr_requests.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func (r *BlockRequest) Request(reqID uint64, peer *serverPeer) error {
return peer.requestBodies(reqID, []common.Hash{r.Hash})
}

// Valid processes an ODR request reply message from the LES network
// Validate processes an ODR request reply message from the LES network
// returns true and stores results in memory if the message was a valid reply
// to the request (implementation of LesOdrRequest)
func (r *BlockRequest) Validate(db ethdb.Database, msg *Msg) error {
Expand Down Expand Up @@ -151,7 +151,7 @@ func (r *ReceiptsRequest) Request(reqID uint64, peer *serverPeer) error {
return peer.requestReceipts(reqID, []common.Hash{r.Hash})
}

// Valid processes an ODR request reply message from the LES network
// Validate processes an ODR request reply message from the LES network
// returns true and stores results in memory if the message was a valid reply
// to the request (implementation of LesOdrRequest)
func (r *ReceiptsRequest) Validate(db ethdb.Database, msg *Msg) error {
Expand Down Expand Up @@ -213,7 +213,7 @@ func (r *TrieRequest) Request(reqID uint64, peer *serverPeer) error {
return peer.requestProofs(reqID, []ProofReq{req})
}

// Valid processes an ODR request reply message from the LES network
// Validate processes an ODR request reply message from the LES network
// returns true and stores results in memory if the message was a valid reply
// to the request (implementation of LesOdrRequest)
func (r *TrieRequest) Validate(db ethdb.Database, msg *Msg) error {
Expand Down Expand Up @@ -242,7 +242,7 @@ type CodeReq struct {
AccKey []byte
}

// ODR request type for node data (used for retrieving contract code), see LesOdrRequest interface
// CodeRequest is the ODR request type for node data (used for retrieving contract code), see LesOdrRequest interface
type CodeRequest light.CodeRequest

// GetCost returns the cost of the given ODR request according to the serving
Expand All @@ -266,7 +266,7 @@ func (r *CodeRequest) Request(reqID uint64, peer *serverPeer) error {
return peer.requestCode(reqID, []CodeReq{req})
}

// Valid processes an ODR request reply message from the LES network
// Validate processes an ODR request reply message from the LES network
// returns true and stores results in memory if the message was a valid reply
// to the request (implementation of LesOdrRequest)
func (r *CodeRequest) Validate(db ethdb.Database, msg *Msg) error {
Expand Down Expand Up @@ -312,7 +312,7 @@ type HelperTrieResps struct { // describes all responses, not just a single one
AuxData [][]byte
}

// ODR request type for requesting headers by Canonical Hash Trie, see LesOdrRequest interface
// ChtRequest is the ODR request type for requesting headers by Canonical Hash Trie, see LesOdrRequest interface
type ChtRequest light.ChtRequest

// GetCost returns the cost of the given ODR request according to the serving
Expand Down Expand Up @@ -343,7 +343,7 @@ func (r *ChtRequest) Request(reqID uint64, peer *serverPeer) error {
return peer.requestHelperTrieProofs(reqID, []HelperTrieReq{req})
}

// Valid processes an ODR request reply message from the LES network
// Validate processes an ODR request reply message from the LES network
// returns true and stores results in memory if the message was a valid reply
// to the request (implementation of LesOdrRequest)
func (r *ChtRequest) Validate(db ethdb.Database, msg *Msg) error {
Expand Down Expand Up @@ -400,7 +400,7 @@ type BloomReq struct {
BloomTrieNum, BitIdx, SectionIndex, FromLevel uint64
}

// ODR request type for requesting headers by Canonical Hash Trie, see LesOdrRequest interface
// BloomRequest is the ODR request type for requesting headers by Canonical Hash Trie, see LesOdrRequest interface
type BloomRequest light.BloomRequest

// GetCost returns the cost of the given ODR request according to the serving
Expand Down Expand Up @@ -439,7 +439,7 @@ func (r *BloomRequest) Request(reqID uint64, peer *serverPeer) error {
return peer.requestHelperTrieProofs(reqID, reqs)
}

// Valid processes an ODR request reply message from the LES network
// Validate processes an ODR request reply message from the LES network
// returns true and stores results in memory if the message was a valid reply
// to the request (implementation of LesOdrRequest)
func (r *BloomRequest) Validate(db ethdb.Database, msg *Msg) error {
Expand Down
2 changes: 1 addition & 1 deletion les/protocol.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ var (
AdvertiseProtocolVersions = []uint{lpv2} // clients are searching for the first advertised protocol in the list
)

// Number of implemented message corresponding to different protocol versions.
// ProtocolLengths is the number of implemented message corresponding to different protocol versions.
var ProtocolLengths = map[uint]uint64{lpv2: 22, lpv3: 24, lpv4: 24}

const (
Expand Down
Loading

0 comments on commit ee301c7

Please sign in to comment.