本文整理汇总了Golang中github.com/gophergala2016/etherapis/etherapis/Godeps/_workspace/src/github.com/ethereum/go-ethereum/common.Address.Hash方法的典型用法代码示例。如果您正苦于以下问题:Golang Address.Hash方法的具体用法?Golang Address.Hash怎么用?Golang Address.Hash使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/gophergala2016/etherapis/etherapis/Godeps/_workspace/src/github.com/ethereum/go-ethereum/common.Address
的用法示例。
在下文中一共展示了Address.Hash方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: NewChannel
// Start Go API. Not important for this version
func (c *Channels) NewChannel(key *ecdsa.PrivateKey, to common.Address, amount, price *big.Int, cb func(*Channel)) (*types.Transaction, error) {
from := crypto.PubkeyToAddress(key.PublicKey)
data, err := c.abi.Pack("createChannel", to, price)
if err != nil {
return nil, err
}
statedb, err := c.blockchain.State()
if err != nil {
return nil, err
}
transaction, err := types.NewTransaction(statedb.GetNonce(from), contractAddress, amount, big.NewInt(250000), big.NewInt(50000000000), data).SignECDSA(key)
if err != nil {
return nil, err
}
evId := c.abi.Events["NewChannel"].Id()
filter := filters.New(c.db)
filter.SetAddresses([]common.Address{contractAddress})
filter.SetTopics([][]common.Hash{ // TODO refactor, helper
[]common.Hash{evId},
[]common.Hash{from.Hash()},
[]common.Hash{to.Hash()},
})
filter.SetBeginBlock(0)
filter.SetEndBlock(-1)
filter.LogsCallback = func(logs vm.Logs) {
// tere should really be only one log. TODO this part
log := logs[0]
// TODO: do to and from validation here
/*
from := log.Topics[1]
to := log.Topics[2]
*/
channelId := common.BytesToHash(log.Data[0:31])
nonce := common.BytesToBig(log.Data[31:])
c.channelMu.Lock()
defer c.channelMu.Unlock()
channel, exist := c.channels[channelId]
if !exist {
channel = NewChannel(c, channelId, from, to, nonce)
c.channels[channelId] = channel
}
cb(channel)
}
c.filters.Add(filter)
return transaction, nil
}