mirror of
https://github.com/ipfs/kubo.git
synced 2025-06-27 16:07:42 +08:00
Merge pull request #1505 from ipfs/object-stat-hash
include hash of resolved object in object stat output
This commit is contained in:
@ -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) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if expected != *actual {
|
if expected != *actual {
|
||||||
t.Error("n.Stat incorrect.\nexpect: %s\nactual: %s", expected, actual)
|
t.Errorf("n.Stat incorrect.\nexpect: %s\nactual: %s", expected, actual)
|
||||||
} else {
|
} else {
|
||||||
fmt.Printf("n.Stat correct: %s\n", actual)
|
fmt.Printf("n.Stat correct: %s\n", actual)
|
||||||
}
|
}
|
||||||
|
@ -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) {
|
|||||||
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.
|
||||||
|
Reference in New Issue
Block a user