@cryptotaxi247 / kubo / commits / dbabcf968

Rename blocks.RawBlock to blocks.BasicBlock.

License: MIT Signed-off-by: Kevin Atkinson <k@kevina.org>

Kevin Atkinson committed May 5, 2016 at 23:24 UTC dbabcf968103ca21601dc29139256c56c306368e
1 file changed +10 -10
blocks/blocks.go
+10 -10
@@ -20,47 +20,47 @@ type Block interface {
20 }
21
22 // Block is a singular block of data in ipfs
23 -type RawBlock struct {
23 +type BasicBlock struct {
24 multihash mh.Multihash
25 data []byte
26 }
27
28 // NewBlock creates a Block object from opaque data. It will hash the data.
29 -func NewBlock(data []byte) *RawBlock {
30 - return &RawBlock{data: data, multihash: u.Hash(data)}
29 +func NewBlock(data []byte) *BasicBlock {
30 + return &BasicBlock{data: data, multihash: u.Hash(data)}
31 }
32
33 // NewBlockWithHash creates a new block when the hash of the data
34 // is already known, this is used to save time in situations where
35 // we are able to be confident that the data is correct
36 -func NewBlockWithHash(data []byte, h mh.Multihash) (*RawBlock, error) {
36 +func NewBlockWithHash(data []byte, h mh.Multihash) (*BasicBlock, error) {
37 if u.Debug {
38 chk := u.Hash(data)
39 if string(chk) != string(h) {
40 return nil, errors.New("Data did not match given hash!")
41 }
42 }
43 - return &RawBlock{data: data, multihash: h}, nil
43 + return &BasicBlock{data: data, multihash: h}, nil
44 }
45
46 -func (b *RawBlock) Multihash() mh.Multihash {
46 +func (b *BasicBlock) Multihash() mh.Multihash {
47 return b.multihash
48 }
49
50 -func (b *RawBlock) Data() []byte {
50 +func (b *BasicBlock) Data() []byte {
51 return b.data
52 }
53
54 // Key returns the block's Multihash as a Key value.
55 -func (b *RawBlock) Key() key.Key {
55 +func (b *BasicBlock) Key() key.Key {
56 return key.Key(b.multihash)
57 }
58
59 -func (b *RawBlock) String() string {
59 +func (b *BasicBlock) String() string {
60 return fmt.Sprintf("[Block %s]", b.Key())
61 }
62
63 -func (b *RawBlock) Loggable() map[string]interface{} {
63 +func (b *BasicBlock) Loggable() map[string]interface{} {
64 return map[string]interface{}{
65 "block": b.Key().String(),
66 }