Skip to content

Commit

Permalink
logs
Browse files Browse the repository at this point in the history
  • Loading branch information
cyberhorsey committed Jul 25, 2024
1 parent 22827b7 commit 239690d
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions internal/ethapi/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -679,11 +679,21 @@ func (s *BlockChainAPI) GetBalance(ctx context.Context, address common.Address,
if forwardURL := s.b.GetPreconfirmationForwardingURL(); forwardURL != "" {
log.Info("forwarding balance request", "url", forwardURL)
if blockNr, ok := blockNrOrHash.Number(); ok {
return forward[hexutil.Big](forwardURL, "eth_getBalance", []interface{}{address.Hex(), blockNr.Int64()})
bal, err := forward[hexutil.Big](forwardURL, "eth_getBalance", []interface{}{address.Hex(), blockNr.Int64()})
if err != nil && bal != nil {
log.Info("forwarded getBalance", "res", bal)
}

return bal, nil
}

if blockHash, ok := blockNrOrHash.Hash(); ok {
return forward[hexutil.Big](forwardURL, "eth_getBalance", []interface{}{address.Hex(), blockHash.Hex()})
bal, err := forward[hexutil.Big](forwardURL, "eth_getBalance", []interface{}{address.Hex(), blockHash.Hex()})
if err != nil && bal != nil {
log.Info("forwarded getBalance", "res", bal)
}

return bal, nil
}
}

Expand Down Expand Up @@ -861,10 +871,11 @@ func (s *BlockChainAPI) GetBlockByNumber(ctx context.Context, number rpc.BlockNu
// change(taiko): check to see if it exists from the preconfer.
// Check if PreconfirmationForwardingURL is set
if forwardURL := s.b.GetPreconfirmationForwardingURL(); forwardURL != "" {
log.Info("forwarding get block by number request", "url", forwardURL)
log.Info("forwarding getBlockByNumber", "url", forwardURL)
// Forward the raw transaction to the specified URL
b, err := forward[map[string]interface{}](forwardURL, "eth_getBlockByNumber", []interface{}{number, fullTx})
if err != nil && b != nil {
log.Info("forwarded getBlockByNumber", "res", b)
return *b, nil
}
}
Expand All @@ -889,9 +900,10 @@ func (s *BlockChainAPI) GetBlockByHash(ctx context.Context, hash common.Hash, fu
// change(taiko): check to see if it exists from the preconfer.
// Check if PreconfirmationForwardingURL is set
if forwardURL := s.b.GetPreconfirmationForwardingURL(); forwardURL != "" {
log.Info("forwarding get block by hash", "url", forwardURL)
log.Info("forwardinggetBlockByHash", "url", forwardURL)
m, err := forward[map[string]interface{}](forwardURL, "eth_getBlockByHash", []interface{}{hash.Hex(), fullTx})
if err != nil && m != nil {
log.Info("forwarded getBlockByHash", "res", m)
return *m, nil
}
}
Expand Down Expand Up @@ -1670,13 +1682,15 @@ func (s *TransactionAPI) GetTransactionCount(ctx context.Context, address common
if blockNr, ok := blockNrOrHash.Number(); ok {
txCount, err := forward[hexutil.Uint64](forwardURL, "eth_getTransactionCount", []interface{}{address.Hex(), blockNr.Int64()})
if err != nil && txCount != nil {
log.Info("forwarded getTransactionCount", "res", txCount)
return txCount, nil
}
}

if blockHash, ok := blockNrOrHash.Hash(); ok {
txCount, err := forward[hexutil.Uint64](forwardURL, "eth_getTransactionCount", []interface{}{address.Hex(), blockHash.Hex()})
if err != nil && txCount != nil {
log.Info("forwarded getTransactionCount", "res", txCount)
return txCount, nil
}
}
Expand Down Expand Up @@ -1928,6 +1942,7 @@ func (s *TransactionAPI) SendRawTransaction(ctx context.Context, input hexutil.B
// Forward the raw transaction to the specified URL
h, err := forward[common.Hash](forwardURL, "eth_sendRawTransaction", []interface{}{input.String()})
if err != nil && h != nil {
log.Info("forwarded sendRawTransaction", "res", h.Hex())
return *h, nil
}
}
Expand Down

0 comments on commit 239690d

Please sign in to comment.