From b4c9fed04afd7874c7390162481b67caa783d169 Mon Sep 17 00:00:00 2001 From: VM <112189277+sysvm@users.noreply.github.com> Date: Wed, 14 Jun 2023 01:43:21 +0800 Subject: [PATCH] docs: fix some comments errors (#2356) --- config/config.go | 6 +++--- core/crypto/ecdsa.go | 2 +- core/crypto/ed25519.go | 2 +- core/crypto/key.go | 4 ++-- core/crypto/rsa_go.go | 6 +++--- core/crypto/secp256k1.go | 4 ++-- core/event/addrs.go | 2 +- core/event/bus.go | 2 +- core/event/dht.go | 2 +- core/event/network.go | 4 ++-- core/host/host.go | 2 +- core/metrics/bandwidth.go | 6 +++--- core/network/network.go | 2 +- core/network/rcmgr.go | 6 +++--- core/peerstore/peerstore.go | 6 +++--- core/record/envelope.go | 6 +++--- core/record/record.go | 2 +- p2p/host/resource-manager/README.md | 2 +- 18 files changed, 33 insertions(+), 33 deletions(-) diff --git a/config/config.go b/config/config.go index 0eb2b0d97a..25f70a5f65 100644 --- a/config/config.go +++ b/config/config.go @@ -136,8 +136,8 @@ func (cfg *Config) makeSwarm(eventBus event.Bus, enableMetrics bool) (*swarm.Swa if pnet.ForcePrivateNetwork && len(cfg.PSK) == 0 { log.Error("tried to create a libp2p node with no Private" + " Network Protector but usage of Private Networks" + - " is forced by the enviroment") - // Note: This is *also* checked the upgrader itself so it'll be + " is forced by the environment") + // Note: This is *also* checked the upgrader itself, so it'll be // enforced even *if* you don't use the libp2p constructor. return nil, pnet.ErrNotInPrivateNetwork } @@ -400,7 +400,7 @@ func (cfg *Config) NewNode() (host.Host, error) { } // Pull out the pieces of the config that we _actually_ care about. - // Specifically, don't setup things like autorelay, listeners, + // Specifically, don't set up things like autorelay, listeners, // identify, etc. autoNatCfg := Config{ Transports: cfg.Transports, diff --git a/core/crypto/ecdsa.go b/core/crypto/ecdsa.go index 318dcac2b4..c936d502ac 100644 --- a/core/crypto/ecdsa.go +++ b/core/crypto/ecdsa.go @@ -49,7 +49,7 @@ func GenerateECDSAKeyPair(src io.Reader) (PrivKey, PubKey, error) { return GenerateECDSAKeyPairWithCurve(ECDSACurve, src) } -// GenerateECDSAKeyPairWithCurve generates a new ecdsa private and public key with a speicified curve +// GenerateECDSAKeyPairWithCurve generates a new ecdsa private and public key with a specified curve func GenerateECDSAKeyPairWithCurve(curve elliptic.Curve, src io.Reader) (PrivKey, PubKey, error) { priv, err := ecdsa.GenerateKey(curve, src) if err != nil { diff --git a/core/crypto/ed25519.go b/core/crypto/ed25519.go index 7cd72efbce..d6e3031c03 100644 --- a/core/crypto/ed25519.go +++ b/core/crypto/ed25519.go @@ -101,7 +101,7 @@ func (k *Ed25519PublicKey) Equals(o Key) bool { return bytes.Equal(k.k, edk.k) } -// Verify checks a signature agains the input data. +// Verify checks a signature against the input data. func (k *Ed25519PublicKey) Verify(data []byte, sig []byte) (success bool, err error) { defer func() { catch.HandlePanic(recover(), &err, "ed15519 signature verification") diff --git a/core/crypto/key.go b/core/crypto/key.go index 9133141c8d..3652c3cde0 100644 --- a/core/crypto/key.go +++ b/core/crypto/key.go @@ -90,7 +90,7 @@ type PrivKey interface { GetPublic() PubKey } -// PubKey is a public key that can be used to verifiy data signed with the corresponding private key +// PubKey is a public key that can be used to verify data signed with the corresponding private key type PubKey interface { Key @@ -106,7 +106,7 @@ func GenerateKeyPair(typ, bits int) (PrivKey, PubKey, error) { return GenerateKeyPairWithReader(typ, bits, rand.Reader) } -// GenerateKeyPairWithReader returns a keypair of the given type and bitsize +// GenerateKeyPairWithReader returns a keypair of the given type and bit-size func GenerateKeyPairWithReader(typ, bits int, src io.Reader) (PrivKey, PubKey, error) { switch typ { case RSA: diff --git a/core/crypto/rsa_go.go b/core/crypto/rsa_go.go index 7927d17d18..efac25d712 100644 --- a/core/crypto/rsa_go.go +++ b/core/crypto/rsa_go.go @@ -14,12 +14,12 @@ import ( "github.com/minio/sha256-simd" ) -// RsaPrivateKey is an rsa private key +// RsaPrivateKey is a rsa private key type RsaPrivateKey struct { sk rsa.PrivateKey } -// RsaPublicKey is an rsa public key +// RsaPublicKey is a rsa public key type RsaPublicKey struct { k rsa.PublicKey @@ -101,7 +101,7 @@ func (sk *RsaPrivateKey) Raw() (res []byte, err error) { // Equals checks whether this key is equal to another func (sk *RsaPrivateKey) Equals(k Key) bool { - // make sure this is an rsa public key + // make sure this is a rsa public key other, ok := (k).(*RsaPrivateKey) if !ok { return basicEquals(sk, k) diff --git a/core/crypto/secp256k1.go b/core/crypto/secp256k1.go index 3b3aa6fe7e..27544a59f9 100644 --- a/core/crypto/secp256k1.go +++ b/core/crypto/secp256k1.go @@ -12,10 +12,10 @@ import ( "github.com/minio/sha256-simd" ) -// Secp256k1PrivateKey is an Secp256k1 private key +// Secp256k1PrivateKey is a Secp256k1 private key type Secp256k1PrivateKey secp256k1.PrivateKey -// Secp256k1PublicKey is an Secp256k1 public key +// Secp256k1PublicKey is a Secp256k1 public key type Secp256k1PublicKey secp256k1.PublicKey // GenerateSecp256k1Key generates a new Secp256k1 private and public key pair diff --git a/core/event/addrs.go b/core/event/addrs.go index 67026d1783..312a2fad56 100644 --- a/core/event/addrs.go +++ b/core/event/addrs.go @@ -59,7 +59,7 @@ type UpdatedAddress struct { // // In addition to the above, EvtLocalAddressesUpdated also contains the updated peer.PeerRecord // for the Current set of listen addresses, wrapped in a record.Envelope and signed by the Host's private key. -// This record can be shared with other peers to inform them of what we believe are our diallable addresses +// This record can be shared with other peers to inform them of what we believe are our diallable addresses // a secure and authenticated way. type EvtLocalAddressesUpdated struct { diff --git a/core/event/bus.go b/core/event/bus.go index 13e18e5356..1929f064d2 100644 --- a/core/event/bus.go +++ b/core/event/bus.go @@ -18,7 +18,7 @@ type CancelFunc = func() // subscriptions. type wildcardSubscriptionType interface{} -// WildcardSubscription is the type to subscribe to to receive all events +// WildcardSubscription is the type to subscribe to receive all events // emitted in the eventbus. var WildcardSubscription = new(wildcardSubscriptionType) diff --git a/core/event/dht.go b/core/event/dht.go index e01953f1d2..22e924e256 100644 --- a/core/event/dht.go +++ b/core/event/dht.go @@ -13,7 +13,7 @@ type RawJSON string // EXPERIMENTAL: this will likely be removed if/when the DHT event types are // hoisted to core, and the DHT event system is reconciled with the eventbus. type GenericDHTEvent struct { - // Type is the type of the DHT event that occured. + // Type is the type of the DHT event that occurred. Type string // Raw is the raw JSON representation of the event payload. diff --git a/core/event/network.go b/core/event/network.go index 37e9177d2f..e7f15726cc 100644 --- a/core/event/network.go +++ b/core/event/network.go @@ -22,7 +22,7 @@ import ( // - It's possible to have _multiple_ connections to a given peer. // - Both libp2p and networks are asynchronous. // -// This means that all of the following situations are possible: +// This means that all the following situations are possible: // // A connection is cut and is re-established: // @@ -48,7 +48,7 @@ import ( // might have been in active use but neither peer will observe a change in // "connectedness". Peers should always make sure to re-try network requests. type EvtPeerConnectednessChanged struct { - // Peer is the remote peer who's connectedness has changed. + // Peer is the remote peer whose connectedness has changed. Peer peer.ID // Connectedness is the new connectedness state. Connectedness network.Connectedness diff --git a/core/host/host.go b/core/host/host.go index e62be281f1..33e3cd33d4 100644 --- a/core/host/host.go +++ b/core/host/host.go @@ -61,7 +61,7 @@ type Host interface { // NewStream opens a new stream to given peer p, and writes a p2p/protocol // header with given ProtocolID. If there is no connection to p, attempts // to create one. If ProtocolID is "", writes no header. - // (Threadsafe) + // (Thread-safe) NewStream(ctx context.Context, p peer.ID, pids ...protocol.ID) (network.Stream, error) // Close shuts down the host, its Network, and services. diff --git a/core/metrics/bandwidth.go b/core/metrics/bandwidth.go index 3532bf5ee0..84360bd7c3 100644 --- a/core/metrics/bandwidth.go +++ b/core/metrics/bandwidth.go @@ -36,7 +36,7 @@ func (bwc *BandwidthCounter) LogSentMessage(size int64) { } // LogRecvMessage records the size of an incoming message -// without associating the bandwith to a specific peer or protocol. +// without associating the bandwidth to a specific peer or protocol. func (bwc *BandwidthCounter) LogRecvMessage(size int64) { bwc.totalIn.Mark(uint64(size)) } @@ -70,7 +70,7 @@ func (bwc *BandwidthCounter) GetBandwidthForPeer(p peer.ID) (out Stats) { } // GetBandwidthForProtocol returns a Stats struct with bandwidth metrics associated with the given protocol.ID. -// The metrics returned include all traffic sent / recieved for the protocol, regardless of which peers were +// The metrics returned include all traffic sent / received for the protocol, regardless of which peers were // involved. func (bwc *BandwidthCounter) GetBandwidthForProtocol(proto protocol.ID) (out Stats) { inSnap := bwc.protocolIn.Get(string(proto)).Snapshot() @@ -84,7 +84,7 @@ func (bwc *BandwidthCounter) GetBandwidthForProtocol(proto protocol.ID) (out Sta } } -// GetBandwidthTotals returns a Stats struct with bandwidth metrics for all data sent / recieved by the +// GetBandwidthTotals returns a Stats struct with bandwidth metrics for all data sent / received by the // local peer, regardless of protocol or remote peer IDs. func (bwc *BandwidthCounter) GetBandwidthTotals() (out Stats) { inSnap := bwc.totalIn.Snapshot() diff --git a/core/network/network.go b/core/network/network.go index 4cedb75d37..13c24ff2ff 100644 --- a/core/network/network.go +++ b/core/network/network.go @@ -130,7 +130,7 @@ type Network interface { io.Closer // SetStreamHandler sets the handler for new streams opened by the - // remote side. This operation is threadsafe. + // remote side. This operation is thread-safe. SetStreamHandler(StreamHandler) // NewStream returns a new stream to given peer p. diff --git a/core/network/rcmgr.go b/core/network/rcmgr.go index 524a28a8c4..934905e250 100644 --- a/core/network/rcmgr.go +++ b/core/network/rcmgr.go @@ -102,7 +102,7 @@ type ResourceManager interface { // ResourceScopeViewer is a mixin interface providing view methods for accessing top level // scopes. type ResourceScopeViewer interface { - // ViewSystem views the system wide resource scope. + // ViewSystem views the system-wide resource scope. // The system scope is the top level scope that accounts for global // resource usage at all levels of the system. This scope constrains all // other scopes and institutes global hard limits. @@ -134,7 +134,7 @@ const ( // Reservation PriorityMedium is a reservation priority that indicates a reservation if the scope // memory utilization is at 60% or less. ReservationPriorityMedium uint8 = 152 - // ReservationPriorityHigh is a reservation prioirity that indicates a reservation if the scope + // ReservationPriorityHigh is a reservation priority that indicates a reservation if the scope // memory utilization is at 80% or less. ReservationPriorityHigh uint8 = 203 // ReservationPriorityAlways is a reservation priority that indicates a reservation if there is @@ -218,7 +218,7 @@ type ConnManagementScope interface { ResourceScopeSpan // PeerScope returns the peer scope associated with this connection. - // It returns nil if the connection is not yet asociated with any peer. + // It returns nil if the connection is not yet associated with any peer. PeerScope() PeerScope // SetPeer sets the peer for a previously unassociated connection diff --git a/core/peerstore/peerstore.go b/core/peerstore/peerstore.go index b63582afe6..e28383b394 100644 --- a/core/peerstore/peerstore.go +++ b/core/peerstore/peerstore.go @@ -23,7 +23,7 @@ var ( // AddressTTL is the expiration time of addresses. AddressTTL = time.Hour - // TempAddrTTL is the ttl used for a short lived address. + // TempAddrTTL is the ttl used for a short-lived address. TempAddrTTL = time.Minute * 2 // RecentlyConnectedAddrTTL is used when we recently connected to a peer. @@ -62,7 +62,7 @@ type Peerstore interface { // that peer, useful to other services. PeerInfo(peer.ID) peer.AddrInfo - // Peers returns all of the peer IDs stored across all inner stores. + // Peers returns all the peer IDs stored across all inner stores. Peers() peer.IDSlice } @@ -116,7 +116,7 @@ type AddrBook interface { // ClearAddresses removes all previously stored addresses. ClearAddrs(p peer.ID) - // PeersWithAddrs returns all of the peer IDs stored in the AddrBook. + // PeersWithAddrs returns all the peer IDs stored in the AddrBook. PeersWithAddrs() peer.IDSlice } diff --git a/core/record/envelope.go b/core/record/envelope.go index 86ad142538..21127a5b97 100644 --- a/core/record/envelope.go +++ b/core/record/envelope.go @@ -87,7 +87,7 @@ func Seal(rec Record, privateKey crypto.PrivKey) (*Envelope, error) { // ConsumeEnvelope unmarshals a serialized Envelope and validates its // signature using the provided 'domain' string. If validation fails, an error -// is returned, along with the unmarshalled envelope so it can be inspected. +// is returned, along with the unmarshalled envelope, so it can be inspected. // // On success, ConsumeEnvelope returns the Envelope itself, as well as the inner payload, // unmarshalled into a concrete Record type. The actual type of the returned Record depends @@ -129,7 +129,7 @@ func ConsumeEnvelope(data []byte, domain string) (envelope *Envelope, rec Record // ConsumeTypedEnvelope unmarshals a serialized Envelope and validates its // signature. If validation fails, an error is returned, along with the unmarshalled -// envelope so it can be inspected. +// envelope, so it can be inspected. // // Unlike ConsumeEnvelope, ConsumeTypedEnvelope does not try to automatically determine // the type of Record to unmarshal the Envelope's payload into. Instead, the caller provides @@ -272,7 +272,7 @@ func makeUnsigned(domain string, payloadType []byte, payload []byte) ([]byte, er fields = [][]byte{[]byte(domain), payloadType, payload} // fields are prefixed with their length as an unsigned varint. we - // compute the lengths before allocating the sig buffer so we know how + // compute the lengths before allocating the sig buffer, so we know how // much space to add for the lengths flen = make([][]byte, len(fields)) size = 0 diff --git a/core/record/record.go b/core/record/record.go index 704227f2a9..9b98f04f52 100644 --- a/core/record/record.go +++ b/core/record/record.go @@ -39,7 +39,7 @@ type Record interface { // (see https://github.com/multiformats/multicodec). // When a Record is put into an Envelope (see record.Seal), the Codec value will be used // as the Envelope's PayloadType. When the Envelope is later unsealed, the PayloadType - // will be used to lookup the correct Record type to unmarshal the Envelope payload into. + // will be used to look up the correct Record type to unmarshal the Envelope payload into. Codec() []byte // MarshalRecord converts a Record instance to a []byte, so that it can be used as an diff --git a/p2p/host/resource-manager/README.md b/p2p/host/resource-manager/README.md index 85926100f6..c0069fdadc 100644 --- a/p2p/host/resource-manager/README.md +++ b/p2p/host/resource-manager/README.md @@ -332,7 +332,7 @@ and streams. ### Scaling Limits When building software that is supposed to run on many different kind of machines, -with various memory and CPU configurations, it is desireable to have limits that +with various memory and CPU configurations, it is desirable to have limits that scale with the size of the machine. This is done using the `ScalingLimitConfig`. For every scope, this configuration