Commit 0b506293 authored by Juan Batiz-Benet's avatar Juan Batiz-Benet

block get returned.

parent 1832342c
......@@ -39,9 +39,10 @@ func NewBlockService(d ds.Datastore) (*BlockService, error) {
return &BlockService{Datastore: d}, nil
}
func (s *BlockService) AddBlock(b *Block) error {
dsk := ds.NewKey(string(b.Key()))
return s.Datastore.Put(dsk, b.Data)
func (s *BlockService) AddBlock(b *Block) (u.Key, error) {
k := b.Key()
dsk := ds.NewKey(string(k))
return k, s.Datastore.Put(dsk, b.Data)
}
func (s *BlockService) GetBlock(k u.Key) (*Block, error) {
......
......@@ -37,12 +37,16 @@ func TestBlocks(t *testing.T) {
t.Error("Block key and data multihash key not equal")
}
err = bs.AddBlock(b)
k, err := bs.AddBlock(b)
if err != nil {
t.Error("failed to add block to BlockService", err)
return
}
if k != b.Key() {
t.Error("returned key is not equal to block key", err)
}
b2, err := bs.GetBlock(b.Key())
if err != nil {
t.Error("failed to retrieve block from BlockService", err)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment