diff --git a/.github/labels.yml b/.github/labels.yml
index 95bc8ee..1bbcdeb 100644
--- a/.github/labels.yml
+++ b/.github/labels.yml
@@ -34,6 +34,9 @@
- name: "chore"
description: "Simple dependency updates or version bumps"
color: 006b75
+- name: "dependencies"
+ description: "Dependency updates, version bumps, etc."
+ color: 006b75
- name: "update"
description: "General updates"
color: 006b75
@@ -59,5 +62,5 @@
description: "Used for referencing DevContainers"
color: 006b75
- name: "docker"
- description: "Used for referencing Docker"
+ description: "Used for referencing Docker related issues"
color: 006b75
diff --git a/.golangci.json b/.golangci.json
index 377532d..a14ef5c 100644
--- a/.golangci.json
+++ b/.golangci.json
@@ -1,300 +1,298 @@
{
- "formatters": {
- "enable": [
- "gofmt"
- ],
- "exclusions": {
- "generated": "lax",
- "paths": [
- ".*\\.my\\.go$",
- "lib/bad.go",
- ".github",
- ".make",
- "dist",
- "third_party$",
- "builtin$",
- "examples$"
- ]
- },
- "settings": {
- "gci": {
- "sections": [
- "prefix(github.com/org/project)"
- ]
- },
- "gofmt": {
- "simplify": true
- },
- "gofumpt": {
- "extra-rules": false
- },
- "goimports": {
- "local-prefixes": [
- "github.com/org/project"
- ]
- }
- }
- },
- "issues": {
- "max-issues-per-linter": 0,
- "max-same-issues": 0,
- "new": false,
- "new-from-rev": "",
- "uniq-by-line": true
- },
- "linters": {
- "disable": [
- "gochecknoglobals",
- "gocritic",
- "godot",
- "gomoddirectives",
- "godox"
- ],
- "enable": [
- "asasalint",
- "asciicheck",
- "err113",
- "bidichk",
- "bodyclose",
- "containedctx",
- "contextcheck",
- "copyloopvar",
- "dogsled",
- "recvcheck",
- "godox",
- "nilnil",
- "nilnesserr",
- "gomoddirectives",
- "durationcheck",
- "errchkjson",
- "errname",
- "errorlint",
- "exhaustive",
- "forbidigo",
- "gocheckcompilerdirectives",
- "gochecknoinits",
- "gochecksumtype",
- "goheader",
- "gosec",
- "gosmopolitan",
- "inamedparam",
- "loggercheck",
- "makezero",
- "mirror",
- "misspell",
- "musttag",
- "nilerr",
- "noctx",
- "nolintlint",
- "nosprintfhostport",
- "prealloc",
- "predeclared",
- "protogetter",
- "reassign",
- "revive",
- "rowserrcheck",
- "spancheck",
- "sqlclosecheck",
- "testifylint",
- "unconvert",
- "unparam",
- "wastedassign",
- "zerologlint"
- ],
- "exclusions": {
- "generated": "lax",
- "paths": [
- ".*\\.my\\.go$",
- "lib/bad.go",
- ".github",
- ".make",
- "dist",
- "third_party$",
- "builtin$",
- "examples$"
- ],
- "rules": [
- {
- "linters": [
- "gocyclo"
- ],
- "path": "_test\\.go"
- },
- {
- "linters": [
- "testifylint"
- ],
- "text": "suite-subtest-run: use ts.Run to run subtest"
- },
- {
- "linters": [
- "scopelint"
- ],
- "text": "Using the variable on range scope"
- },
- {
- "linters": [
- "lll"
- ],
- "source": "^//go:generate "
- },
- {
- "path": "(.+)\\.go$",
- "text": "abcdef"
- }
- ]
- },
- "settings": {
- "dogsled": {
- "max-blank-identifiers": 2
- },
- "dupl": {
- "threshold": 100
- },
- "exhaustive": {
- "default-signifies-exhaustive": false
- },
- "funlen": {
- "lines": 60,
- "statements": 40
- },
- "gocognit": {
- "min-complexity": 10
- },
- "goconst": {
- "min-len": 3,
- "min-occurrences": 10
- },
- "gocritic": {
- "disabled-checks": [
- "regexpMust"
- ],
- "disabled-tags": [
- "experimental"
- ],
- "enabled-tags": [
- "performance"
- ],
- "settings": {
- "captLocal": {
- "paramsOnly": true
- },
- "rangeValCopy": {
- "sizeThreshold": 32
- }
- }
- },
- "gocyclo": {
- "min-complexity": 10
- },
- "godox": {
- "keywords": [
- "NOTE",
- "OPTIMIZE",
- "HACK"
- ]
- },
- "govet": {
- "disable-all": false,
- "enable": [
- "atomicalign",
- "shadow"
- ],
- "enable-all": false,
- "settings": {
- "printf": {
- "funcs": [
- "(github.com/golangci/golangci-lint/pkg/logutils.Log).Infof",
- "(github.com/golangci/golangci-lint/pkg/logutils.Log).Warnf",
- "(github.com/golangci/golangci-lint/pkg/logutils.Log).Errorf",
- "(github.com/golangci/golangci-lint/pkg/logutils.Log).Fatalf"
- ]
- }
- }
- },
- "lll": {
- "line-length": 120,
- "tab-width": 1
- },
- "misspell": {
- "ignore-rules": [
- "bsv",
- "bitcoin"
- ],
- "locale": "US"
- },
- "nakedret": {
- "max-func-lines": 30
- },
- "nestif": {
- "min-complexity": 4
- },
- "nolintlint": {
- "allow-unused": false,
- "require-explanation": true,
- "require-specific": true
- },
- "prealloc": {
- "for-loops": false,
- "range-loops": true,
- "simple": true
- },
- "rowserrcheck": {
- "packages": [
- "github.com/jmoiron/sqlx"
- ]
- },
- "testpackage": {
- "skip-regexp": "(export|internal)_test\\.go"
- },
- "unparam": {
- "check-exported": false
- },
- "whitespace": {
- "multi-func": false,
- "multi-if": false
- },
- "wsl": {
- "allow-assign-and-call": true,
- "allow-cuddle-declarations": true,
- "allow-multiline-assign": true,
- "allow-separated-leading-comment": false,
- "allow-trailing-comment": false,
- "force-case-trailing-whitespace": 0,
- "force-err-cuddling": false,
- "strict-append": true
- }
- }
- },
- "output": {
- "formats": {
- "text": {
- "path": "stdout",
- "print-issued-lines": true,
- "print-linter-name": true
- }
- },
- "path-prefix": ""
- },
- "run": {
- "allow-parallel-runners": false,
- "build-tags": [
- "mytag"
- ],
- "concurrency": 4,
- "issues-exit-code": 1,
- "tests": true
- },
- "severity": {
- "default": "error",
- "rules": [
- {
- "linters": [
- "dupl"
- ],
- "severity": "info"
- }
- ]
- },
- "version": "2"
+ "formatters": {
+ "enable": [
+ "gofmt"
+ ],
+ "exclusions": {
+ "generated": "lax",
+ "paths": [
+ ".*\\.my\\.go$",
+ "lib/bad.go",
+ ".github",
+ ".make",
+ "dist",
+ "third_party$",
+ "builtin$",
+ "examples$"
+ ]
+ },
+ "settings": {
+ "gci": {
+ "sections": [
+ "prefix(github.com/org/project)"
+ ]
+ },
+ "gofmt": {
+ "simplify": true
+ },
+ "gofumpt": {
+ "extra-rules": false
+ },
+ "goimports": {
+ "local-prefixes": [
+ "github.com/org/project"
+ ]
+ }
+ }
+ },
+ "issues": {
+ "max-issues-per-linter": 0,
+ "max-same-issues": 0,
+ "new": false,
+ "new-from-rev": "",
+ "uniq-by-line": true
+ },
+ "linters": {
+ "disable": [
+ "gocritic",
+ "godot",
+ "godox"
+ ],
+ "enable": [
+ "asasalint",
+ "asciicheck",
+ "bidichk",
+ "bodyclose",
+ "containedctx",
+ "contextcheck",
+ "copyloopvar",
+ "dogsled",
+ "durationcheck",
+ "err113",
+ "errchkjson",
+ "errname",
+ "errorlint",
+ "exhaustive",
+ "forbidigo",
+ "gocheckcompilerdirectives",
+ "gochecknoglobals",
+ "gochecknoinits",
+ "gochecksumtype",
+ "goheader",
+ "gomoddirectives",
+ "gosec",
+ "gosmopolitan",
+ "inamedparam",
+ "loggercheck",
+ "makezero",
+ "mirror",
+ "misspell",
+ "musttag",
+ "nilerr",
+ "nilnesserr",
+ "nilnil",
+ "noctx",
+ "nolintlint",
+ "nosprintfhostport",
+ "prealloc",
+ "predeclared",
+ "protogetter",
+ "reassign",
+ "recvcheck",
+ "revive",
+ "rowserrcheck",
+ "spancheck",
+ "sqlclosecheck",
+ "testifylint",
+ "unconvert",
+ "unparam",
+ "wastedassign",
+ "zerologlint"
+ ],
+ "exclusions": {
+ "generated": "lax",
+ "paths": [
+ ".*\\.my\\.go$",
+ "lib/bad.go",
+ ".github",
+ ".make",
+ "dist",
+ "third_party$",
+ "builtin$",
+ "examples$"
+ ],
+ "rules": [
+ {
+ "linters": [
+ "gocyclo"
+ ],
+ "path": "_test\\.go"
+ },
+ {
+ "linters": [
+ "testifylint"
+ ],
+ "text": "suite-subtest-run: use ts.Run to run subtest"
+ },
+ {
+ "linters": [
+ "scopelint"
+ ],
+ "text": "Using the variable on range scope"
+ },
+ {
+ "linters": [
+ "lll"
+ ],
+ "source": "^//go:generate "
+ },
+ {
+ "path": "(.+)\\.go$",
+ "text": "abcdef"
+ }
+ ]
+ },
+ "settings": {
+ "dogsled": {
+ "max-blank-identifiers": 2
+ },
+ "dupl": {
+ "threshold": 100
+ },
+ "exhaustive": {
+ "default-signifies-exhaustive": false
+ },
+ "funlen": {
+ "lines": 60,
+ "statements": 40
+ },
+ "gocognit": {
+ "min-complexity": 10
+ },
+ "goconst": {
+ "min-len": 3,
+ "min-occurrences": 10
+ },
+ "gocritic": {
+ "disabled-checks": [
+ "regexpMust"
+ ],
+ "disabled-tags": [
+ "experimental"
+ ],
+ "enabled-tags": [
+ "performance"
+ ],
+ "settings": {
+ "captLocal": {
+ "paramsOnly": true
+ },
+ "rangeValCopy": {
+ "sizeThreshold": 32
+ }
+ }
+ },
+ "gocyclo": {
+ "min-complexity": 10
+ },
+ "godox": {
+ "keywords": [
+ "NOTE",
+ "OPTIMIZE",
+ "HACK"
+ ]
+ },
+ "govet": {
+ "disable-all": false,
+ "enable": [
+ "atomicalign",
+ "shadow"
+ ],
+ "enable-all": false,
+ "settings": {
+ "printf": {
+ "funcs": [
+ "(github.com/golangci/golangci-lint/pkg/logutils.Log).Infof",
+ "(github.com/golangci/golangci-lint/pkg/logutils.Log).Warnf",
+ "(github.com/golangci/golangci-lint/pkg/logutils.Log).Errorf",
+ "(github.com/golangci/golangci-lint/pkg/logutils.Log).Fatalf"
+ ]
+ }
+ }
+ },
+ "lll": {
+ "line-length": 120,
+ "tab-width": 1
+ },
+ "misspell": {
+ "ignore-rules": [
+ "bsv",
+ "bitcoin"
+ ],
+ "locale": "US"
+ },
+ "nakedret": {
+ "max-func-lines": 30
+ },
+ "nestif": {
+ "min-complexity": 4
+ },
+ "nolintlint": {
+ "allow-unused": false,
+ "require-explanation": true,
+ "require-specific": true
+ },
+ "prealloc": {
+ "for-loops": false,
+ "range-loops": true,
+ "simple": true
+ },
+ "rowserrcheck": {
+ "packages": [
+ "github.com/jmoiron/sqlx"
+ ]
+ },
+ "testpackage": {
+ "skip-regexp": "(export|internal)_test\\.go"
+ },
+ "unparam": {
+ "check-exported": false
+ },
+ "whitespace": {
+ "multi-func": false,
+ "multi-if": false
+ },
+ "wsl": {
+ "allow-assign-and-call": true,
+ "allow-cuddle-declarations": true,
+ "allow-multiline-assign": true,
+ "allow-separated-leading-comment": false,
+ "allow-trailing-comment": false,
+ "force-case-trailing-whitespace": 0,
+ "force-err-cuddling": false,
+ "strict-append": true
+ }
+ }
+ },
+ "output": {
+ "formats": {
+ "text": {
+ "path": "stdout",
+ "print-issued-lines": true,
+ "print-linter-name": true
+ }
+ },
+ "path-prefix": ""
+ },
+ "run": {
+ "allow-parallel-runners": false,
+ "build-tags": [
+ "mytag"
+ ],
+ "concurrency": 4,
+ "issues-exit-code": 1,
+ "tests": true
+ },
+ "severity": {
+ "default": "error",
+ "rules": [
+ {
+ "linters": [
+ "dupl"
+ ],
+ "severity": "info"
+ }
+ ]
+ },
+ "version": "2"
}
diff --git a/README.md b/README.md
index c96e430..4371fa5 100644
--- a/README.md
+++ b/README.md
@@ -32,7 +32,7 @@
-
+
diff --git a/examples/examples.go b/examples/examples.go
index a2c3769..4ed2615 100644
--- a/examples/examples.go
+++ b/examples/examples.go
@@ -2,5 +2,5 @@
package main
func main() {
- // TODO - Implement the examples
+ // Implement the examples
}
diff --git a/map_to_slice_test.go b/map_to_slice_test.go
index eb7de98..45de936 100644
--- a/map_to_slice_test.go
+++ b/map_to_slice_test.go
@@ -4,7 +4,9 @@ import (
"sync"
"testing"
+ "github.com/bsv-blockchain/go-bt/v2/chainhash"
"github.com/stretchr/testify/assert"
+ "github.com/stretchr/testify/require"
)
// TestConvertSyncMapToUint32Slice tests the conversion of a sync.Map to a slice of uint32.
@@ -50,3 +52,39 @@ func TestGenericConvertSyncMapToUint32Slice(t *testing.T) {
assert.True(t, hasTransactions)
})
}
+
+// TestSplitSwissMapUint64Delete tests the Delete method of SplitSwissMapUint64.
+func TestSplitSwissMapUint64Delete(t *testing.T) {
+ t.Run("bucket does not exist", func(t *testing.T) {
+ m := NewSplitSwissMapUint64(10)
+ h := chainhash.Hash{0x00, 0x01}
+ bucket := Bytes2Uint16Buckets(h, m.nrOfBuckets)
+ delete(m.m, bucket)
+
+ err := m.Delete(h)
+ require.Error(t, err)
+ assert.ErrorIs(t, err, ErrBucketDoesNotExist)
+ })
+
+ t.Run("hash does not exist", func(t *testing.T) {
+ m := NewSplitSwissMapUint64(10)
+ h := chainhash.Hash{0x02, 0x01}
+
+ err := m.Delete(h)
+ require.Error(t, err)
+ assert.ErrorIs(t, err, ErrHashDoesNotExist)
+ })
+
+ t.Run("success", func(t *testing.T) {
+ m := NewSplitSwissMapUint64(10)
+ h := chainhash.Hash{0x03, 0x01}
+
+ require.NoError(t, m.Put(h, 1))
+ assert.Equal(t, 1, m.Length())
+
+ err := m.Delete(h)
+ require.NoError(t, err)
+ assert.False(t, m.Exists(h))
+ assert.Equal(t, 0, m.Length())
+ })
+}
diff --git a/split_swiss_map_uint64_delete_test.go b/split_swiss_map_uint64_delete_test.go
deleted file mode 100644
index eb05beb..0000000
--- a/split_swiss_map_uint64_delete_test.go
+++ /dev/null
@@ -1,44 +0,0 @@
-package txmap
-
-import (
- "testing"
-
- "github.com/bsv-blockchain/go-bt/v2/chainhash"
- "github.com/stretchr/testify/assert"
- "github.com/stretchr/testify/require"
-)
-
-func TestSplitSwissMapUint64_Delete(t *testing.T) {
- t.Run("bucket does not exist", func(t *testing.T) {
- m := NewSplitSwissMapUint64(10)
- h := chainhash.Hash{0x00, 0x01}
- bucket := Bytes2Uint16Buckets(h, m.nrOfBuckets)
- delete(m.m, bucket)
-
- err := m.Delete(h)
- require.Error(t, err)
- assert.ErrorIs(t, err, ErrBucketDoesNotExist)
- })
-
- t.Run("hash does not exist", func(t *testing.T) {
- m := NewSplitSwissMapUint64(10)
- h := chainhash.Hash{0x02, 0x01}
-
- err := m.Delete(h)
- require.Error(t, err)
- assert.ErrorIs(t, err, ErrHashDoesNotExist)
- })
-
- t.Run("success", func(t *testing.T) {
- m := NewSplitSwissMapUint64(10)
- h := chainhash.Hash{0x03, 0x01}
-
- require.NoError(t, m.Put(h, 1))
- assert.Equal(t, 1, m.Length())
-
- err := m.Delete(h)
- require.NoError(t, err)
- assert.False(t, m.Exists(h))
- assert.Equal(t, 0, m.Length())
- })
-}
diff --git a/tx_map.go b/tx_map.go
index 53fafc3..f487f02 100644
--- a/tx_map.go
+++ b/tx_map.go
@@ -121,7 +121,7 @@ var (
// Returns:
// - *SwissMap: A pointer to the newly created SwissMap instance.
//
-// Note: The length is not enforced, and the map can grow beyond this size.
+// Attn: The length is not enforced, and the map can grow beyond this size.
func NewSwissMap(length uint32) *SwissMap {
return &SwissMap{
m: swiss.NewMap[chainhash.Hash, struct{}](length),
@@ -452,7 +452,7 @@ type SwissLockFreeMapUint64 struct {
// - *SwissLockFreeMapUint64: A pointer to the newly created SwissLockFreeMapUint64 instance.
func NewSwissLockFreeMapUint64(length int) *SwissLockFreeMapUint64 {
return &SwissLockFreeMapUint64{
- m: swiss.NewMap[uint64, uint64](uint32(length)), //nolint:gosec // TODO: explain why we are skipping linting
+ m: swiss.NewMap[uint64, uint64](uint32(length)), //nolint:gosec // integer overflow conversion int -> uint32
length: atomic.Uint32{},
}
}
@@ -463,7 +463,7 @@ func NewSwissLockFreeMapUint64(length int) *SwissLockFreeMapUint64 {
// Returns:
// - *swiss.Map[uint64, uint64]: A pointer to the underlying swiss map.
//
-// Note: This method does not lock the map, so it is not suitable for concurrent access.
+// Attn: This method does not lock the map, so it is not suitable for concurrent access.
func (s *SwissLockFreeMapUint64) Map() *swiss.Map[uint64, uint64] {
return s.m
}
@@ -476,7 +476,7 @@ func (s *SwissLockFreeMapUint64) Map() *swiss.Map[uint64, uint64] {
// Returns:
// - bool: True if the hash exists in the map, false otherwise.
//
-// Note: This method does not lock the map, so it is not suitable for concurrent access.
+// Attn: This method does not lock the map, so it is not suitable for concurrent access.
func (s *SwissLockFreeMapUint64) Exists(hash uint64) bool {
_, ok := s.m.Get(hash)
return ok
@@ -493,7 +493,7 @@ func (s *SwissLockFreeMapUint64) Exists(hash uint64) bool {
// Returns:
// - error: An error if the hash already exists in the map, nil otherwise.
//
-// Note: This method does not lock the map, so it is not suitable for concurrent access.
+// Attn: This method does not lock the map, so it is not suitable for concurrent access.
func (s *SwissLockFreeMapUint64) Put(hash uint64, n uint64) error {
exists := s.m.Has(hash)
if exists {
@@ -515,7 +515,7 @@ func (s *SwissLockFreeMapUint64) Put(hash uint64, n uint64) error {
// - uint64: The value associated with the hash, or 0 if the hash does not exist.
// - bool: True if the hash was found in the map, false otherwise.
//
-// Note: This method does not lock the map, so it is not suitable for concurrent access.
+// Attn: This method does not lock the map, so it is not suitable for concurrent access.
func (s *SwissLockFreeMapUint64) Get(hash uint64) (uint64, bool) {
n, ok := s.m.Get(hash)
if !ok {
@@ -530,7 +530,7 @@ func (s *SwissLockFreeMapUint64) Get(hash uint64) (uint64, bool) {
// Returns:
// - int: The number of hashes currently stored in the map.
//
-// Note: This method uses atomic operations to retrieve the length, making it safe for concurrent access.
+// Attn: This method uses atomic operations to retrieve the length, making it safe for concurrent access.
func (s *SwissLockFreeMapUint64) Length() int {
return int(s.length.Load())
}
@@ -553,7 +553,7 @@ type SplitSwissMap struct {
// Returns:
// - *SplitSwissMap: A pointer to the newly created SplitSwissMap instance.
//
-// Note: The number of buckets is fixed at 1024, and the length is divided by this number to determine the size of each bucket.
+// Attn: The number of buckets is fixed at 1024, and the length is divided by this number to determine the size of each bucket.
func NewSplitSwissMap(length int) *SplitSwissMap {
m := &SplitSwissMap{
m: make(map[uint16]*SwissMapUint64, 1024),
@@ -708,7 +708,7 @@ func (g *SplitSwissMap) Delete(hash chainhash.Hash) error {
// Returns:
// - TxMap: A map where the keys are bucket indices and the values are pointers to SwissMapUint64 instances.
func (g *SplitSwissMap) Map() *SwissMapUint64 {
- m := NewSwissMapUint64(uint32(g.Length())) //nolint:gosec // TODO: explain why we are skipping linting
+ m := NewSwissMapUint64(uint32(g.Length())) //nolint:gosec // integer overflow conversion int -> uint32
for i := uint16(0); i <= g.nrOfBuckets; i++ {
keys := g.m[i].Keys()
for _, key := range keys {
@@ -878,7 +878,7 @@ func NewSplitSwissLockFreeMapUint64(length int) *SplitSwissLockFreeMapUint64 {
}
for i := uint64(0); i <= m.nrOfBuckets; i++ {
- m.m[i] = NewSwissLockFreeMapUint64(length / int(m.nrOfBuckets)) //nolint:gosec // TODO: define why we are skipping linting
+ m.m[i] = NewSwissLockFreeMapUint64(length / int(m.nrOfBuckets)) //nolint:gosec // integer overflow conversion uint64 -> int
}
return m
@@ -893,7 +893,7 @@ func NewSplitSwissLockFreeMapUint64(length int) *SplitSwissLockFreeMapUint64 {
// Returns:
// - bool: True if the hash exists in the map, false otherwise.
//
-// Note: This method does not lock the map, so it is not suitable for concurrent access.
+// Attn: This method does not lock the map, so it is not suitable for concurrent access.
func (g *SplitSwissLockFreeMapUint64) Exists(hash uint64) bool {
return g.m[hash%g.nrOfBuckets].Exists(hash)
}
@@ -904,7 +904,7 @@ func (g *SplitSwissLockFreeMapUint64) Exists(hash uint64) bool {
// Returns:
// - map[uint64]*SwissLockFreeMapUint64: A map where the keys are bucket indices and the values are pointers to SwissLockFreeMapUint64 instances.
//
-// Note: This method does not lock the map, so it is not suitable for concurrent access.
+// Attn: This method does not lock the map, so it is not suitable for concurrent access.
func (g *SplitSwissLockFreeMapUint64) Map() map[uint64]*SwissLockFreeMapUint64 {
return g.m
}
@@ -920,7 +920,7 @@ func (g *SplitSwissLockFreeMapUint64) Map() map[uint64]*SwissLockFreeMapUint64 {
// Returns:
// - error: An error if the hash already exists in the map, nil otherwise.
//
-// Note: This method does not lock the map, so it is not suitable for concurrent access.
+// Attn: This method does not lock the map, so it is not suitable for concurrent access.
func (g *SplitSwissLockFreeMapUint64) Put(hash, n uint64) error {
return g.m[hash%g.nrOfBuckets].Put(hash, n)
}
@@ -935,7 +935,7 @@ func (g *SplitSwissLockFreeMapUint64) Put(hash, n uint64) error {
// - uint64: The value associated with the hash, or 0 if the hash does not exist.
// - bool: True if the hash was found in the map, false otherwise.
//
-// Note: This method does not lock the map, so it is not suitable for concurrent access.
+// Attn: This method does not lock the map, so it is not suitable for concurrent access.
func (g *SplitSwissLockFreeMapUint64) Get(hash uint64) (uint64, bool) {
return g.m[hash%g.nrOfBuckets].Get(hash)
}
@@ -947,7 +947,7 @@ func (g *SplitSwissLockFreeMapUint64) Get(hash uint64) (uint64, bool) {
// Returns:
// - []chainhash.Hash: A slice containing all the hashes in the map.
//
-// Note: This method does not lock the map, so it is not suitable for concurrent access.
+// Attn: This method does not lock the map, so it is not suitable for concurrent access.
func (g *SplitSwissMapUint64) Keys() []chainhash.Hash {
keys := make([]chainhash.Hash, 0, g.Length())
diff --git a/tx_map_benchmarks_test.go b/tx_map_benchmarks_test.go
index fe10b95..b0269f2 100644
--- a/tx_map_benchmarks_test.go
+++ b/tx_map_benchmarks_test.go
@@ -7,6 +7,8 @@ import (
"github.com/bsv-blockchain/go-bt/v2/chainhash"
)
+const errMapShouldNotBeNil = "map should not be nil"
+
// BenchmarkBytes2Uint16Buckets measures the performance of Bytes2Uint16Buckets.
func BenchmarkBytes2Uint16Buckets(b *testing.B) {
hash := chainhash.Hash{0x01, 0x02}
@@ -63,7 +65,7 @@ func BenchmarkNewSplitSwissLockFreeMapUint64(b *testing.B) {
for i := 0; i < b.N; i++ {
if NewSplitSwissLockFreeMapUint64(1000) == nil {
- b.Fatal("map should not be nil")
+ b.Fatal(errMapShouldNotBeNil)
}
}
}
@@ -75,7 +77,7 @@ func BenchmarkNewSplitSwissMap(b *testing.B) {
for i := 0; i < b.N; i++ {
if NewSplitSwissMap(1000) == nil {
- b.Fatal("map should not be nil")
+ b.Fatal(errMapShouldNotBeNil)
}
}
}
@@ -87,7 +89,7 @@ func BenchmarkNewSplitSwissMapUint64(b *testing.B) {
for i := 0; i < b.N; i++ {
if NewSplitSwissMapUint64(1000) == nil {
- b.Fatal("map should not be nil")
+ b.Fatal(errMapShouldNotBeNil)
}
}
}
@@ -99,7 +101,7 @@ func BenchmarkNewSwissLockFreeMapUint64(b *testing.B) {
for i := 0; i < b.N; i++ {
if NewSwissLockFreeMapUint64(1000) == nil {
- b.Fatal("map should not be nil")
+ b.Fatal(errMapShouldNotBeNil)
}
}
}
@@ -111,7 +113,7 @@ func BenchmarkNewSwissMap(b *testing.B) {
for i := 0; i < b.N; i++ {
if NewSwissMap(1000) == nil {
- b.Fatal("map should not be nil")
+ b.Fatal(errMapShouldNotBeNil)
}
}
}
@@ -123,7 +125,7 @@ func BenchmarkNewSwissMapUint64(b *testing.B) {
for i := 0; i < b.N; i++ {
if NewSwissMapUint64(1000) == nil {
- b.Fatal("map should not be nil")
+ b.Fatal(errMapShouldNotBeNil)
}
}
}
diff --git a/tx_map_test.go b/tx_map_test.go
index 225c304..67e7bf9 100644
--- a/tx_map_test.go
+++ b/tx_map_test.go
@@ -8,8 +8,8 @@ import (
"github.com/stretchr/testify/require"
)
-// Test_bytes2Uint16 tests the Bytes2Uint16Buckets function with various byte arrays and modulus values.
-func Test_bytes2Uint16(t *testing.T) {
+// TestBytes2Uint16 tests the Bytes2Uint16Buckets function with various byte arrays and modulus values.
+func TestBytes2Uint16(t *testing.T) {
type args struct {
b [32]byte
mod uint16