// CreateNextBlock creates a simple block structure with the given data
517667
func (mcs *ConsenterSupport) CreateNextBlock(data []*cb.Envelope) *cb.Block {
	block := cb.NewBlock(0, nil)
	mtxs := make([][]byte, len(data))
	for i := range data {
		mtxs[i] = utils.MarshalOrPanic(data[i])
	}
	block.Data = &cb.BlockData{Data: mtxs}
	mcs.NextBlockVal = block
	return block
}
623681
func NewImageBlock(imageURL, altText, blockID string, title *TextBlockObject) *ImageBlock {
	return &ImageBlock{
		Type:     mbtImage,
		ImageURL: imageURL,
		AltText:  altText,
		BlockID:  blockID,
		Title:    title,
	}
}
454487
func NewBlockFromBytes(serializedBlock []byte) (*Block, error) {
	br := bytes.NewReader(serializedBlock)
	b, err := NewBlockFromReader(br)
	if err != nil {
		return nil, err
	}
	b.serializedBlock = serializedBlock
	return b, nil
}
25172
func (s *ListObjectsOutput) SetNextMarker(v string) *ListObjectsOutput {
	s.NextMarker = &v
	return s
}
149542
func UpdateBlockNextByHash(db SqlExecutor, this, next string) error {
	res, err := db.Exec(internal.UpdateBlockNextByHash, this, next)
	if err != nil {
		return err
	}
	numRows, err := res.RowsAffected()
	if err != nil {
		return err
	}
	if numRows != 1 {
		return fmt.Errorf("%s (%d)", notOneRowErrMsg, numRows)
	}
	return nil
}
2578
func (br *BlockReader) connectNext() error {
	address := br.datanodes.next()

	if br.DialFunc == nil {
		br.DialFunc = (&net.Dialer{}).DialContext
	}

	conn, err := br.DialFunc(context.Background(), "tcp", address)
	if err != nil {
		return err
	}

	err = br.writeBlockReadRequest(conn)
	if err != nil {
		return err
	}

	resp, err := readBlockOpResponse(conn)
	if err != nil {
		return err
	} else if resp.GetStatus() != hdfs.Status_SUCCESS {
		return fmt.Errorf("read failed: %s (%s)", resp.GetStatus().String(), resp.GetMessage())
	}

	readInfo := resp.GetReadOpChecksumInfo()
	checksumInfo := readInfo.GetChecksum()

	var checksumTab *crc32.Table
	checksumType := checksumInfo.GetType()
	switch checksumType {
	case hdfs.ChecksumTypeProto_CHECKSUM_CRC32:
		checksumTab = crc32.IEEETable
	case hdfs.ChecksumTypeProto_CHECKSUM_CRC32C:
		checksumTab = crc32.MakeTable(crc32.Castagnoli)
	default:
		return fmt.Errorf("unsupported checksum type: %d", checksumType)
	}

	chunkSize := int(checksumInfo.GetBytesPerChecksum())
	stream := newBlockReadStream(conn, chunkSize, checksumTab)

	// The read will start aligned to a chunk boundary, so we need to seek forward
	// to the requested offset.
	amountToDiscard := br.Offset - int64(readInfo.GetChunkOffset())
	if amountToDiscard > 0 {
		_, err := io.CopyN(ioutil.Discard, stream, amountToDiscard)
		if err != nil {
			if err == io.EOF {
				err = io.ErrUnexpectedEOF
			}

			conn.Close()
			return err
		}
	}

	br.stream = stream
	br.conn = conn
	err = br.conn.SetDeadline(br.deadline)
	if err != nil {
		return err
	}

	return nil
}
387520
func (s *ListGrantsResponse) SetNextMarker(v string) *ListGrantsResponse {
	s.NextMarker = &v
	return s
}
1016111
func NewBlock(tags core.TagSlice) (*Block, error) {
	block := new(Block)

	block.Init(map[int]core.TypeParser{
		1:  core.NewStringTypeParserToVar(&block.XrefPathName),
		2:  core.NewStringTypeParserToVar(&block.Name),
		3:  core.NewStringTypeParserToVar(&block.SecondName),
		4:  core.NewStringTypeParserToVar(&block.Description),
		5:  core.NewStringTypeParserToVar(&block.Handle),
		8:  core.NewStringTypeParserToVar(&block.LayerName),
		10: core.NewFloatTypeParserToVar(&block.BasePoint.X),
		20: core.NewFloatTypeParserToVar(&block.BasePoint.Y),
		30: core.NewFloatTypeParserToVar(&block.BasePoint.Z),
	})

	err := block.Parse(tags)
	return block, err
}
1026235
func UpdateBlockNextByNextHash(db SqlExecutor, currentNext, newNext string) error {
	res, err := db.Exec(internal.UpdateBlockNextByNextHash, currentNext, newNext)
	if err != nil {
		return err
	}
	numRows, err := res.RowsAffected()
	if err != nil {
		return err
	}
	if numRows != 1 {
		return fmt.Errorf("%s (%d)", notOneRowErrMsg, numRows)
	}
	return nil
}
790794
func blockUntilNextLog(ctx context.Context, fs allocdir.AllocDirFS, logPath, task, logType string, nextIndex int64) chan error {
	nextPath := filepath.Join(logPath, fmt.Sprintf("%s.%s.%d", task, logType, nextIndex))
	next := make(chan error, 1)

	go func() {
		eofCancelCh, err := fs.BlockUntilExists(ctx, nextPath)
		if err != nil {
			next <- err
			close(next)
			return
		}

		ticker := time.NewTicker(nextLogCheckRate)
		defer ticker.Stop()
		scanCh := ticker.C
		for {
			select {
			case <-ctx.Done():
				next <- nil
				close(next)
				return
			case err := <-eofCancelCh:
				next <- err
				close(next)
				return
			case <-scanCh:
				entries, err := fs.List(logPath)
				if err != nil {
					next <- fmt.Errorf("failed to list entries: %v", err)
					close(next)
					return
				}

				indexes, err := logIndexes(entries, task, logType)
				if err != nil {
					next <- err
					close(next)
					return
				}

				// Scan and see if there are any entries larger than what we are
				// waiting for.
				for _, entry := range indexes {
					if entry.idx >= nextIndex {
						next <- nil
						close(next)
						return
					}
				}
			}
		}
	}()

	return next
}
1206047
func NewBlock(channelID string, transactions ...*TxInfo) *cb.Block {
	var data [][]byte
	txValidationFlags := make([]uint8, len(transactions))
	for i, txInfo := range transactions {
		envBytes, err := proto.Marshal(newEnvelope(channelID, txInfo))
		if err != nil {
			panic(err)
		}
		data = append(data, envBytes)
		txValidationFlags[i] = uint8(txInfo.TxValidationCode)
	}

	blockMetaData := make([][]byte, 4)
	blockMetaData[cb.BlockMetadataIndex_TRANSACTIONS_FILTER] = txValidationFlags

	return &cb.Block{
		Header:   &cb.BlockHeader{},
		Metadata: &cb.BlockMetadata{Metadata: blockMetaData},
		Data:     &cb.BlockData{Data: data},
	}
}
544929
func (s *DescribeFileSystemsOutput) SetNextMarker(v string) *DescribeFileSystemsOutput {
	s.NextMarker = &v
	return s
}
1057613
func CreateBlockWithCCEventAndTxStatus(events *pp.ChaincodeEvent, txID string,
	channelID string, txValidationCode pp.TxValidationCode) (*common.Block, error) {
	chdr := &common.ChannelHeader{
		Type:    int32(common.HeaderType_ENDORSER_TRANSACTION),
		Version: 1,
		Timestamp: &timestamp.Timestamp{
			Seconds: time.Now().Unix(),
			Nanos:   0,
		},
		ChannelId: channelID,
		TxId:      txID}
	hdr := &common.Header{ChannelHeader: protoutil.MarshalOrPanic(chdr)}
	payload := &common.Payload{Header: hdr}
	cea := &pp.ChaincodeEndorsedAction{}
	ccaPayload := &pp.ChaincodeActionPayload{Action: cea}
	env := &common.Envelope{}
	taa := &pp.TransactionAction{}
	taas := make([]*pp.TransactionAction, 1)
	taas[0] = taa
	tx := &pp.Transaction{Actions: taas}

	pHashBytes := []byte("proposal_hash")
	pResponse := &pp.Response{Status: 200}
	results := []byte("results")
	eventBytes, err := protoutil.GetBytesChaincodeEvent(events)
	if err != nil {
		return nil, err
	}
	ccaPayload.Action.ProposalResponsePayload, err = protoutil.GetBytesProposalResponsePayload(pHashBytes, pResponse, results, eventBytes, nil)
	if err != nil {
		return nil, err
	}
	tx.Actions[0].Payload, err = protoutil.GetBytesChaincodeActionPayload(ccaPayload)
	if err != nil {
		return nil, err
	}
	payload.Data, err = protoutil.GetBytesTransaction(tx)
	if err != nil {
		return nil, err
	}
	env.Payload, err = protoutil.GetBytesPayload(payload)
	if err != nil {
		return nil, err
	}
	ebytes, err := protoutil.GetBytesEnvelope(env)
	if err != nil {
		return nil, err
	}

	block := newBlock(1, []byte{})
	block.Data.Data = append(block.Data.Data, ebytes)

	blockbytes := cutil.ConcatenateBytes(block.Data.Data...)
	block.Header.DataHash = computeSHA256(blockbytes)

	txsfltr := ledger_util.NewTxValidationFlags(len(block.Data.Data))
	for i := 0; i < len(block.Data.Data); i++ {
		txsfltr[i] = uint8(txValidationCode)
	}

	block.Metadata.Metadata[common.BlockMetadataIndex_TRANSACTIONS_FILTER] = txsfltr

	return block, nil
}
417728
func (s *ListFileSharesOutput) SetNextMarker(v string) *ListFileSharesOutput {
	s.NextMarker = &v
	return s
}
187147
func UpdateBlockNext(db SqlExecutor, blockDbID uint64, next string) error {
	res, err := db.Exec(internal.UpdateBlockNext, blockDbID, next)
	if err != nil {
		return err
	}
	numRows, err := res.RowsAffected()
	if err != nil {
		return err
	}
	if numRows != 1 {
		return fmt.Errorf("%s (%d)", notOneRowErrMsg, numRows)
	}
	return nil
}
693630
func (s *DeviceRegistryEnrichActivity) SetNext(v string) *DeviceRegistryEnrichActivity {
	s.Next = &v
	return s
}
1064002
func (s *ListResourceTagsOutput) SetNextMarker(v string) *ListResourceTagsOutput {
	s.NextMarker = &v
	return s
}