Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mybee
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
vicotor
mybee
Commits
1d685803
Unverified
Commit
1d685803
authored
May 08, 2020
by
Janoš Guljaš
Committed by
GitHub
May 08, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add misspell, gofmt and unconvert linters (#160)
parent
e7b0f738
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
32 additions
and
23 deletions
+32
-23
pre-push.bash
.githooks/pre-push.bash
+1
-6
go.yml
.github/workflows/go.yml
+4
-0
.golangci.yml
.golangci.yml
+6
-1
Makefile
Makefile
+7
-2
breaker.go
pkg/p2p/libp2p/internal/breaker/breaker.go
+5
-5
metrics.go
pkg/pushsync/metrics.go
+2
-2
pushsync.go
pkg/pushsync/pushsync.go
+2
-2
swarm.go
pkg/swarm/swarm.go
+3
-3
validator_test.go
pkg/validator/validator_test.go
+2
-2
No files found.
.githooks/pre-push.bash
View file @
1d685803
...
...
@@ -8,9 +8,4 @@ if [ -z "$commits" ]; then
exit
0
fi
if
!
command
-v
golangci-lint &> /dev/null
;
then
echo
"installing golangci-lint..."
go get
-u
github.com/golangci/golangci-lint/cmd/golangci-lint
fi
make lint vet test-race
make build lint vet test-race
\ No newline at end of file
.github/workflows/go.yml
View file @
1d685803
...
...
@@ -26,6 +26,10 @@ jobs:
echo "::set-env name=GOPATH::$(go env GOPATH)"
echo "::add-path::$(go env GOPATH)/bin"
shell
:
bash
-
name
:
Set git to use LF
# make sure that line endings are not converted on windows
# as gofmt linter will report that they need to be changed
run
:
git config --global core.autocrlf
false
-
name
:
Checkout
uses
:
actions/checkout@v2
with
:
...
...
.golangci.yml
View file @
1d685803
run
:
timeout
:
10m
linters
:
enable
:
-
misspell
-
gofmt
-
unconvert
Makefile
View file @
1d685803
GO
?=
go
GOLANGCI_LINT
?=
golangci-lint
GOLANGCI_LINT_VERSION
?=
v1.26.0
LDFLAGS
?=
-s
-w
ifdef
COMMIT
...
...
@@ -7,7 +8,7 @@ LDFLAGS += -X github.com/ethersphere/bee.commit="$(COMMIT)"
endif
.PHONY
:
all
all
:
build lint vet test binary
all
:
build lint vet test
-race
binary
.PHONY
:
binary
binary
:
export CGO_ENABLED=0
...
...
@@ -19,9 +20,13 @@ dist:
mkdir
$@
.PHONY
:
lint
lint
:
lint
:
linter
$(GOLANGCI_LINT)
run
.PHONY
:
linter
linter
:
which
$(GOLANGCI_LINT)
||
(
cd
/tmp
&&
GO111MODULE
=
on
$(GO)
get
-u
github.com/golangci/golangci-lint/cmd/golangci-lint@
$(GOLANGCI_LINT_VERSION)
)
.PHONY
:
vet
vet
:
$(GO)
vet ./...
...
...
pkg/p2p/libp2p/internal/breaker/breaker.go
View file @
1d685803
...
...
@@ -30,22 +30,22 @@ var (
type
Interface
interface
{
// Execute runs f() if the limit number of consecutive failed calls is not reached within fail interval.
// f() call is not locked so it can still be executed concurently.
// f() call is not locked so it can still be executed concur
r
ently.
// Returns `ErrClosed` if the limit is reached or f() result otherwise.
Execute
(
f
func
()
error
)
error
// ClosedUntil retuns the timestamp when the breaker will become open again.
// ClosedUntil retu
r
ns the timestamp when the breaker will become open again.
ClosedUntil
()
time
.
Time
}
type
breaker
struct
{
limit
int
// breaker will not exe
ucute any more tasks after limit number of consequtive failuer
s happen
consFailedCalls
int
// current number of conse
q
utive fails
limit
int
// breaker will not exe
cute any more tasks after limit number of consecutive failure
s happen
consFailedCalls
int
// current number of conse
c
utive fails
firstFailedTimestamp
time
.
Time
closedTimestamp
time
.
Time
backoff
time
.
Duration
// initial backoff duration
maxBackoff
time
.
Duration
failInterval
time
.
Duration
// conse
quitive failures are counted if they happen withing
this interval
failInterval
time
.
Duration
// conse
cutive failures are counted if they happen within
this interval
mtx
sync
.
Mutex
}
...
...
pkg/pushsync/metrics.go
View file @
1d685803
...
...
@@ -47,13 +47,13 @@ func newMetrics() metrics {
Namespace
:
m
.
Namespace
,
Subsystem
:
subsystem
,
Name
:
"total_chunk_synced"
,
Help
:
"Total chunks synced succesfully with valid receipts."
,
Help
:
"Total chunks synced succes
s
fully with valid receipts."
,
}),
TotalChunksStoredInDB
:
prometheus
.
NewCounter
(
prometheus
.
CounterOpts
{
Namespace
:
m
.
Namespace
,
Subsystem
:
subsystem
,
Name
:
"total_chunk_stored_in_DB"
,
Help
:
"Total chunks stored succesfully in local store."
,
Help
:
"Total chunks stored succes
s
fully in local store."
,
}),
ChunksSentCounter
:
prometheus
.
NewCounter
(
prometheus
.
CounterOpts
{
Namespace
:
m
.
Namespace
,
...
...
pkg/pushsync/pushsync.go
View file @
1d685803
...
...
@@ -111,7 +111,7 @@ func (ps *PushSync) handler(ctx context.Context, p p2p.Peer, stream p2p.Stream)
}
ps
.
metrics
.
TotalChunksStoredInDB
.
Inc
()
// Send a receipt immediately once the storage of the chunk is successful
l
// Send a receipt immediately once the storage of the chunk is successful
receipt
:=
&
pb
.
Receipt
{
Address
:
chunk
.
Address
()
.
Bytes
()}
err
=
ps
.
sendReceipt
(
w
,
receipt
)
if
err
!=
nil
{
...
...
@@ -133,7 +133,7 @@ func (ps *PushSync) handler(ctx context.Context, p p2p.Peer, stream p2p.Stream)
}
ps
.
metrics
.
TotalChunksStoredInDB
.
Inc
()
// Send a receipt immediately once the storage of the chunk is successful
l
// Send a receipt immediately once the storage of the chunk is successful
receipt
:=
&
pb
.
Receipt
{
Address
:
chunk
.
Address
()
.
Bytes
()}
return
ps
.
sendReceipt
(
w
,
receipt
)
}
...
...
pkg/swarm/swarm.go
View file @
1d685803
pkg/validator/validator_test.go
View file @
1d685803
...
...
@@ -7,8 +7,8 @@ import (
"encoding/binary"
"testing"
"github.com/ethersphere/bee/pkg/validator"
"github.com/ethersphere/bee/pkg/swarm"
"github.com/ethersphere/bee/pkg/validator"
)
// TestContentAddressValidator checks that the validator evaluates correctly
...
...
@@ -28,7 +28,7 @@ func TestContentAddressValidator(t *testing.T) {
fooLength
:=
len
(
foo
)
fooBytes
:=
make
([]
byte
,
8
+
fooLength
)
binary
.
LittleEndian
.
PutUint64
(
fooBytes
,
uint64
(
fooLength
))
copy
(
fooBytes
[
8
:
],
[]
byte
(
foo
)
)
copy
(
fooBytes
[
8
:
],
foo
)
ch
:=
swarm
.
NewChunk
(
address
,
fooBytes
)
if
!
validator
.
Validate
(
ch
)
{
t
.
Fatalf
(
"data '%s' should have validated to hash '%s'"
,
ch
.
Data
(),
ch
.
Address
())
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment