Skip to content

Commit 0bd1b92

Browse files
committed
Add block interface for interoperability
1 parent e82c533 commit 0bd1b92

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

blocks.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,22 @@ import (
1616
// according to the contents. It is currently used only when debugging.
1717
var ErrWrongHash = errors.New("data did not match given hash")
1818

19+
// Interface provides abstraction for blocks implementations.
20+
type Interface interface {
21+
RawData() []byte
22+
Cid() cid.Cid
23+
String() string
24+
Loggable() map[string]interface{}
25+
}
26+
1927
// A Block is a singular block of data in ipfs. This is some bytes addressed by a hash.
2028
type Block struct {
2129
cid cid.Cid
2230
data []byte
2331
}
2432

33+
var _ Interface = Block{}
34+
2535
// NewBlock creates a Block object from opaque data. It will hash the data.
2636
func NewBlock(data []byte) Block {
2737
// TODO: fix assumptions

0 commit comments

Comments
 (0)