mirror of
https://github.com/arnaucube/hermez-node.git
synced 2026-02-07 03:16:45 +01:00
Avoid using pointers in common
This commit is contained in:
@@ -14,9 +14,7 @@ type L2Tx struct {
|
||||
FromIdx Idx
|
||||
ToIdx Idx
|
||||
Amount *big.Int
|
||||
USD *float64
|
||||
Fee FeeSelector
|
||||
FeeUSD *float64
|
||||
Nonce Nonce
|
||||
Type TxType
|
||||
EthBlockNum int64 // Ethereum Block Number in which this L2Tx was added to the queue
|
||||
@@ -60,32 +58,23 @@ func NewL2Tx(l2Tx *L2Tx) (*L2Tx, error) {
|
||||
|
||||
// Tx returns a *Tx from the L2Tx
|
||||
func (tx *L2Tx) Tx() *Tx {
|
||||
f := new(big.Float).SetInt(tx.Amount)
|
||||
amountFloat, _ := f.Float64()
|
||||
batchNum := new(BatchNum)
|
||||
*batchNum = tx.BatchNum
|
||||
fee := new(FeeSelector)
|
||||
*fee = tx.Fee
|
||||
nonce := new(Nonce)
|
||||
*nonce = tx.Nonce
|
||||
fromIdx := new(Idx)
|
||||
*fromIdx = tx.FromIdx
|
||||
toIdx := new(Idx)
|
||||
*toIdx = tx.ToIdx
|
||||
return &Tx{
|
||||
IsL1: false,
|
||||
TxID: tx.TxID,
|
||||
Type: tx.Type,
|
||||
Position: tx.Position,
|
||||
FromIdx: fromIdx,
|
||||
ToIdx: toIdx,
|
||||
FromIdx: tx.FromIdx,
|
||||
ToIdx: tx.ToIdx,
|
||||
Amount: tx.Amount,
|
||||
USD: tx.USD,
|
||||
AmountFloat: amountFloat,
|
||||
BatchNum: batchNum,
|
||||
EthBlockNum: tx.EthBlockNum,
|
||||
Fee: fee,
|
||||
FeeUSD: tx.FeeUSD,
|
||||
Nonce: nonce,
|
||||
}
|
||||
}
|
||||
@@ -93,19 +82,14 @@ func (tx *L2Tx) Tx() *Tx {
|
||||
// PoolL2Tx returns the data structure of PoolL2Tx with the parameters of a
|
||||
// L2Tx filled
|
||||
func (tx *L2Tx) PoolL2Tx() *PoolL2Tx {
|
||||
batchNum := new(BatchNum)
|
||||
*batchNum = tx.BatchNum
|
||||
toIdx := new(Idx)
|
||||
*toIdx = tx.ToIdx
|
||||
return &PoolL2Tx{
|
||||
TxID: tx.TxID,
|
||||
BatchNum: batchNum,
|
||||
FromIdx: tx.FromIdx,
|
||||
ToIdx: toIdx,
|
||||
Amount: tx.Amount,
|
||||
Fee: tx.Fee,
|
||||
Nonce: tx.Nonce,
|
||||
Type: tx.Type,
|
||||
TxID: tx.TxID,
|
||||
FromIdx: tx.FromIdx,
|
||||
ToIdx: tx.ToIdx,
|
||||
Amount: tx.Amount,
|
||||
Fee: tx.Fee,
|
||||
Nonce: tx.Nonce,
|
||||
Type: tx.Type,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user