github.com/linapex/ethereum-dpos-chinese@v0.0.0-20190316121959-b78b3a4a1ece/mobile/vm.go (about)

     1  
     2  //<developer>
     3  //    <name>linapex 曹一峰</name>
     4  //    <email>linapex@163.com</email>
     5  //    <wx>superexc</wx>
     6  //    <qqgroup>128148617</qqgroup>
     7  //    <url>https://jsq.ink</url>
     8  //    <role>pku engineer</role>
     9  //    <date>2019-03-16 12:09:43</date>
    10  //</624342654565486592>
    11  
    12  
    13  //包含core/types包中的所有包装器。
    14  
    15  package geth
    16  
    17  import (
    18  	"errors"
    19  
    20  	"github.com/ethereum/go-ethereum/core/types"
    21  )
    22  
    23  //日志表示合同日志事件。这些事件由日志生成
    24  //操作码并由节点存储/索引。
    25  type Log struct {
    26  	log *types.Log
    27  }
    28  
    29  func (l *Log) GetAddress() *Address  { return &Address{l.log.Address} }
    30  func (l *Log) GetTopics() *Hashes    { return &Hashes{l.log.Topics} }
    31  func (l *Log) GetData() []byte       { return l.log.Data }
    32  func (l *Log) GetBlockNumber() int64 { return int64(l.log.BlockNumber) }
    33  func (l *Log) GetTxHash() *Hash      { return &Hash{l.log.TxHash} }
    34  func (l *Log) GetTxIndex() int       { return int(l.log.TxIndex) }
    35  func (l *Log) GetBlockHash() *Hash   { return &Hash{l.log.BlockHash} }
    36  func (l *Log) GetIndex() int         { return int(l.log.Index) }
    37  
    38  //日志表示VM日志的一部分。
    39  type Logs struct{ logs []*types.Log }
    40  
    41  //SIZE返回切片中的日志数。
    42  func (l *Logs) Size() int {
    43  	return len(l.logs)
    44  }
    45  
    46  //get返回切片中给定索引处的日志。
    47  func (l *Logs) Get(index int) (log *Log, _ error) {
    48  	if index < 0 || index >= len(l.logs) {
    49  		return nil, errors.New("index out of bounds")
    50  	}
    51  	return &Log{l.logs[index]}, nil
    52  }
    53