本文整理匯總了Golang中certcomp/comp.C.Use方法的典型用法代碼示例。如果您正苦於以下問題:Golang C.Use方法的具體用法?Golang C.Use怎麽用?Golang C.Use使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類certcomp/comp.C
的用法示例。
在下文中一共展示了C.Use方法的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
}
示例2: 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]
}
示例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)
}
示例4: 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,
}
}
示例5: Index
func (l *LogEntry) Index(idx int32, c comp.C) *LogEntry {
c.Use(l)
if idx != 0 {
panic(idx)
}
return l
}
示例6: 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,
}
}
示例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
}
示例8: 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
}
示例9: 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
}
示例10: Count
func (t *LogTreap) Count(c comp.C) int32 {
if t == nil {
return 0
}
c.Use(t)
return t.Num
}
示例11: 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
}
示例12: 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
}
示例13: 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
}
示例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
}
示例15: CalculateTxnsImpl
func CalculateTxnsImpl(block *core.Block, c comp.C) bitrie.Bitrie {
if block == nil {
return bitrie.Nil
}
c.Use(block)
txns := CalculateTxns(block.Previous, c)
txns = ProcessBlock(block, txns, c)
return txns
}