github.com/sberex/go-sberex@v1.8.2-0.20181113200658-ed96ac38f7d7/mobile/vm.go (about)

     1  // This file is part of the go-sberex library. The go-sberex library is 
     2  // free software: you can redistribute it and/or modify it under the terms 
     3  // of the GNU Lesser General Public License as published by the Free 
     4  // Software Foundation, either version 3 of the License, or (at your option)
     5  // any later version.
     6  //
     7  // The go-sberex library is distributed in the hope that it will be useful, 
     8  // but WITHOUT ANY WARRANTY; without even the implied warranty of
     9  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 
    10  // General Public License <http://www.gnu.org/licenses/> for more details.
    11  
    12  package geth
    13  
    14  import (
    15  	"errors"
    16  
    17  	"github.com/Sberex/go-sberex/core/types"
    18  )
    19  
    20  // Log represents a contract log event. These events are generated by the LOG
    21  // opcode and stored/indexed by the node.
    22  type Log struct {
    23  	log *types.Log
    24  }
    25  
    26  func (l *Log) GetAddress() *Address  { return &Address{l.log.Address} }
    27  func (l *Log) GetTopics() *Hashes    { return &Hashes{l.log.Topics} }
    28  func (l *Log) GetData() []byte       { return l.log.Data }
    29  func (l *Log) GetBlockNumber() int64 { return int64(l.log.BlockNumber) }
    30  func (l *Log) GetTxHash() *Hash      { return &Hash{l.log.TxHash} }
    31  func (l *Log) GetTxIndex() int       { return int(l.log.TxIndex) }
    32  func (l *Log) GetBlockHash() *Hash   { return &Hash{l.log.BlockHash} }
    33  func (l *Log) GetIndex() int         { return int(l.log.Index) }
    34  
    35  // Logs represents a slice of VM logs.
    36  type Logs struct{ logs []*types.Log }
    37  
    38  // Size returns the number of logs in the slice.
    39  func (l *Logs) Size() int {
    40  	return len(l.logs)
    41  }
    42  
    43  // Get returns the log at the given index from the slice.
    44  func (l *Logs) Get(index int) (log *Log, _ error) {
    45  	if index < 0 || index >= len(l.logs) {
    46  		return nil, errors.New("index out of bounds")
    47  	}
    48  	return &Log{l.logs[index]}, nil
    49  }