Skip to content

Commit

Permalink
docs: fix some comments errors (#2356)
Browse files Browse the repository at this point in the history
  • Loading branch information
sysvm authored Jun 13, 2023
1 parent 703c3a4 commit b4c9fed
Show file tree
Hide file tree
Showing 18 changed files with 33 additions and 33 deletions.
6 changes: 3 additions & 3 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion core/crypto/ecdsa.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion core/crypto/ed25519.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
4 changes: 2 additions & 2 deletions core/crypto/key.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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:
Expand Down
6 changes: 3 additions & 3 deletions core/crypto/rsa_go.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions core/crypto/secp256k1.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion core/event/addrs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down
2 changes: 1 addition & 1 deletion core/event/bus.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion core/event/dht.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions core/event/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:
//
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion core/host/host.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 3 additions & 3 deletions core/metrics/bandwidth.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
Expand Down Expand Up @@ -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()
Expand All @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion core/network/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 3 additions & 3 deletions core/network/rcmgr.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions core/peerstore/peerstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -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
}

Expand Down
6 changes: 3 additions & 3 deletions core/record/envelope.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion core/record/record.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion p2p/host/resource-manager/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b4c9fed

Please sign in to comment.