Skip to content
Merged
Show file tree
Hide file tree
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
19 changes: 19 additions & 0 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: golangci-lint
on: [ push, pull_request ]
jobs:
golangci:
name: lint
# run job on all pushes OR external PR, not both
if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name }}
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Install Go
uses: actions/setup-go@v6
with:
go-version: 1.26.x
- name: golangci-lint
uses: golangci/golangci-lint-action@v9
with:
version: v2.11.4
40 changes: 40 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Test
on: [ push, pull_request ]
jobs:
test:
# run job on all pushes OR external PR, not both
if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name }}
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest, windows-latest, macos-latest ]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Install Go
uses: actions/setup-go@v6
with:
go-version: 1.26.x
cache: true
- name: gofmt && go mod tidy
if: matrix.os == 'ubuntu-latest'
shell: bash
run: |
go mod tidy -compat=1.26
test -z "$(gofmt -d .)" || (gofmt -d . && false)
test -z "$(git status --porcelain)" || (git status; git diff && false)
- name: Test
run: go test -count=1 -v ./...
- name: Test with -race
run: go test -race -count=1 -v ./...
- name: Build
run: go build .
- name: Upload build
uses: actions/upload-artifact@v7
with:
name: awl-bootstrap-node-${{ runner.os }}
path: |
awl-bootstrap-node
awl-bootstrap-node.exe
if-no-files-found: error
88 changes: 88 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
version: "2"
run:
go: "1.26"

linters:
default: none
enable:
- asciicheck
- bodyclose
- copyloopvar
- dogsled
- dupl
- errcheck
- exhaustive
- goconst
- gocritic
- gocyclo
- goprintffuncname
- gosec
- govet
- ineffassign
- mirror
- misspell
- nakedret
- nestif
- nilnil
- nolintlint
- nosprintfhostport
- prealloc
- rowserrcheck
- sqlclosecheck
- staticcheck
- unconvert
- unparam
- unused
- wastedassign
- whitespace

settings:
exhaustive:
default-signifies-exhaustive: true
gocritic:
disabled-checks:
- hugeParam
- rangeValCopy
- ifElseChain
enabled-tags:
- diagnostic
- performance
prealloc:
simple: true
range-loops: true
for-loops: true
exclusions:
generated: lax
presets:
- comments
- common-false-positives
- legacy
- std-error-handling
rules:
- linters:
- errcheck
- goconst
path: _test\.go
- linters:
- gosec
text: 'G101:'
- linters:
- gosec
text: 'G404:'
- linters:
- gosec
text: 'G115:'
paths:
- third_party$
- builtin$
- examples$

formatters:
enable:
- gofmt
exclusions:
generated: lax
paths:
- third_party$
- builtin$
- examples$
10 changes: 9 additions & 1 deletion application.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"github.com/libp2p/go-libp2p/core/network"
"github.com/libp2p/go-libp2p/core/peer"
"github.com/libp2p/go-libp2p/core/peerstore"
"github.com/libp2p/go-libp2p/p2p/host/peerstore/pstoreds"
"github.com/libp2p/go-libp2p/p2p/host/peerstore/pstoreds" //nolint:staticcheck // disk-backed peerstore is intentional for bootstrap-node; will migrate when libp2p removes it
"github.com/libp2p/go-libp2p/p2p/host/peerstore/pstoremem"
rcmgr "github.com/libp2p/go-libp2p/p2p/host/resource-manager"
"github.com/libp2p/go-libp2p/p2p/protocol/circuitv2/relay"
Expand All @@ -41,6 +41,7 @@ type Application struct {

Api *api.Handler
p2pServer *p2p.P2p
datastore ds.Batching
}

func New() *Application {
Expand All @@ -53,6 +54,7 @@ func (a *Application) Init(ctx context.Context) error {
if err != nil {
return fmt.Errorf("could not make p2p host config: %s", err)
}
a.datastore = p2pHostConfig.DHTDatastore
p2pSrv := p2p.NewP2p(ctx)
host, err := p2pSrv.InitHost(p2pHostConfig)
if err != nil {
Expand Down Expand Up @@ -145,6 +147,12 @@ func (a *Application) Close() {
a.logger.Errorf("closing p2p server: %v", err)
}
}
if a.datastore != nil {
err := a.datastore.Close()
if err != nil {
a.logger.Errorf("closing datastore: %v", err)
}
}
}

func (a *Application) makeP2pHostConfig() (p2p.HostConfig, error) {
Expand Down
Loading