code: func CreateNextBlock(rl Reader, messages []*cb.Envelope) *cb.Block {
  	var nextBlockNumber uint64
  	var previousBlockHash []byte
  
  	if rl.Height() > 0 {
  		it, _ := rl.Iterator(&ab.SeekPosition{
  			Type: &ab.SeekPosition_Newest{
  				Newest: &ab.SeekNewest{},
  			},
  		})
  		block, status := it.Next()
  		if status != cb.Status_SUCCESS {
  			panic("Error seeking to newest block for chain with non-zero height")
  		}
  		nextBlockNumber = block.Header.Number + 1
  		previousBlockHash = block.Header.Hash()
  	}
  
  	data := &cb.BlockData{
  		Data: make([][]byte, len(messages)),
  	}
  
  	var err error
  	for i, msg := range messages {
  		data.Data[i], err = proto.Marshal(msg)
  		if err != nil {
  			panic(err)
  		}
  	}
  
  	block := cb.NewBlock(nextBlockNumber, previousBlockHash)
  	block.Header.DataHash = data.Hash()
  	block.Data = data
  
  	return block
  }
docs: // CreateNextBlock provides a utility way to construct the next block from
  // contents and metadata for a given ledger
  // XXX This will need to be modified to accept marshaled envelopes
  //     to accommodate non-deterministic marshaling