github.com/keltia/go-ipfs@v0.3.8-0.20150909044612-210793031c63/blocks/blocksutil/block_generator.go (about) 1 package blocksutil 2 3 import "github.com/ipfs/go-ipfs/blocks" 4 5 func NewBlockGenerator() BlockGenerator { 6 return BlockGenerator{} 7 } 8 9 type BlockGenerator struct { 10 seq int 11 } 12 13 func (bg *BlockGenerator) Next() *blocks.Block { 14 bg.seq++ 15 return blocks.NewBlock([]byte(string(bg.seq))) 16 } 17 18 func (bg *BlockGenerator) Blocks(n int) []*blocks.Block { 19 blocks := make([]*blocks.Block, 0) 20 for i := 0; i < n; i++ { 21 b := bg.Next() 22 blocks = append(blocks, b) 23 } 24 return blocks 25 }