Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
whqwjb
go-ethereum
提交
580145e9
G
go-ethereum
项目概览
whqwjb
/
go-ethereum
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
go-ethereum
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
580145e9
编写于
9月 06, 2018
作者:
E
Elad
提交者:
Balint Gabor
9月 06, 2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
swarm/storage: added metrics for db entry count (#17589)
上级
4c15ffff
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
25 addition
and
20 deletion
+25
-20
swarm/api/http/server_test.go
swarm/api/http/server_test.go
+19
-20
swarm/storage/ldbstore.go
swarm/storage/ldbstore.go
+6
-0
未找到文件。
swarm/api/http/server_test.go
浏览文件 @
580145e9
...
...
@@ -893,14 +893,14 @@ func TestMethodsNotAllowed(t *testing.T) {
}{
{
url
:
fmt
.
Sprintf
(
"%s/bzz-list:/"
,
srv
.
URL
),
code
:
405
,
code
:
http
.
StatusMethodNotAllowed
,
},
{
url
:
fmt
.
Sprintf
(
"%s/bzz-hash:/"
,
srv
.
URL
),
code
:
405
,
code
:
http
.
StatusMethodNotAllowed
,
},
{
url
:
fmt
.
Sprintf
(
"%s/bzz-immutable:/"
,
srv
.
URL
),
code
:
405
,
code
:
http
.
StatusMethodNotAllowed
,
},
}
{
res
,
_
:=
http
.
Post
(
c
.
url
,
"text/plain"
,
bytes
.
NewReader
([]
byte
(
databytes
)))
...
...
@@ -958,7 +958,7 @@ func TestGet(t *testing.T) {
uri
:
fmt
.
Sprintf
(
"%s/"
,
srv
.
URL
),
method
:
"GET"
,
headers
:
map
[
string
]
string
{
"Accept"
:
"text/html"
},
expectedStatusCode
:
200
,
expectedStatusCode
:
http
.
StatusOK
,
assertResponseBody
:
"Swarm: Serverless Hosting Incentivised Peer-To-Peer Storage And Content Distribution"
,
verbose
:
false
,
},
...
...
@@ -966,7 +966,7 @@ func TestGet(t *testing.T) {
uri
:
fmt
.
Sprintf
(
"%s/"
,
srv
.
URL
),
method
:
"GET"
,
headers
:
map
[
string
]
string
{
"Accept"
:
"application/json"
},
expectedStatusCode
:
200
,
expectedStatusCode
:
http
.
StatusOK
,
assertResponseBody
:
"Swarm: Please request a valid ENS or swarm hash with the appropriate bzz scheme"
,
verbose
:
false
,
},
...
...
@@ -974,7 +974,7 @@ func TestGet(t *testing.T) {
uri
:
fmt
.
Sprintf
(
"%s/robots.txt"
,
srv
.
URL
),
method
:
"GET"
,
headers
:
map
[
string
]
string
{
"Accept"
:
"text/html"
},
expectedStatusCode
:
200
,
expectedStatusCode
:
http
.
StatusOK
,
assertResponseBody
:
"User-agent: *
\n
Disallow: /"
,
verbose
:
false
,
},
...
...
@@ -982,38 +982,37 @@ func TestGet(t *testing.T) {
uri
:
fmt
.
Sprintf
(
"%s/nonexistent_path"
,
srv
.
URL
),
method
:
"GET"
,
headers
:
map
[
string
]
string
{},
expectedStatusCode
:
404
,
expectedStatusCode
:
http
.
StatusNotFound
,
verbose
:
false
,
},
{
uri
:
fmt
.
Sprintf
(
"%s/bzz:asdf/"
,
srv
.
URL
),
method
:
"GET"
,
headers
:
map
[
string
]
string
{},
expectedStatusCode
:
404
,
expectedStatusCode
:
http
.
StatusNotFound
,
verbose
:
false
,
},
{
uri
:
fmt
.
Sprintf
(
"%s/tbz2/"
,
srv
.
URL
),
method
:
"GET"
,
headers
:
map
[
string
]
string
{},
expectedStatusCode
:
404
,
expectedStatusCode
:
http
.
StatusNotFound
,
verbose
:
false
,
},
{
uri
:
fmt
.
Sprintf
(
"%s/bzz-rack:/"
,
srv
.
URL
),
method
:
"GET"
,
headers
:
map
[
string
]
string
{},
expectedStatusCode
:
404
,
expectedStatusCode
:
http
.
StatusNotFound
,
verbose
:
false
,
},
{
uri
:
fmt
.
Sprintf
(
"%s/bzz-ls"
,
srv
.
URL
),
method
:
"GET"
,
headers
:
map
[
string
]
string
{},
expectedStatusCode
:
404
,
expectedStatusCode
:
http
.
StatusNotFound
,
verbose
:
false
,
},
}
{
}}
{
t
.
Run
(
"GET "
+
testCase
.
uri
,
func
(
t
*
testing
.
T
)
{
res
,
body
:=
httpDo
(
testCase
.
method
,
testCase
.
uri
,
nil
,
testCase
.
headers
,
testCase
.
verbose
,
t
)
if
res
.
StatusCode
!=
testCase
.
expectedStatusCode
{
...
...
@@ -1060,7 +1059,7 @@ func TestModify(t *testing.T) {
uri
:
fmt
.
Sprintf
(
"%s/bzz:/%s"
,
srv
.
URL
,
hash
),
method
:
"DELETE"
,
headers
:
map
[
string
]
string
{},
expectedStatusCode
:
200
,
expectedStatusCode
:
http
.
StatusOK
,
assertResponseBody
:
"8b634aea26eec353ac0ecbec20c94f44d6f8d11f38d4578a4c207a84c74ef731"
,
verbose
:
false
,
},
...
...
@@ -1068,21 +1067,21 @@ func TestModify(t *testing.T) {
uri
:
fmt
.
Sprintf
(
"%s/bzz:/%s"
,
srv
.
URL
,
hash
),
method
:
"PUT"
,
headers
:
map
[
string
]
string
{},
expectedStatusCode
:
405
,
expectedStatusCode
:
http
.
StatusMethodNotAllowed
,
verbose
:
false
,
},
{
uri
:
fmt
.
Sprintf
(
"%s/bzz-raw:/%s"
,
srv
.
URL
,
hash
),
method
:
"PUT"
,
headers
:
map
[
string
]
string
{},
expectedStatusCode
:
405
,
expectedStatusCode
:
http
.
StatusMethodNotAllowed
,
verbose
:
false
,
},
{
uri
:
fmt
.
Sprintf
(
"%s/bzz:/%s"
,
srv
.
URL
,
hash
),
method
:
"PATCH"
,
headers
:
map
[
string
]
string
{},
expectedStatusCode
:
405
,
expectedStatusCode
:
http
.
StatusMethodNotAllowed
,
verbose
:
false
,
},
{
...
...
@@ -1090,7 +1089,7 @@ func TestModify(t *testing.T) {
method
:
"POST"
,
headers
:
map
[
string
]
string
{},
requestBody
:
[]
byte
(
"POSTdata"
),
expectedStatusCode
:
200
,
expectedStatusCode
:
http
.
StatusOK
,
assertResponseHeaders
:
map
[
string
]
string
{
"Content-Length"
:
"64"
},
verbose
:
false
,
},
...
...
@@ -1099,7 +1098,7 @@ func TestModify(t *testing.T) {
method
:
"POST"
,
headers
:
map
[
string
]
string
{},
requestBody
:
[]
byte
(
"POSTdata"
),
expectedStatusCode
:
200
,
expectedStatusCode
:
http
.
StatusOK
,
assertResponseHeaders
:
map
[
string
]
string
{
"Content-Length"
:
"128"
},
verbose
:
false
,
},
...
...
@@ -1148,7 +1147,7 @@ func TestMultiPartUpload(t *testing.T) {
}
res
,
body
:=
httpDo
(
"POST"
,
url
,
buf
,
headers
,
verbose
,
t
)
if
res
.
StatusCode
!=
200
{
if
res
.
StatusCode
!=
http
.
StatusOK
{
t
.
Fatalf
(
"expected POST multipart/form-data to return 200, but it returned %d"
,
res
.
StatusCode
)
}
if
len
(
body
)
!=
64
{
...
...
swarm/storage/ldbstore.go
浏览文件 @
580145e9
...
...
@@ -48,6 +48,10 @@ const (
maxGCitems
=
5000
// max number of items to be gc'd per call to collectGarbage()
)
var
(
dbEntryCount
=
metrics
.
NewRegisteredCounter
(
"ldbstore.entryCnt"
,
nil
)
)
var
(
keyIndex
=
byte
(
0
)
keyOldData
=
byte
(
1
)
...
...
@@ -495,6 +499,7 @@ func (s *LDBStore) delete(idx uint64, idxKey []byte, po uint8) {
batch
.
Delete
(
idxKey
)
batch
.
Delete
(
getDataKey
(
idx
,
po
))
s
.
entryCnt
--
dbEntryCount
.
Dec
(
1
)
s
.
bucketCnt
[
po
]
--
cntKey
:=
make
([]
byte
,
2
)
cntKey
[
0
]
=
keyDistanceCnt
...
...
@@ -566,6 +571,7 @@ func (s *LDBStore) doPut(chunk *Chunk, index *dpaDBIndex, po uint8) {
index
.
Idx
=
s
.
dataIdx
s
.
bucketCnt
[
po
]
=
s
.
dataIdx
s
.
entryCnt
++
dbEntryCount
.
Inc
(
1
)
s
.
dataIdx
++
cntKey
:=
make
([]
byte
,
2
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录