// NewBlockID constructs a new BlockID.
559461
func NewBlockID(hash *chainhash.Hash, height int64) *BlockID {
	return &BlockID{
		Hash:   *hash,
		Height: height,
	}
}
991272
func (sp *ServerPeer) newestBlock() (*chainhash.Hash, int32, error) {
	bestHeader, bestHeight, err := sp.server.BlockHeaders.ChainTip()
	if err != nil {
		return nil, 0, err
	}
	bestHash := bestHeader.BlockHash()
	return &bestHash, int32(bestHeight), nil
}
309128
func NewMutableID(body Mutable) (ID, error) {
	t := body.Type()
	return NewID(t)
}
903586
func NewFilteredBlock(channelID string, filteredTx ...*pb.FilteredTransaction) *pb.FilteredBlock {
	return &pb.FilteredBlock{
		ChannelId:            channelID,
		FilteredTransactions: filteredTx,
	}
}
566333
func NewNodeID(pub *btcec.PublicKey) NodeID {
	var n NodeID
	copy(n[:], pub.SerializeCompressed())
	return n
}
1138798
func (f *contextFactory) newId(name string) string {
	return fmt.Sprintf("%s-%s-%d", f.unit.Name(), name, f.rand.Int63())
}
257527
func NewActionBlock(blockID string, elements ...BlockElement) *ActionBlock {
	return &ActionBlock{
		Type:     mbtAction,
		BlockID:  blockID,
		Elements: elements,
	}
}
1331221
func (api *PublicFilterAPI) NewBlockFilter() rpc.ID {
	var (
		headers   = make(chan *types.Header)
		headerSub = api.events.SubscribeNewHeads(headers)
	)

	api.filtersMu.Lock()
	api.filters[headerSub.ID] = &filter{typ: BlocksSubscription, deadline: time.NewTimer(deadline), hashes: make([]common.Hash, 0), s: headerSub}
	api.filtersMu.Unlock()

	go func() {
		for {
			select {
			case h := <-headers:
				api.filtersMu.Lock()
				if f, found := api.filters[headerSub.ID]; found {
					f.hashes = append(f.hashes, h.Hash())
				}
				api.filtersMu.Unlock()
			case <-headerSub.Err():
				api.filtersMu.Lock()
				delete(api.filters, headerSub.ID)
				api.filtersMu.Unlock()
				return
			}
		}
	}()

	return headerSub.ID
}
837611
func NewBlockAttrs(name, elementType string, required bool) *Spec {
	return BlockAttrsSpec(&BlockAttrs{
		Name:     name,
		Required: required,
		Type:     elementType,
	})
}
115441
func NewID(t idtype.Type) (ID, error) {
	if !t.Mutable() {
		return ID{}, errors.New("Cannot generate ID for non-mutable type")
	}

	id := ID{idVersion<<4 | t.Upper(), t.Lower()}
	_, err := rand.Read(id[2:])
	if err != nil {
		return ID{}, err
	}

	return id, nil
}
638992
func NewBlockEvent(block *cb.Block, sourceURL string) *fab.BlockEvent {
	return &fab.BlockEvent{
		Block:     block,
		SourceURL: sourceURL,
	}
}
174614
func NewOverflowBlockElement(actionID string, options ...*OptionBlockObject) *OverflowBlockElement {
	return &OverflowBlockElement{
		Type:     metOverflow,
		ActionID: actionID,
		Options:  options,
	}
}
1044315
func NewBlock(name string, required bool, nested *Spec) *Spec {
	return BlockSpec(&Block{
		Name:     name,
		Required: required,
		Nested:   nested,
	})
}
1074114
func New(key []byte, t1 int) (cipher.Block, error) {
	if l := len(key); l == 0 || l > 128 {
		return nil, KeySizeError(l)
	}

	if t1 < 8 || t1 > 1024 {
		return nil, EffectiveKeySizeError(t1)
	}

	return &rc2Cipher{
		k: expandKey(key, t1),
	}, nil
}
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},
	}
}
582547
func NewHtmlId(tag, id string) HtmlId {
	if TestMode {
		return htmlIdImpl{
			tag:   tag,
			id:    id,
			t:     newTestOps(),
			cache: make(map[string]DomAttribute),
		}
	}
	jq := jquery.NewJQuery(tag + "#" + id)
	if jq.Length == 0 {
		panic(fmt.Sprintf("probably your HTML and your code are out of sync: %s not found", tag+"#"+id))
	}
	if jq.Length > 1 {
		panic(fmt.Sprintf("probably your HTML and your code are out of sync: %s not unique", tag+"#"+id))
	}
	return htmlIdImpl{
		tag:   tag,
		id:    id,
		t:     wrap(jq),
		cache: make(map[string]DomAttribute),
	}
}
758285
func NewID() string {
	buff := make([]byte, 16) // 128 bit random ID.
	if _, err := io.ReadFull(rand.Reader, buff); err != nil {
		panic(err)
	}
	// Avoid the identifier to begin with number and trim padding
	return string(buff[0]%26+'a') + strings.TrimRight(encoding.EncodeToString(buff[1:]), "=")
}