Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-merkledag
Commits
e40c4df3
Commit
e40c4df3
authored
Jul 21, 2015
by
Jeromy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
include hash of resolved object in object stat output
License: MIT Signed-off-by:
Jeromy
<
jeromyj@gmail.com
>
parent
b8c16c5a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
1 deletion
+15
-1
merkledag_test.go
merkledag_test.go
+8
-1
node.go
node.go
+7
-0
No files found.
merkledag_test.go
View file @
e40c4df3
...
@@ -109,12 +109,19 @@ func SubtestNodeStat(t *testing.T, n *Node) {
...
@@ -109,12 +109,19 @@ func SubtestNodeStat(t *testing.T, n *Node) {
return
return
}
}
k
,
err
:=
n
.
Key
()
if
err
!=
nil
{
t
.
Error
(
"n.Key() failed"
)
return
}
expected
:=
NodeStat
{
expected
:=
NodeStat
{
NumLinks
:
len
(
n
.
Links
),
NumLinks
:
len
(
n
.
Links
),
BlockSize
:
len
(
enc
),
BlockSize
:
len
(
enc
),
LinksSize
:
len
(
enc
)
-
len
(
n
.
Data
),
// includes framing.
LinksSize
:
len
(
enc
)
-
len
(
n
.
Data
),
// includes framing.
DataSize
:
len
(
n
.
Data
),
DataSize
:
len
(
n
.
Data
),
CumulativeSize
:
int
(
cumSize
),
CumulativeSize
:
int
(
cumSize
),
Hash
:
k
.
B58String
(),
}
}
actual
,
err
:=
n
.
Stat
()
actual
,
err
:=
n
.
Stat
()
...
@@ -124,7 +131,7 @@ func SubtestNodeStat(t *testing.T, n *Node) {
...
@@ -124,7 +131,7 @@ func SubtestNodeStat(t *testing.T, n *Node) {
}
}
if
expected
!=
*
actual
{
if
expected
!=
*
actual
{
t
.
Error
(
"n.Stat incorrect.
\n
expect: %s
\n
actual: %s"
,
expected
,
actual
)
t
.
Error
f
(
"n.Stat incorrect.
\n
expect: %s
\n
actual: %s"
,
expected
,
actual
)
}
else
{
}
else
{
fmt
.
Printf
(
"n.Stat correct: %s
\n
"
,
actual
)
fmt
.
Printf
(
"n.Stat correct: %s
\n
"
,
actual
)
}
}
...
...
node.go
View file @
e40c4df3
...
@@ -23,6 +23,7 @@ type Node struct {
...
@@ -23,6 +23,7 @@ type Node struct {
// NodeStat is a statistics object for a Node. Mostly sizes.
// NodeStat is a statistics object for a Node. Mostly sizes.
type
NodeStat
struct
{
type
NodeStat
struct
{
Hash
string
NumLinks
int
// number of links in link table
NumLinks
int
// number of links in link table
BlockSize
int
// size of the raw, encoded data
BlockSize
int
// size of the raw, encoded data
LinksSize
int
// size of the links segment
LinksSize
int
// size of the links segment
...
@@ -201,7 +202,13 @@ func (n *Node) Stat() (*NodeStat, error) {
...
@@ -201,7 +202,13 @@ func (n *Node) Stat() (*NodeStat, error) {
return
nil
,
err
return
nil
,
err
}
}
key
,
err
:=
n
.
Key
()
if
err
!=
nil
{
return
nil
,
err
}
return
&
NodeStat
{
return
&
NodeStat
{
Hash
:
key
.
B58String
(),
NumLinks
:
len
(
n
.
Links
),
NumLinks
:
len
(
n
.
Links
),
BlockSize
:
len
(
enc
),
BlockSize
:
len
(
enc
),
LinksSize
:
len
(
enc
)
-
len
(
n
.
Data
),
// includes framing.
LinksSize
:
len
(
enc
)
-
len
(
n
.
Data
),
// includes framing.
...
...
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