本文整理汇总了Golang中github.com/shiftcurrency/shift/core/types.Block.Bloom方法的典型用法代码示例。如果您正苦于以下问题:Golang Block.Bloom方法的具体用法?Golang Block.Bloom怎么用?Golang Block.Bloom使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/shiftcurrency/shift/core/types.Block
的用法示例。
在下文中一共展示了Block.Bloom方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: bloomFilter
func (self *Filter) bloomFilter(block *types.Block) bool {
if len(self.address) > 0 {
var included bool
for _, addr := range self.address {
if types.BloomLookup(block.Bloom(), addr) {
included = true
break
}
}
if !included {
return false
}
}
for _, sub := range self.topics {
var included bool
for _, topic := range sub {
if (topic == common.Hash{}) || types.BloomLookup(block.Bloom(), topic) {
included = true
break
}
}
if !included {
return false
}
}
return true
}
示例2: NewBlock
// Creates a new QML Block from a chain block
func NewBlock(block *types.Block) *Block {
if block == nil {
return &Block{}
}
ptxs := make([]*Transaction, len(block.Transactions()))
/*
for i, tx := range block.Transactions() {
ptxs[i] = NewTx(tx)
}
*/
txlist := common.NewList(ptxs)
puncles := make([]*Block, len(block.Uncles()))
/*
for i, uncle := range block.Uncles() {
puncles[i] = NewBlock(types.NewBlockWithHeader(uncle))
}
*/
ulist := common.NewList(puncles)
return &Block{
ref: block, Size: block.Size().String(),
Number: int(block.NumberU64()), GasUsed: block.GasUsed().String(),
GasLimit: block.GasLimit().String(), Hash: block.Hash().Hex(),
Transactions: txlist, Uncles: ulist,
Time: block.Time(),
Coinbase: block.Coinbase().Hex(),
PrevHash: block.ParentHash().Hex(),
Bloom: common.ToHex(block.Bloom().Bytes()),
Raw: block.String(),
}
}
示例3: NewBlockRes
func NewBlockRes(block *types.Block, fullTx bool) *BlockRes {
if block == nil {
return nil
}
res := new(BlockRes)
res.fullTx = fullTx
res.BlockNumber = newHexNum(block.Number())
res.BlockHash = newHexData(block.Hash())
res.ParentHash = newHexData(block.ParentHash())
res.Nonce = newHexData(block.Nonce())
res.Sha3Uncles = newHexData(block.UncleHash())
res.LogsBloom = newHexData(block.Bloom())
res.TransactionRoot = newHexData(block.TxHash())
res.StateRoot = newHexData(block.Root())
res.Miner = newHexData(block.Coinbase())
res.Difficulty = newHexNum(block.Difficulty())
res.TotalDifficulty = newHexNum(block.Td)
res.Size = newHexNum(block.Size().Int64())
res.ExtraData = newHexData(block.Extra())
res.GasLimit = newHexNum(block.GasLimit())
res.GasUsed = newHexNum(block.GasUsed())
res.UnixTimestamp = newHexNum(block.Time())
txs := block.Transactions()
res.Transactions = make([]*TransactionRes, len(txs))
for i, tx := range txs {
res.Transactions[i] = NewTransactionRes(tx)
res.Transactions[i].BlockHash = res.BlockHash
res.Transactions[i].BlockNumber = res.BlockNumber
res.Transactions[i].TxIndex = newHexNum(i)
}
uncles := block.Uncles()
res.Uncles = make([]*UncleRes, len(uncles))
for i, uncle := range uncles {
res.Uncles[i] = NewUncleRes(uncle)
}
return res
}