Get receipt CID and block data for logs.
This commit is contained in:
parent
42f066772b
commit
18266c4f9d
@ -41,7 +41,7 @@ import (
|
|||||||
"github.com/ethereum/go-ethereum/rpc"
|
"github.com/ethereum/go-ethereum/rpc"
|
||||||
"github.com/ethereum/go-ethereum/trie"
|
"github.com/ethereum/go-ethereum/trie"
|
||||||
|
|
||||||
"github.com/vulcanize/ipfs-ethdb"
|
ipfsethdb "github.com/vulcanize/ipfs-ethdb"
|
||||||
"github.com/vulcanize/ipld-eth-indexer/pkg/ipfs"
|
"github.com/vulcanize/ipld-eth-indexer/pkg/ipfs"
|
||||||
"github.com/vulcanize/ipld-eth-indexer/pkg/postgres"
|
"github.com/vulcanize/ipld-eth-indexer/pkg/postgres"
|
||||||
shared2 "github.com/vulcanize/ipld-eth-indexer/pkg/shared"
|
shared2 "github.com/vulcanize/ipld-eth-indexer/pkg/shared"
|
||||||
@ -59,10 +59,10 @@ var (
|
|||||||
const (
|
const (
|
||||||
RetrieveCanonicalBlockHashByNumber = `SELECT block_hash FROM eth.header_cids
|
RetrieveCanonicalBlockHashByNumber = `SELECT block_hash FROM eth.header_cids
|
||||||
INNER JOIN public.blocks ON (header_cids.mh_key = blocks.key)
|
INNER JOIN public.blocks ON (header_cids.mh_key = blocks.key)
|
||||||
WHERE id = (SELECT canonical_header_id($1))`
|
WHERE id = (SELECT public.canonical_header($1))`
|
||||||
RetrieveCanonicalHeaderByNumber = `SELECT cid, data FROM eth.header_cids
|
RetrieveCanonicalHeaderByNumber = `SELECT cid, data FROM eth.header_cids
|
||||||
INNER JOIN public.blocks ON (header_cids.mh_key = blocks.key)
|
INNER JOIN public.blocks ON (header_cids.mh_key = blocks.key)
|
||||||
WHERE id = (SELECT canonical_header_id($1))`
|
WHERE id = (SELECT public.canonical_header($1))`
|
||||||
RetrieveTD = `SELECT td FROM eth.header_cids
|
RetrieveTD = `SELECT td FROM eth.header_cids
|
||||||
WHERE header_cids.block_hash = $1`
|
WHERE header_cids.block_hash = $1`
|
||||||
RetrieveRPCTransaction = `SELECT blocks.data, block_hash, block_number, index FROM public.blocks, eth.transaction_cids, eth.header_cids
|
RetrieveRPCTransaction = `SELECT blocks.data, block_hash, block_number, index FROM public.blocks, eth.transaction_cids, eth.header_cids
|
||||||
@ -76,7 +76,7 @@ const (
|
|||||||
AND block_number <= (SELECT block_number
|
AND block_number <= (SELECT block_number
|
||||||
FROM eth.header_cids
|
FROM eth.header_cids
|
||||||
WHERE block_hash = $2)
|
WHERE block_hash = $2)
|
||||||
AND header_cids.id = (SELECT canonical_header_id(block_number))
|
AND header_cids.id = (SELECT public.canonical_header(block_number))
|
||||||
ORDER BY block_number DESC
|
ORDER BY block_number DESC
|
||||||
LIMIT 1`
|
LIMIT 1`
|
||||||
RetrieveCodeByMhKey = `SELECT data FROM public.blocks WHERE key = $1`
|
RetrieveCodeByMhKey = `SELECT data FROM public.blocks WHERE key = $1`
|
||||||
@ -509,6 +509,7 @@ func (b *Backend) GetLogs(ctx context.Context, hash common.Hash) ([][]*types.Log
|
|||||||
if err := rlp.DecodeBytes(rctBytes, &rct); err != nil {
|
if err := rlp.DecodeBytes(rctBytes, &rct); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
logs[i] = rct.Logs
|
logs[i] = rct.Logs
|
||||||
}
|
}
|
||||||
return logs, nil
|
return logs, nil
|
||||||
|
@ -91,6 +91,8 @@ type Log struct {
|
|||||||
backend *eth.Backend
|
backend *eth.Backend
|
||||||
transaction *Transaction
|
transaction *Transaction
|
||||||
log *types.Log
|
log *types.Log
|
||||||
|
cid string
|
||||||
|
ipldBlock []byte
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *Log) Transaction(ctx context.Context) *Transaction {
|
func (l *Log) Transaction(ctx context.Context) *Transaction {
|
||||||
@ -117,6 +119,14 @@ func (l *Log) Data(ctx context.Context) hexutil.Bytes {
|
|||||||
return hexutil.Bytes(l.log.Data)
|
return hexutil.Bytes(l.log.Data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (l *Log) Cid(ctx context.Context) string {
|
||||||
|
return l.cid
|
||||||
|
}
|
||||||
|
|
||||||
|
func (l *Log) IpldBlock(ctx context.Context) hexutil.Bytes {
|
||||||
|
return hexutil.Bytes(l.ipldBlock)
|
||||||
|
}
|
||||||
|
|
||||||
// Transaction represents an Ethereum transaction.
|
// Transaction represents an Ethereum transaction.
|
||||||
// backend and hash are mandatory; all others will be fetched when required.
|
// backend and hash are mandatory; all others will be fetched when required.
|
||||||
type Transaction struct {
|
type Transaction struct {
|
||||||
|
@ -66,6 +66,12 @@ const schema string = `
|
|||||||
data: Bytes!
|
data: Bytes!
|
||||||
# Transaction is the transaction that generated this log entry.
|
# Transaction is the transaction that generated this log entry.
|
||||||
transaction: Transaction!
|
transaction: Transaction!
|
||||||
|
|
||||||
|
# CID for the Receipt IPLD block this Log exists in.
|
||||||
|
cid: String!
|
||||||
|
|
||||||
|
# IPLD block data for the Receipt this Log exists in.
|
||||||
|
ipldBlock: Bytes!
|
||||||
}
|
}
|
||||||
|
|
||||||
# Transaction is an Ethereum transaction.
|
# Transaction is an Ethereum transaction.
|
||||||
|
Loading…
Reference in New Issue
Block a user