Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix function comments based on best practices from Effective Go #101

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions stratum/mmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func NewMinersMap() MinersMap {
return m
}

// Returns shard under given key
// GetShard returns shard under given key
func (m MinersMap) GetShard(key string) *MinersMapShared {
hasher := fnv.New32()
hasher.Write([]byte(key))
Expand All @@ -43,7 +43,7 @@ func (m *MinersMap) Set(key string, value *Miner) {
shard.items[key] = value
}

// Retrieves an element from map under given key.
// Get retrieves an element from map under given key.
func (m MinersMap) Get(key string) (*Miner, bool) {
// Get shard
shard := m.GetShard(key)
Expand All @@ -55,7 +55,7 @@ func (m MinersMap) Get(key string) (*Miner, bool) {
return val, ok
}

// Returns the number of elements within the map.
// Count returns the number of elements within the map.
func (m MinersMap) Count() int {
count := 0
for i := 0; i < SHARD_COUNT; i++ {
Expand All @@ -79,7 +79,7 @@ func (m *MinersMap) Has(key string) bool {
return ok
}

// Removes an element from the map.
// Remove removes an element from the map.
func (m *MinersMap) Remove(key string) {
// Try to get shard.
shard := m.GetShard(key)
Expand All @@ -88,7 +88,7 @@ func (m *MinersMap) Remove(key string) {
delete(shard.items, key)
}

// Checks if map is empty.
// IsEmpty checks if map is empty.
func (m *MinersMap) IsEmpty() bool {
return m.Count() == 0
}
Expand All @@ -99,7 +99,7 @@ type Tuple struct {
Val *Miner
}

// Returns an iterator which could be used in a for range loop.
// Iter returns an iterator which could be used in a for range loop.
func (m MinersMap) Iter() <-chan Tuple {
ch := make(chan Tuple)
go func() {
Expand All @@ -117,7 +117,7 @@ func (m MinersMap) Iter() <-chan Tuple {
return ch
}

// Returns a buffered iterator which could be used in a for range loop.
// IterBuffered returns a buffered iterator which could be used in a for range loop.
func (m MinersMap) IterBuffered() <-chan Tuple {
ch := make(chan Tuple, m.Count())
go func() {
Expand Down