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
Hide 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
...
@@ -8,9 +8,4 @@ if [ -z "$commits" ]; then
exit
0
exit
0
fi
fi
if
!
command
-v
golangci-lint &> /dev/null
;
then
make build lint vet test-race
echo
"installing golangci-lint..."
\ No newline at end of file
go get
-u
github.com/golangci/golangci-lint/cmd/golangci-lint
fi
make lint vet test-race
.github/workflows/go.yml
View file @
1d685803
...
@@ -26,6 +26,10 @@ jobs:
...
@@ -26,6 +26,10 @@ jobs:
echo "::set-env name=GOPATH::$(go env GOPATH)"
echo "::set-env name=GOPATH::$(go env GOPATH)"
echo "::add-path::$(go env GOPATH)/bin"
echo "::add-path::$(go env GOPATH)/bin"
shell
:
bash
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
-
name
:
Checkout
uses
:
actions/checkout@v2
uses
:
actions/checkout@v2
with
:
with
:
...
...
.golangci.yml
View file @
1d685803
run
:
run
:
timeout
:
10m
timeout
:
10m
\ No newline at end of file
linters
:
enable
:
-
misspell
-
gofmt
-
unconvert
Makefile
View file @
1d685803
GO
?=
go
GO
?=
go
GOLANGCI_LINT
?=
golangci-lint
GOLANGCI_LINT
?=
golangci-lint
GOLANGCI_LINT_VERSION
?=
v1.26.0
LDFLAGS
?=
-s
-w
LDFLAGS
?=
-s
-w
ifdef
COMMIT
ifdef
COMMIT
...
@@ -7,7 +8,7 @@ LDFLAGS += -X github.com/ethersphere/bee.commit="$(COMMIT)"
...
@@ -7,7 +8,7 @@ LDFLAGS += -X github.com/ethersphere/bee.commit="$(COMMIT)"
endif
endif
.PHONY
:
all
.PHONY
:
all
all
:
build lint vet test binary
all
:
build lint vet test
-race
binary
.PHONY
:
binary
.PHONY
:
binary
binary
:
export CGO_ENABLED=0
binary
:
export CGO_ENABLED=0
...
@@ -19,9 +20,13 @@ dist:
...
@@ -19,9 +20,13 @@ dist:
mkdir
$@
mkdir
$@
.PHONY
:
lint
.PHONY
:
lint
lint
:
lint
:
linter
$(GOLANGCI_LINT)
run
$(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
.PHONY
:
vet
vet
:
vet
:
$(GO)
vet ./...
$(GO)
vet ./...
...
...
pkg/p2p/libp2p/internal/breaker/breaker.go
View file @
1d685803
...
@@ -30,22 +30,22 @@ var (
...
@@ -30,22 +30,22 @@ var (
type
Interface
interface
{
type
Interface
interface
{
// Execute runs f() if the limit number of consecutive failed calls is not reached within fail interval.
// 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.
// Returns `ErrClosed` if the limit is reached or f() result otherwise.
Execute
(
f
func
()
error
)
error
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
ClosedUntil
()
time
.
Time
}
}
type
breaker
struct
{
type
breaker
struct
{
limit
int
// breaker will not exe
ucute any more tasks after limit number of consequtive failuer
s happen
limit
int
// breaker will not exe
cute any more tasks after limit number of consecutive failure
s happen
consFailedCalls
int
// current number of conse
q
utive fails
consFailedCalls
int
// current number of conse
c
utive fails
firstFailedTimestamp
time
.
Time
firstFailedTimestamp
time
.
Time
closedTimestamp
time
.
Time
closedTimestamp
time
.
Time
backoff
time
.
Duration
// initial backoff duration
backoff
time
.
Duration
// initial backoff duration
maxBackoff
time
.
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
mtx
sync
.
Mutex
}
}
...
...
pkg/pushsync/metrics.go
View file @
1d685803
...
@@ -47,13 +47,13 @@ func newMetrics() metrics {
...
@@ -47,13 +47,13 @@ func newMetrics() metrics {
Namespace
:
m
.
Namespace
,
Namespace
:
m
.
Namespace
,
Subsystem
:
subsystem
,
Subsystem
:
subsystem
,
Name
:
"total_chunk_synced"
,
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
{
TotalChunksStoredInDB
:
prometheus
.
NewCounter
(
prometheus
.
CounterOpts
{
Namespace
:
m
.
Namespace
,
Namespace
:
m
.
Namespace
,
Subsystem
:
subsystem
,
Subsystem
:
subsystem
,
Name
:
"total_chunk_stored_in_DB"
,
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
{
ChunksSentCounter
:
prometheus
.
NewCounter
(
prometheus
.
CounterOpts
{
Namespace
:
m
.
Namespace
,
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)
...
@@ -111,7 +111,7 @@ func (ps *PushSync) handler(ctx context.Context, p p2p.Peer, stream p2p.Stream)
}
}
ps
.
metrics
.
TotalChunksStoredInDB
.
Inc
()
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
()}
receipt
:=
&
pb
.
Receipt
{
Address
:
chunk
.
Address
()
.
Bytes
()}
err
=
ps
.
sendReceipt
(
w
,
receipt
)
err
=
ps
.
sendReceipt
(
w
,
receipt
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -133,7 +133,7 @@ func (ps *PushSync) handler(ctx context.Context, p p2p.Peer, stream p2p.Stream)
...
@@ -133,7 +133,7 @@ func (ps *PushSync) handler(ctx context.Context, p p2p.Peer, stream p2p.Stream)
}
}
ps
.
metrics
.
TotalChunksStoredInDB
.
Inc
()
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
()}
receipt
:=
&
pb
.
Receipt
{
Address
:
chunk
.
Address
()
.
Bytes
()}
return
ps
.
sendReceipt
(
w
,
receipt
)
return
ps
.
sendReceipt
(
w
,
receipt
)
}
}
...
...
pkg/swarm/swarm.go
View file @
1d685803
...
@@ -14,9 +14,9 @@ import (
...
@@ -14,9 +14,9 @@ import (
const
(
const
(
SectionSize
=
32
SectionSize
=
32
Branches
=
128
Branches
=
128
ChunkSize
=
SectionSize
*
Branches
ChunkSize
=
SectionSize
*
Branches
MaxPO
=
16
MaxPO
=
16
)
)
// Address represents an address in Swarm metric space of
// Address represents an address in Swarm metric space of
...
...
pkg/validator/validator_test.go
View file @
1d685803
...
@@ -7,8 +7,8 @@ import (
...
@@ -7,8 +7,8 @@ import (
"encoding/binary"
"encoding/binary"
"testing"
"testing"
"github.com/ethersphere/bee/pkg/validator"
"github.com/ethersphere/bee/pkg/swarm"
"github.com/ethersphere/bee/pkg/swarm"
"github.com/ethersphere/bee/pkg/validator"
)
)
// TestContentAddressValidator checks that the validator evaluates correctly
// TestContentAddressValidator checks that the validator evaluates correctly
...
@@ -28,7 +28,7 @@ func TestContentAddressValidator(t *testing.T) {
...
@@ -28,7 +28,7 @@ func TestContentAddressValidator(t *testing.T) {
fooLength
:=
len
(
foo
)
fooLength
:=
len
(
foo
)
fooBytes
:=
make
([]
byte
,
8
+
fooLength
)
fooBytes
:=
make
([]
byte
,
8
+
fooLength
)
binary
.
LittleEndian
.
PutUint64
(
fooBytes
,
uint64
(
fooLength
))
binary
.
LittleEndian
.
PutUint64
(
fooBytes
,
uint64
(
fooLength
))
copy
(
fooBytes
[
8
:
],
[]
byte
(
foo
)
)
copy
(
fooBytes
[
8
:
],
foo
)
ch
:=
swarm
.
NewChunk
(
address
,
fooBytes
)
ch
:=
swarm
.
NewChunk
(
address
,
fooBytes
)
if
!
validator
.
Validate
(
ch
)
{
if
!
validator
.
Validate
(
ch
)
{
t
.
Fatalf
(
"data '%s' should have validated to hash '%s'"
,
ch
.
Data
(),
ch
.
Address
())
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