當前位置: 首頁>>代碼示例>>Golang>>正文


Golang comp.C類代碼示例

本文整理匯總了Golang中certcomp/comp.C的典型用法代碼示例。如果您正苦於以下問題:Golang C類的具體用法?Golang C怎麽用?Golang C使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了C類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: Slice

func (t *LogTreap) Slice(start, end int32, c comp.C) *seqhash.Hash {
	if t == nil {
		return new(seqhash.Hash)
	}

	c.Use(t)

	if start <= 0 && end >= t.Num {
		return t.SeqHash(c)
	}

	leftCount := t.Left.Count(c)

	h := new(seqhash.Hash)
	if start < leftCount {
		h = seqhash.Merge(h, t.Left.Slice(start, end, c), c)
	}
	if start <= leftCount && end >= leftCount+1 {
		h = seqhash.Merge(h, seqhash.New(t.Value), c)
	}
	if end > leftCount+1 {
		h = seqhash.Merge(h, t.Right.Slice(start-leftCount-1, end-leftCount-1, c), c)
	}
	return h
}
開發者ID:Roasbeef,項目名稱:versum,代碼行數:25,代碼來源:log.go

示例2: Set

func (l *BitrieLeaf) Set(b Bits, value ads.ADS, c comp.C) Bitrie {
	c.Use(l)

	s := SplitPoint(l.Bits, b)

	if s == b.Length {
		return &BitrieLeaf{
			Bits:  b,
			Value: value,
		}
	}

	left := &BitrieLeaf{
		Bits:  b.Cut(s+1, b.Length),
		Value: value,
	}
	right := &BitrieLeaf{
		Bits:  l.Bits.Cut(s+1, l.Bits.Length),
		Value: l.Value,
	}

	if b.Get(s) != 0 {
		left, right = right, left
	}

	return &BitrieNode{
		Bits:  b.Cut(0, s),
		Left:  left,
		Right: right,
	}
}
開發者ID:Roasbeef,項目名稱:versum,代碼行數:31,代碼來源:bitrie.go

示例3: ProcessTransactionImpl

func ProcessTransactionImpl(transaction *Transaction, balances bitrie.Bitrie, c comp.C) bitrie.Bitrie {
	c.Use(transaction, balances)

	for _, input := range transaction.MsgTx.TxIn {
		if (input.PreviousOutpoint.Hash == btcwire.ShaHash{}) {
			continue
		}

		balances = ProcessOutpoint(input.PreviousOutpoint, balances, c)
	}

	loc := bitrie.MakeBits(ads.Hash(transaction))
	x, found := balances.Get(loc, c)
	var oi *OutpointInfo
	if found {
		oi = x.(*OutpointInfo)
	} else {
		oi = &OutpointInfo{}
	}

	c.Use(oi)

	oi = oi.Add(len(transaction.MsgTx.TxOut))
	return balances.Set(loc, oi, c)
}
開發者ID:Roasbeef,項目名稱:versum,代碼行數:25,代碼來源:balances.go

示例4: Finish

func (h *Hash) Finish(c comp.C) Hashable {
	c.Use(h)

	if h.Empty() {
		return nil
	}

	left := make([]Hashable, 0)
	right := make([]Hashable, 0)

	for i := int8(0); i < h.Height; i++ {
		left = append(left, h.LeftFringes[i]...)
		right = append(h.RightFringes[i], right...)

		left = doRound(left, false, false, c).center
		right = doRound(right, false, false, c).center
	}

	elems := append(append(left, h.Top...), right...)
	for len(elems) > 1 {
		elems = doRound(elems, false, false, c).center
	}

	return elems[0]
}
開發者ID:Roasbeef,項目名稱:versum,代碼行數:25,代碼來源:hash.go

示例5: CombineTree

func CombineTree(left, right LogTree, c comp.C) *LogTreeNode {
	c.Use(left, right)
	return &LogTreeNode{
		Num:   left.Count() + right.Count(),
		Left:  left,
		Right: right,
	}
}
開發者ID:Roasbeef,項目名稱:versum,代碼行數:8,代碼來源:log.go

示例6: Index

func (l *LogEntry) Index(idx int32, c comp.C) *LogEntry {
	c.Use(l)

	if idx != 0 {
		panic(idx)
	}
	return l
}
開發者ID:Roasbeef,項目名稱:versum,代碼行數:8,代碼來源:log.go

示例7: ProcessBlock

func ProcessBlock(block *core.Block, txns, regs bitrie.Bitrie, c comp.C) (bitrie.Bitrie, bitrie.Bitrie) {
	c.Use(block)

	for _, txn := range block.Transactions {
		txns, regs = ProcessTxn(txn.(*core.Transaction), txns, regs, c)
	}

	return txns, regs
}
開發者ID:Roasbeef,項目名稱:versum,代碼行數:9,代碼來源:namereg.go

