github.com/arieschain/arieschain@v0.0.0-20191023063405-37c074544356/mobile/vm.go (about)

     1  // Contains all the wrappers from the core/types package.
     2  
     3  package geth
     4  
     5  import (
     6  	"errors"
     7  
     8  	"github.com/quickchainproject/quickchain/core/types"
     9  )
    10  
    11  // Log represents a contract log event. These events are generated by the LOG
    12  // opcode and stored/indexed by the node.
    13  type Log struct {
    14  	log *types.Log
    15  }
    16  
    17  func (l *Log) GetAddress() *Address  { return &Address{l.log.Address} }
    18  func (l *Log) GetTopics() *Hashes    { return &Hashes{l.log.Topics} }
    19  func (l *Log) GetData() []byte       { return l.log.Data }
    20  func (l *Log) GetBlockNumber() int64 { return int64(l.log.BlockNumber) }
    21  func (l *Log) GetTxHash() *Hash      { return &Hash{l.log.TxHash} }
    22  func (l *Log) GetTxIndex() int       { return int(l.log.TxIndex) }
    23  func (l *Log) GetBlockHash() *Hash   { return &Hash{l.log.BlockHash} }
    24  func (l *Log) GetIndex() int         { return int(l.log.Index) }
    25  
    26  // Logs represents a slice of VM logs.
    27  type Logs struct{ logs []*types.Log }
    28  
    29  // Size returns the number of logs in the slice.
    30  func (l *Logs) Size() int {
    31  	return len(l.logs)
    32  }
    33  
    34  // Get returns the log at the given index from the slice.
    35  func (l *Logs) Get(index int) (log *Log, _ error) {
    36  	if index < 0 || index >= len(l.logs) {
    37  		return nil, errors.New("index out of bounds")
    38  	}
    39  	return &Log{l.logs[index]}, nil
    40  }