use pointer for timeout param

This commit is contained in:
aodhgan 2025-10-15 10:42:41 -07:00
parent eed426c36f
commit b05fbc1868

View file

@ -703,24 +703,26 @@ func (ec *Client) SendTransaction(ctx context.Context, tx *types.Transaction) er
func (ec *Client) SendTransactionSync( func (ec *Client) SendTransactionSync(
ctx context.Context, ctx context.Context,
tx *types.Transaction, tx *types.Transaction,
timeout ...time.Duration, timeout *time.Duration,
) (*types.Receipt, error) { ) (*types.Receipt, error) {
raw, err := tx.MarshalBinary() raw, err := tx.MarshalBinary()
if err != nil { if err != nil {
return nil, err return nil, err
} }
return ec.SendRawTransactionSync(ctx, raw, timeout...) return ec.SendRawTransactionSync(ctx, raw, timeout)
} }
func (ec *Client) SendRawTransactionSync( func (ec *Client) SendRawTransactionSync(
ctx context.Context, ctx context.Context,
rawTx []byte, rawTx []byte,
timeout ...time.Duration, timeout *time.Duration,
) (*types.Receipt, error) { ) (*types.Receipt, error) {
var ms *hexutil.Uint64 var ms *hexutil.Uint64
if len(timeout) > 0 && timeout[0] > 0 { if timeout != nil {
v := hexutil.Uint64(timeout[0] / time.Millisecond) if d := timeout.Milliseconds(); d > 0 {
ms = &v ms = new(hexutil.Uint64)
*ms = hexutil.Uint64(uint64(d))
}
} }
var receipt types.Receipt var receipt types.Receipt
if err := ec.c.CallContext(ctx, &receipt, "eth_sendRawTransactionSync", hexutil.Bytes(rawTx), ms); err != nil { if err := ec.c.CallContext(ctx, &receipt, "eth_sendRawTransactionSync", hexutil.Bytes(rawTx), ms); err != nil {