Skip to content

Commit

Permalink
Rename blocks.RawBlock to blocks.BasicBlock.
Browse files Browse the repository at this point in the history
License: MIT
Signed-off-by: Kevin Atkinson <k@kevina.org>
  • Loading branch information
kevina committed Jun 1, 2016
1 parent 92cc3f1 commit 1e01b02
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions blocks.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,47 +20,47 @@ type Block interface {
}

// Block is a singular block of data in ipfs
type RawBlock struct {
type BasicBlock struct {
multihash mh.Multihash
data []byte
}

// NewBlock creates a Block object from opaque data. It will hash the data.
func NewBlock(data []byte) *RawBlock {
return &RawBlock{data: data, multihash: u.Hash(data)}
func NewBlock(data []byte) *BasicBlock {
return &BasicBlock{data: data, multihash: u.Hash(data)}
}

// NewBlockWithHash creates a new block when the hash of the data
// is already known, this is used to save time in situations where
// we are able to be confident that the data is correct
func NewBlockWithHash(data []byte, h mh.Multihash) (*RawBlock, error) {
func NewBlockWithHash(data []byte, h mh.Multihash) (*BasicBlock, error) {
if u.Debug {
chk := u.Hash(data)
if string(chk) != string(h) {
return nil, errors.New("Data did not match given hash!")
}
}
return &RawBlock{data: data, multihash: h}, nil
return &BasicBlock{data: data, multihash: h}, nil
}

func (b *RawBlock) Multihash() mh.Multihash {
func (b *BasicBlock) Multihash() mh.Multihash {
return b.multihash
}

func (b *RawBlock) Data() []byte {
func (b *BasicBlock) Data() []byte {
return b.data
}

// Key returns the block's Multihash as a Key value.
func (b *RawBlock) Key() key.Key {
func (b *BasicBlock) Key() key.Key {
return key.Key(b.multihash)
}

func (b *RawBlock) String() string {
func (b *BasicBlock) String() string {
return fmt.Sprintf("[Block %s]", b.Key())
}

func (b *RawBlock) Loggable() map[string]interface{} {
func (b *BasicBlock) Loggable() map[string]interface{} {
return map[string]interface{}{
"block": b.Key().String(),
}
Expand Down

0 comments on commit 1e01b02

Please sign in to comment.