示例8: Count

func (t *LogTreap) Count(c comp.C) int32 {
	if t == nil {
		return 0
	}

	c.Use(t)

	return t.Num
}
開發者ID:Roasbeef,項目名稱:versum,代碼行數:9,代碼來源:log.go

示例9: ProcessTxnImpl

func ProcessTxnImpl(txn *core.Transaction, txns bitrie.Bitrie, c comp.C) bitrie.Bitrie {
	c.Use(txn)

	for _, output := range txn.MsgTx.TxOut {
		txns = ProcessOutput(txn, output, txns, c)
	}

	return txns
}
開發者ID:Roasbeef,項目名稱:versum,代碼行數:9,代碼來源:transactions.go

示例10: ProcessBlock

func ProcessBlock(block *Block, balances bitrie.Bitrie, c comp.C) bitrie.Bitrie {
	c.Use(block)

	for _, transaction := range block.Transactions {
		balances = ProcessTransaction(transaction.(*Transaction), balances, c)
	}

	return balances
}
開發者ID:Roasbeef,項目名稱:versum,代碼行數:9,代碼來源:balances.go

示例11: Delete

func (l *BitrieLeaf) Delete(b Bits, c comp.C) Bitrie {
	c.Use(l)

	if SplitPoint(l.Bits, b) < l.Bits.Length {
		return l
	}

	return Nil
}
開發者ID:Roasbeef,項目名稱:versum,代碼行數:9,代碼來源:bitrie.go

示例12: Get

func (l *BitrieLeaf) Get(b Bits, c comp.C) (ads.ADS, bool) {
	c.Use(l)

	s := SplitPoint(l.Bits, b)

	if s == b.Length {
		return l.Value, true
	}
	return nil, false
}
開發者ID:Roasbeef,項目名稱:versum,代碼行數:10,代碼來源:bitrie.go

示例13: CalculateRegsImpl

func CalculateRegsImpl(block *core.Block, c comp.C) (bitrie.Bitrie, bitrie.Bitrie) {
	if block == nil {
		return bitrie.Nil, bitrie.Nil
	}

	c.Use(block)
	txns, regs := CalculateRegs(block.Previous, c)
	txns, regs = ProcessBlock(block, txns, regs, c)
	return txns, regs
}
開發者ID:Roasbeef,項目名稱:versum,代碼行數:10,代碼來源:namereg.go

示例14: ProcessTxnImpl

func ProcessTxnImpl(txn *core.Transaction, txns, regs bitrie.Bitrie, c comp.C) (bitrie.Bitrie, bitrie.Bitrie) {
	c.Use(txn)

	txns = txns.Set(bitrie.MakeBits(txn.ComputeHash()), txn, c)

	if len(txn.MsgTx.TxOut) != 1 {
		return txns, regs
	}

	script := txn.MsgTx.TxOut[0].PkScript
	if len(script) < 1 || script[0] != btcscript.OP_RETURN {
		return txns, regs
	}

	data := script[1:]
	if len(data) != 40 {
		return txns, regs
	}

	if !bytes.Equal(data[0:8], tag) {
		return txns, regs
	}

	loc := bitrie.MakeBits(sha.Sum(data[8:40]))

	ads, found := regs.Get(loc, c)
	claim := ads.(*Claim)

	// two types of txns: register and transfer
	if len(txn.MsgTx.TxIn) == 1 {
		if found {
			return txns, regs
		}

		key := GetKey(txns, txn.MsgTx.TxIn[0].PreviousOutpoint, c)
		regs = regs.Set(loc, &Claim{Key: key}, c)
	}

	if len(txn.MsgTx.TxIn) == 2 {
		if !found {
			return txns, regs
		}

		from := GetKey(txns, txn.MsgTx.TxIn[0].PreviousOutpoint, c)

		if !bytes.Equal(from, claim.Key) {
			return txns, regs
		}

		to := GetKey(txns, txn.MsgTx.TxIn[1].PreviousOutpoint, c)
		regs = regs.Set(loc, &Claim{Key: to}, c)
	}

	return txns, regs
}
開發者ID:Roasbeef,項目名稱:versum,代碼行數:55,代碼來源:namereg.go

示例15: CalculateBalancesImpl

func CalculateBalancesImpl(block *Block, c comp.C) bitrie.Bitrie {
	if block == nil {
		return bitrie.Nil
	}

	c.Use(block)
	balances := CalculateBalances(block.Previous, c)
	balances = ProcessBlock(block, balances, c)

	return balances
}
開發者ID:Roasbeef,項目名稱:versum,代碼行數:11,代碼來源:balances.go


注:本文中的certcomp/comp.C類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。