| 
									
										
										
										
											2015-03-10 12:52:45 -05:00
										 |  |  | package rpc | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | import ( | 
					
						
							| 
									
										
										
										
											2015-04-01 16:49:07 +02:00
										 |  |  | 	"encoding/json" | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-06 17:51:32 +02:00
										 |  |  | 	"github.com/ethereum/go-ethereum/common" | 
					
						
							| 
									
										
										
										
											2015-03-23 16:59:09 +01:00
										 |  |  | 	"github.com/ethereum/go-ethereum/core/state" | 
					
						
							| 
									
										
										
										
											2015-03-25 16:50:30 +01:00
										 |  |  | 	"github.com/ethereum/go-ethereum/core/types" | 
					
						
							| 
									
										
										
										
											2015-03-10 12:52:45 -05:00
										 |  |  | ) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | type BlockRes struct { | 
					
						
							|  |  |  | 	fullTx bool | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-03-31 19:04:02 +02:00
										 |  |  | 	BlockNumber     *hexnum           `json:"number"` | 
					
						
							|  |  |  | 	BlockHash       *hexdata          `json:"hash"` | 
					
						
							|  |  |  | 	ParentHash      *hexdata          `json:"parentHash"` | 
					
						
							| 
									
										
										
										
											2015-04-01 15:28:06 +02:00
										 |  |  | 	Nonce           *hexdata          `json:"nonce"` | 
					
						
							| 
									
										
										
										
											2015-03-31 19:04:02 +02:00
										 |  |  | 	Sha3Uncles      *hexdata          `json:"sha3Uncles"` | 
					
						
							|  |  |  | 	LogsBloom       *hexdata          `json:"logsBloom"` | 
					
						
							| 
									
										
										
										
											2015-04-02 12:30:22 +02:00
										 |  |  | 	TransactionRoot *hexdata          `json:"transactionsRoot"` | 
					
						
							| 
									
										
										
										
											2015-03-31 19:04:02 +02:00
										 |  |  | 	StateRoot       *hexdata          `json:"stateRoot"` | 
					
						
							|  |  |  | 	Miner           *hexdata          `json:"miner"` | 
					
						
							|  |  |  | 	Difficulty      *hexnum           `json:"difficulty"` | 
					
						
							|  |  |  | 	TotalDifficulty *hexnum           `json:"totalDifficulty"` | 
					
						
							|  |  |  | 	Size            *hexnum           `json:"size"` | 
					
						
							|  |  |  | 	ExtraData       *hexdata          `json:"extraData"` | 
					
						
							|  |  |  | 	GasLimit        *hexnum           `json:"gasLimit"` | 
					
						
							|  |  |  | 	GasUsed         *hexnum           `json:"gasUsed"` | 
					
						
							|  |  |  | 	UnixTimestamp   *hexnum           `json:"timestamp"` | 
					
						
							| 
									
										
										
										
											2015-03-10 12:52:45 -05:00
										 |  |  | 	Transactions    []*TransactionRes `json:"transactions"` | 
					
						
							| 
									
										
										
										
											2015-04-02 17:55:42 +02:00
										 |  |  | 	Uncles          []*UncleRes       `json:"uncles"` | 
					
						
							| 
									
										
										
										
											2015-03-10 12:52:45 -05:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-04-01 16:49:07 +02:00
										 |  |  | func (b *BlockRes) MarshalJSON() ([]byte, error) { | 
					
						
							|  |  |  | 	if b.fullTx { | 
					
						
							|  |  |  | 		var ext struct { | 
					
						
							|  |  |  | 			BlockNumber     *hexnum           `json:"number"` | 
					
						
							|  |  |  | 			BlockHash       *hexdata          `json:"hash"` | 
					
						
							|  |  |  | 			ParentHash      *hexdata          `json:"parentHash"` | 
					
						
							|  |  |  | 			Nonce           *hexdata          `json:"nonce"` | 
					
						
							|  |  |  | 			Sha3Uncles      *hexdata          `json:"sha3Uncles"` | 
					
						
							|  |  |  | 			LogsBloom       *hexdata          `json:"logsBloom"` | 
					
						
							| 
									
										
										
										
											2015-04-02 12:30:22 +02:00
										 |  |  | 			TransactionRoot *hexdata          `json:"transactionsRoot"` | 
					
						
							| 
									
										
										
										
											2015-04-01 16:49:07 +02:00
										 |  |  | 			StateRoot       *hexdata          `json:"stateRoot"` | 
					
						
							|  |  |  | 			Miner           *hexdata          `json:"miner"` | 
					
						
							|  |  |  | 			Difficulty      *hexnum           `json:"difficulty"` | 
					
						
							|  |  |  | 			TotalDifficulty *hexnum           `json:"totalDifficulty"` | 
					
						
							|  |  |  | 			Size            *hexnum           `json:"size"` | 
					
						
							|  |  |  | 			ExtraData       *hexdata          `json:"extraData"` | 
					
						
							|  |  |  | 			GasLimit        *hexnum           `json:"gasLimit"` | 
					
						
							|  |  |  | 			GasUsed         *hexnum           `json:"gasUsed"` | 
					
						
							|  |  |  | 			UnixTimestamp   *hexnum           `json:"timestamp"` | 
					
						
							|  |  |  | 			Transactions    []*TransactionRes `json:"transactions"` | 
					
						
							|  |  |  | 			Uncles          []*hexdata        `json:"uncles"` | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		ext.BlockNumber = b.BlockNumber | 
					
						
							|  |  |  | 		ext.BlockHash = b.BlockHash | 
					
						
							|  |  |  | 		ext.ParentHash = b.ParentHash | 
					
						
							|  |  |  | 		ext.Nonce = b.Nonce | 
					
						
							|  |  |  | 		ext.Sha3Uncles = b.Sha3Uncles | 
					
						
							|  |  |  | 		ext.LogsBloom = b.LogsBloom | 
					
						
							|  |  |  | 		ext.TransactionRoot = b.TransactionRoot | 
					
						
							|  |  |  | 		ext.StateRoot = b.StateRoot | 
					
						
							|  |  |  | 		ext.Miner = b.Miner | 
					
						
							|  |  |  | 		ext.Difficulty = b.Difficulty | 
					
						
							|  |  |  | 		ext.TotalDifficulty = b.TotalDifficulty | 
					
						
							|  |  |  | 		ext.Size = b.Size | 
					
						
							|  |  |  | 		ext.ExtraData = b.ExtraData | 
					
						
							|  |  |  | 		ext.GasLimit = b.GasLimit | 
					
						
							|  |  |  | 		ext.GasUsed = b.GasUsed | 
					
						
							|  |  |  | 		ext.UnixTimestamp = b.UnixTimestamp | 
					
						
							|  |  |  | 		ext.Transactions = b.Transactions | 
					
						
							| 
									
										
										
										
											2015-04-02 17:55:42 +02:00
										 |  |  | 		ext.Uncles = make([]*hexdata, len(b.Uncles)) | 
					
						
							|  |  |  | 		for i, u := range b.Uncles { | 
					
						
							|  |  |  | 			ext.Uncles[i] = u.BlockHash | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2015-04-01 16:49:07 +02:00
										 |  |  | 		return json.Marshal(ext) | 
					
						
							|  |  |  | 	} else { | 
					
						
							|  |  |  | 		var ext struct { | 
					
						
							|  |  |  | 			BlockNumber     *hexnum    `json:"number"` | 
					
						
							|  |  |  | 			BlockHash       *hexdata   `json:"hash"` | 
					
						
							|  |  |  | 			ParentHash      *hexdata   `json:"parentHash"` | 
					
						
							|  |  |  | 			Nonce           *hexdata   `json:"nonce"` | 
					
						
							|  |  |  | 			Sha3Uncles      *hexdata   `json:"sha3Uncles"` | 
					
						
							|  |  |  | 			LogsBloom       *hexdata   `json:"logsBloom"` | 
					
						
							| 
									
										
										
										
											2015-04-02 12:30:22 +02:00
										 |  |  | 			TransactionRoot *hexdata   `json:"transactionsRoot"` | 
					
						
							| 
									
										
										
										
											2015-04-01 16:49:07 +02:00
										 |  |  | 			StateRoot       *hexdata   `json:"stateRoot"` | 
					
						
							|  |  |  | 			Miner           *hexdata   `json:"miner"` | 
					
						
							|  |  |  | 			Difficulty      *hexnum    `json:"difficulty"` | 
					
						
							|  |  |  | 			TotalDifficulty *hexnum    `json:"totalDifficulty"` | 
					
						
							|  |  |  | 			Size            *hexnum    `json:"size"` | 
					
						
							|  |  |  | 			ExtraData       *hexdata   `json:"extraData"` | 
					
						
							|  |  |  | 			GasLimit        *hexnum    `json:"gasLimit"` | 
					
						
							|  |  |  | 			GasUsed         *hexnum    `json:"gasUsed"` | 
					
						
							|  |  |  | 			UnixTimestamp   *hexnum    `json:"timestamp"` | 
					
						
							|  |  |  | 			Transactions    []*hexdata `json:"transactions"` | 
					
						
							|  |  |  | 			Uncles          []*hexdata `json:"uncles"` | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		ext.BlockNumber = b.BlockNumber | 
					
						
							|  |  |  | 		ext.BlockHash = b.BlockHash | 
					
						
							|  |  |  | 		ext.ParentHash = b.ParentHash | 
					
						
							|  |  |  | 		ext.Nonce = b.Nonce | 
					
						
							|  |  |  | 		ext.Sha3Uncles = b.Sha3Uncles | 
					
						
							|  |  |  | 		ext.LogsBloom = b.LogsBloom | 
					
						
							|  |  |  | 		ext.TransactionRoot = b.TransactionRoot | 
					
						
							|  |  |  | 		ext.StateRoot = b.StateRoot | 
					
						
							|  |  |  | 		ext.Miner = b.Miner | 
					
						
							|  |  |  | 		ext.Difficulty = b.Difficulty | 
					
						
							|  |  |  | 		ext.TotalDifficulty = b.TotalDifficulty | 
					
						
							|  |  |  | 		ext.Size = b.Size | 
					
						
							|  |  |  | 		ext.ExtraData = b.ExtraData | 
					
						
							|  |  |  | 		ext.GasLimit = b.GasLimit | 
					
						
							|  |  |  | 		ext.GasUsed = b.GasUsed | 
					
						
							|  |  |  | 		ext.UnixTimestamp = b.UnixTimestamp | 
					
						
							|  |  |  | 		ext.Transactions = make([]*hexdata, len(b.Transactions)) | 
					
						
							|  |  |  | 		for i, tx := range b.Transactions { | 
					
						
							|  |  |  | 			ext.Transactions[i] = tx.Hash | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2015-04-02 17:55:42 +02:00
										 |  |  | 		ext.Uncles = make([]*hexdata, len(b.Uncles)) | 
					
						
							|  |  |  | 		for i, u := range b.Uncles { | 
					
						
							|  |  |  | 			ext.Uncles[i] = u.BlockHash | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2015-04-01 16:49:07 +02:00
										 |  |  | 		return json.Marshal(ext) | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-04-01 13:18:30 +02:00
										 |  |  | func NewBlockRes(block *types.Block, fullTx bool) *BlockRes { | 
					
						
							| 
									
										
										
										
											2015-03-10 19:34:07 -05:00
										 |  |  | 	if block == nil { | 
					
						
							| 
									
										
										
										
											2015-04-02 13:05:13 +02:00
										 |  |  | 		return nil | 
					
						
							| 
									
										
										
										
											2015-03-10 19:34:07 -05:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-03-10 12:52:45 -05:00
										 |  |  | 	res := new(BlockRes) | 
					
						
							| 
									
										
										
										
											2015-04-01 13:18:30 +02:00
										 |  |  | 	res.fullTx = fullTx | 
					
						
							| 
									
										
										
										
											2015-03-31 19:04:02 +02:00
										 |  |  | 	res.BlockNumber = newHexNum(block.Number()) | 
					
						
							|  |  |  | 	res.BlockHash = newHexData(block.Hash()) | 
					
						
							|  |  |  | 	res.ParentHash = newHexData(block.ParentHash()) | 
					
						
							| 
									
										
										
										
											2015-04-01 17:48:53 +02:00
										 |  |  | 	res.Nonce = newHexData(block.Nonce()) | 
					
						
							| 
									
										
										
										
											2015-03-31 19:04:02 +02:00
										 |  |  | 	res.Sha3Uncles = newHexData(block.Header().UncleHash) | 
					
						
							|  |  |  | 	res.LogsBloom = newHexData(block.Bloom()) | 
					
						
							|  |  |  | 	res.TransactionRoot = newHexData(block.Header().TxHash) | 
					
						
							|  |  |  | 	res.StateRoot = newHexData(block.Root()) | 
					
						
							|  |  |  | 	res.Miner = newHexData(block.Header().Coinbase) | 
					
						
							|  |  |  | 	res.Difficulty = newHexNum(block.Difficulty()) | 
					
						
							|  |  |  | 	res.TotalDifficulty = newHexNum(block.Td) | 
					
						
							| 
									
										
										
										
											2015-04-01 15:44:09 +02:00
										 |  |  | 	res.Size = newHexNum(block.Size().Int64()) | 
					
						
							| 
									
										
										
										
											2015-03-31 19:04:02 +02:00
										 |  |  | 	res.ExtraData = newHexData(block.Header().Extra) | 
					
						
							|  |  |  | 	res.GasLimit = newHexNum(block.GasLimit()) | 
					
						
							|  |  |  | 	res.GasUsed = newHexNum(block.GasUsed()) | 
					
						
							|  |  |  | 	res.UnixTimestamp = newHexNum(block.Time()) | 
					
						
							| 
									
										
										
										
											2015-04-01 13:18:51 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	res.Transactions = make([]*TransactionRes, len(block.Transactions())) | 
					
						
							|  |  |  | 	for i, tx := range block.Transactions() { | 
					
						
							|  |  |  | 		res.Transactions[i] = NewTransactionRes(tx) | 
					
						
							|  |  |  | 		res.Transactions[i].BlockHash = res.BlockHash | 
					
						
							|  |  |  | 		res.Transactions[i].BlockNumber = res.BlockNumber | 
					
						
							|  |  |  | 		res.Transactions[i].TxIndex = newHexNum(i) | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-04-02 17:55:42 +02:00
										 |  |  | 	res.Uncles = make([]*UncleRes, len(block.Uncles())) | 
					
						
							| 
									
										
										
										
											2015-03-10 12:52:45 -05:00
										 |  |  | 	for i, uncle := range block.Uncles() { | 
					
						
							| 
									
										
										
										
											2015-04-02 17:55:42 +02:00
										 |  |  | 		res.Uncles[i] = NewUncleRes(uncle) | 
					
						
							| 
									
										
										
										
											2015-03-10 12:52:45 -05:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2015-04-01 13:18:51 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-03-10 12:52:45 -05:00
										 |  |  | 	return res | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | type TransactionRes struct { | 
					
						
							| 
									
										
										
										
											2015-03-31 19:04:02 +02:00
										 |  |  | 	Hash        *hexdata `json:"hash"` | 
					
						
							|  |  |  | 	Nonce       *hexnum  `json:"nonce"` | 
					
						
							|  |  |  | 	BlockHash   *hexdata `json:"blockHash"` | 
					
						
							|  |  |  | 	BlockNumber *hexnum  `json:"blockNumber"` | 
					
						
							|  |  |  | 	TxIndex     *hexnum  `json:"transactionIndex"` | 
					
						
							|  |  |  | 	From        *hexdata `json:"from"` | 
					
						
							|  |  |  | 	To          *hexdata `json:"to"` | 
					
						
							|  |  |  | 	Value       *hexnum  `json:"value"` | 
					
						
							|  |  |  | 	Gas         *hexnum  `json:"gas"` | 
					
						
							|  |  |  | 	GasPrice    *hexnum  `json:"gasPrice"` | 
					
						
							|  |  |  | 	Input       *hexdata `json:"input"` | 
					
						
							| 
									
										
										
										
											2015-03-10 12:52:45 -05:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func NewTransactionRes(tx *types.Transaction) *TransactionRes { | 
					
						
							| 
									
										
										
										
											2015-04-02 14:54:28 +02:00
										 |  |  | 	if tx == nil { | 
					
						
							|  |  |  | 		return nil | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-03-10 12:52:45 -05:00
										 |  |  | 	var v = new(TransactionRes) | 
					
						
							| 
									
										
										
										
											2015-03-31 19:04:02 +02:00
										 |  |  | 	v.Hash = newHexData(tx.Hash()) | 
					
						
							|  |  |  | 	v.Nonce = newHexNum(tx.Nonce()) | 
					
						
							|  |  |  | 	// v.BlockHash = | 
					
						
							|  |  |  | 	// v.BlockNumber = | 
					
						
							|  |  |  | 	// v.TxIndex = | 
					
						
							|  |  |  | 	from, _ := tx.From() | 
					
						
							|  |  |  | 	v.From = newHexData(from) | 
					
						
							|  |  |  | 	v.To = newHexData(tx.To()) | 
					
						
							|  |  |  | 	v.Value = newHexNum(tx.Value()) | 
					
						
							|  |  |  | 	v.Gas = newHexNum(tx.Gas()) | 
					
						
							|  |  |  | 	v.GasPrice = newHexNum(tx.GasPrice()) | 
					
						
							|  |  |  | 	v.Input = newHexData(tx.Data()) | 
					
						
							|  |  |  | 	return v | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-04-02 17:55:42 +02:00
										 |  |  | type UncleRes struct { | 
					
						
							|  |  |  | 	BlockNumber     *hexnum  `json:"number"` | 
					
						
							|  |  |  | 	BlockHash       *hexdata `json:"hash"` | 
					
						
							|  |  |  | 	ParentHash      *hexdata `json:"parentHash"` | 
					
						
							|  |  |  | 	Nonce           *hexdata `json:"nonce"` | 
					
						
							|  |  |  | 	Sha3Uncles      *hexdata `json:"sha3Uncles"` | 
					
						
							|  |  |  | 	ReceiptHash     *hexdata `json:"receiptHash"` | 
					
						
							|  |  |  | 	LogsBloom       *hexdata `json:"logsBloom"` | 
					
						
							|  |  |  | 	TransactionRoot *hexdata `json:"transactionsRoot"` | 
					
						
							|  |  |  | 	StateRoot       *hexdata `json:"stateRoot"` | 
					
						
							|  |  |  | 	Miner           *hexdata `json:"miner"` | 
					
						
							|  |  |  | 	Difficulty      *hexnum  `json:"difficulty"` | 
					
						
							|  |  |  | 	ExtraData       *hexdata `json:"extraData"` | 
					
						
							|  |  |  | 	GasLimit        *hexnum  `json:"gasLimit"` | 
					
						
							|  |  |  | 	GasUsed         *hexnum  `json:"gasUsed"` | 
					
						
							|  |  |  | 	UnixTimestamp   *hexnum  `json:"timestamp"` | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func NewUncleRes(h *types.Header) *UncleRes { | 
					
						
							|  |  |  | 	if h == nil { | 
					
						
							|  |  |  | 		return nil | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	var v = new(UncleRes) | 
					
						
							|  |  |  | 	v.BlockNumber = newHexNum(h.Number) | 
					
						
							|  |  |  | 	v.BlockHash = newHexData(h.Hash()) | 
					
						
							|  |  |  | 	v.ParentHash = newHexData(h.ParentHash) | 
					
						
							|  |  |  | 	v.Sha3Uncles = newHexData(h.UncleHash) | 
					
						
							|  |  |  | 	v.Nonce = newHexData(h.Nonce[:]) | 
					
						
							|  |  |  | 	v.LogsBloom = newHexData(h.Bloom) | 
					
						
							|  |  |  | 	v.TransactionRoot = newHexData(h.TxHash) | 
					
						
							|  |  |  | 	v.StateRoot = newHexData(h.Root) | 
					
						
							|  |  |  | 	v.Miner = newHexData(h.Coinbase) | 
					
						
							|  |  |  | 	v.Difficulty = newHexNum(h.Difficulty) | 
					
						
							|  |  |  | 	v.ExtraData = newHexData(h.Extra) | 
					
						
							|  |  |  | 	v.GasLimit = newHexNum(h.GasLimit) | 
					
						
							|  |  |  | 	v.GasUsed = newHexNum(h.GasUsed) | 
					
						
							|  |  |  | 	v.UnixTimestamp = newHexNum(h.Time) | 
					
						
							|  |  |  | 	v.ReceiptHash = newHexData(h.ReceiptHash) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return v | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-03-31 17:40:35 +02:00
										 |  |  | // type FilterLogRes struct { | 
					
						
							|  |  |  | // 	Hash             string `json:"hash"` | 
					
						
							|  |  |  | // 	Address          string `json:"address"` | 
					
						
							|  |  |  | // 	Data             string `json:"data"` | 
					
						
							|  |  |  | // 	BlockNumber      string `json:"blockNumber"` | 
					
						
							|  |  |  | // 	TransactionHash  string `json:"transactionHash"` | 
					
						
							|  |  |  | // 	BlockHash        string `json:"blockHash"` | 
					
						
							|  |  |  | // 	TransactionIndex string `json:"transactionIndex"` | 
					
						
							|  |  |  | // 	LogIndex         string `json:"logIndex"` | 
					
						
							|  |  |  | // } | 
					
						
							| 
									
										
										
										
											2015-03-10 12:52:45 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-03-31 17:40:35 +02:00
										 |  |  | // type FilterWhisperRes struct { | 
					
						
							|  |  |  | // 	Hash       string `json:"hash"` | 
					
						
							|  |  |  | // 	From       string `json:"from"` | 
					
						
							|  |  |  | // 	To         string `json:"to"` | 
					
						
							|  |  |  | // 	Expiry     string `json:"expiry"` | 
					
						
							|  |  |  | // 	Sent       string `json:"sent"` | 
					
						
							|  |  |  | // 	Ttl        string `json:"ttl"` | 
					
						
							|  |  |  | // 	Topics     string `json:"topics"` | 
					
						
							|  |  |  | // 	Payload    string `json:"payload"` | 
					
						
							|  |  |  | // 	WorkProved string `json:"workProved"` | 
					
						
							|  |  |  | // } | 
					
						
							| 
									
										
										
										
											2015-03-19 14:19:52 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | type LogRes struct { | 
					
						
							| 
									
										
										
										
											2015-03-31 19:04:02 +02:00
										 |  |  | 	Address          *hexdata   `json:"address"` | 
					
						
							|  |  |  | 	Topics           []*hexdata `json:"topics"` | 
					
						
							|  |  |  | 	Data             *hexdata   `json:"data"` | 
					
						
							|  |  |  | 	BlockNumber      *hexnum    `json:"blockNumber"` | 
					
						
							|  |  |  | 	LogIndex         *hexnum    `json:"logIndex"` | 
					
						
							|  |  |  | 	BlockHash        *hexdata   `json:"blockHash"` | 
					
						
							|  |  |  | 	TransactionHash  *hexdata   `json:"transactionHash"` | 
					
						
							|  |  |  | 	TransactionIndex *hexnum    `json:"transactionIndex"` | 
					
						
							| 
									
										
										
										
											2015-03-25 16:50:30 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-04-08 17:14:58 +02:00
										 |  |  | func NewLogRes(log *state.Log) LogRes { | 
					
						
							| 
									
										
										
										
											2015-03-25 16:50:30 +01:00
										 |  |  | 	var l LogRes | 
					
						
							| 
									
										
										
										
											2015-04-08 17:14:58 +02:00
										 |  |  | 	l.Topics = make([]*hexdata, len(log.Topics)) | 
					
						
							|  |  |  | 	for j, topic := range log.Topics { | 
					
						
							| 
									
										
										
										
											2015-03-31 19:04:02 +02:00
										 |  |  | 		l.Topics[j] = newHexData(topic) | 
					
						
							| 
									
										
										
										
											2015-03-25 16:50:30 +01:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2015-04-08 17:14:58 +02:00
										 |  |  | 	l.Address = newHexData(log.Address) | 
					
						
							|  |  |  | 	l.Data = newHexData(log.Data) | 
					
						
							|  |  |  | 	l.BlockNumber = newHexNum(log.Number) | 
					
						
							|  |  |  | 	l.LogIndex = newHexNum(log.Index) | 
					
						
							|  |  |  | 	l.TransactionHash = newHexData(log.TxHash) | 
					
						
							|  |  |  | 	l.TransactionIndex = newHexNum(log.TxIndex) | 
					
						
							|  |  |  | 	l.BlockHash = newHexData(log.BlockHash) | 
					
						
							| 
									
										
										
										
											2015-03-25 16:50:30 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-03-31 19:04:02 +02:00
										 |  |  | 	return l | 
					
						
							| 
									
										
										
										
											2015-03-19 14:19:52 -04:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func NewLogsRes(logs state.Logs) (ls []LogRes) { | 
					
						
							|  |  |  | 	ls = make([]LogRes, len(logs)) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	for i, log := range logs { | 
					
						
							| 
									
										
										
										
											2015-03-25 16:50:30 +01:00
										 |  |  | 		ls[i] = NewLogRes(log) | 
					
						
							| 
									
										
										
										
											2015-03-19 14:19:52 -04:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2015-05-06 17:51:32 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | func NewHashesRes(hs []common.Hash) []string { | 
					
						
							|  |  |  | 	hashes := make([]string, len(hs)) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	for i, hash := range hs { | 
					
						
							|  |  |  | 		hashes[i] = hash.Hex() | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return hashes | 
					
						
							|  |  |  | } |