mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-27 15:16:43 +00:00
Make newRPCTransaction public (#26)
This commit is contained in:
parent
ce2e4cb154
commit
c3df219a7b
2 changed files with 6 additions and 6 deletions
|
|
@ -1349,9 +1349,9 @@ type RPCTransaction struct {
|
|||
YParity *hexutil.Uint64 `json:"yParity,omitempty"`
|
||||
}
|
||||
|
||||
// newRPCTransaction returns a transaction that will serialize to the RPC
|
||||
// NewRPCTransaction returns a transaction that will serialize to the RPC
|
||||
// representation, with the given location metadata set (if available).
|
||||
func newRPCTransaction(tx *types.Transaction, blockHash common.Hash, blockNumber uint64, blockTime uint64, index uint64, baseFee *big.Int, config *params.ChainConfig) *RPCTransaction {
|
||||
func NewRPCTransaction(tx *types.Transaction, blockHash common.Hash, blockNumber uint64, blockTime uint64, index uint64, baseFee *big.Int, config *params.ChainConfig) *RPCTransaction {
|
||||
signer := types.MakeSigner(config, new(big.Int).SetUint64(blockNumber), blockTime)
|
||||
from, _ := types.Sender(signer, tx)
|
||||
v, r, s := tx.RawSignatureValues()
|
||||
|
|
@ -1449,7 +1449,7 @@ func NewRPCPendingTransaction(tx *types.Transaction, current *types.Header, conf
|
|||
blockNumber = current.Number.Uint64()
|
||||
blockTime = current.Time
|
||||
}
|
||||
return newRPCTransaction(tx, common.Hash{}, blockNumber, blockTime, 0, baseFee, config)
|
||||
return NewRPCTransaction(tx, common.Hash{}, blockNumber, blockTime, 0, baseFee, config)
|
||||
}
|
||||
|
||||
// newRPCTransactionFromBlockIndex returns a transaction that will serialize to the RPC representation.
|
||||
|
|
@ -1458,7 +1458,7 @@ func newRPCTransactionFromBlockIndex(b *types.Block, index uint64, config *param
|
|||
if index >= uint64(len(txs)) {
|
||||
return nil
|
||||
}
|
||||
return newRPCTransaction(txs[index], b.Hash(), b.NumberU64(), b.Time(), index, b.BaseFee(), config)
|
||||
return NewRPCTransaction(txs[index], b.Hash(), b.NumberU64(), b.Time(), index, b.BaseFee(), config)
|
||||
}
|
||||
|
||||
// newRPCRawTransactionFromBlockIndex returns the bytes of a transaction given a block and a transaction index.
|
||||
|
|
@ -1657,7 +1657,7 @@ func (s *TransactionAPI) GetTransactionByHash(ctx context.Context, hash common.H
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return newRPCTransaction(tx, blockHash, blockNumber, header.Time, index, header.BaseFee, s.b.ChainConfig()), nil
|
||||
return NewRPCTransaction(tx, blockHash, blockNumber, header.Time, index, header.BaseFee, s.b.ChainConfig()), nil
|
||||
}
|
||||
// No finalized transaction, try to retrieve it from the pool
|
||||
if tx := s.b.GetPoolTransaction(hash); tx != nil {
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ func testTransactionMarshal(t *testing.T, tests []txData, config *params.ChainCo
|
|||
}
|
||||
|
||||
// rpcTransaction
|
||||
rpcTx := newRPCTransaction(tx, common.Hash{}, 0, 0, 0, nil, config)
|
||||
rpcTx := NewRPCTransaction(tx, common.Hash{}, 0, 0, 0, nil, config)
|
||||
if data, err := json.Marshal(rpcTx); err != nil {
|
||||
t.Fatalf("test %d: marshalling failed; %v", i, err)
|
||||
} else if err = tx2.UnmarshalJSON(data); err != nil {
|
||||
|
|
|
|||
Loading…
Reference in a new issue