You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

70 lines
3.2 KiB

  1. package l2db
  2. import (
  3. "math/big"
  4. "time"
  5. ethCommon "github.com/ethereum/go-ethereum/common"
  6. "github.com/hermeznetwork/hermez-node/common"
  7. "github.com/iden3/go-iden3-crypto/babyjub"
  8. )
  9. // PoolL2TxWrite holds the necessary data to perform inserts in tx_pool
  10. type PoolL2TxWrite struct {
  11. TxID common.TxID `meddler:"tx_id"`
  12. FromIdx common.Idx `meddler:"from_idx"`
  13. ToIdx *common.Idx `meddler:"to_idx"`
  14. ToEthAddr *ethCommon.Address `meddler:"to_eth_addr"`
  15. ToBJJ *babyjub.PublicKey `meddler:"to_bjj"`
  16. TokenID common.TokenID `meddler:"token_id"`
  17. Amount *big.Int `meddler:"amount,bigint"`
  18. AmountFloat float64 `meddler:"amount_f"`
  19. Fee common.FeeSelector `meddler:"fee"`
  20. Nonce common.Nonce `meddler:"nonce"`
  21. State common.PoolL2TxState `meddler:"state"`
  22. Signature *babyjub.Signature `meddler:"signature"`
  23. RqFromIdx *common.Idx `meddler:"rq_from_idx"`
  24. RqToIdx *common.Idx `meddler:"rq_to_idx"`
  25. RqToEthAddr *ethCommon.Address `meddler:"rq_to_eth_addr"`
  26. RqToBJJ *babyjub.PublicKey `meddler:"rq_to_bjj"`
  27. RqTokenID *common.TokenID `meddler:"rq_token_id"`
  28. RqAmount *big.Int `meddler:"rq_amount,bigintnull"`
  29. RqFee *common.FeeSelector `meddler:"rq_fee"`
  30. RqNonce *common.Nonce `meddler:"rq_nonce"`
  31. Type common.TxType `meddler:"tx_type"`
  32. }
  33. // PoolL2TxRead represents a L2 Tx pool with extra metadata used by the API
  34. type PoolL2TxRead struct {
  35. TxID common.TxID `meddler:"tx_id"`
  36. FromIdx common.Idx `meddler:"from_idx"`
  37. ToIdx *common.Idx `meddler:"to_idx"`
  38. ToEthAddr *ethCommon.Address `meddler:"to_eth_addr"`
  39. ToBJJ *babyjub.PublicKey `meddler:"to_bjj"`
  40. Amount *big.Int `meddler:"amount,bigint"`
  41. Fee common.FeeSelector `meddler:"fee"`
  42. Nonce common.Nonce `meddler:"nonce"`
  43. State common.PoolL2TxState `meddler:"state"`
  44. Signature *babyjub.Signature `meddler:"signature"`
  45. RqFromIdx *common.Idx `meddler:"rq_from_idx"`
  46. RqToIdx *common.Idx `meddler:"rq_to_idx"`
  47. RqToEthAddr *ethCommon.Address `meddler:"rq_to_eth_addr"`
  48. RqToBJJ *babyjub.PublicKey `meddler:"rq_to_bjj"`
  49. RqTokenID *common.TokenID `meddler:"rq_token_id"`
  50. RqAmount *big.Int `meddler:"rq_amount,bigintnull"`
  51. RqFee *common.FeeSelector `meddler:"rq_fee"`
  52. RqNonce *common.Nonce `meddler:"rq_nonce"`
  53. Type common.TxType `meddler:"tx_type"`
  54. // Extra read fileds
  55. BatchNum *common.BatchNum `meddler:"batch_num"`
  56. Timestamp time.Time `meddler:"timestamp,utctime"`
  57. TotalItems int `meddler:"total_items"`
  58. TokenID common.TokenID `meddler:"token_id"`
  59. TokenEthBlockNum int64 `meddler:"eth_block_num"`
  60. TokenEthAddr ethCommon.Address `meddler:"eth_addr"`
  61. TokenName string `meddler:"name"`
  62. TokenSymbol string `meddler:"symbol"`
  63. TokenDecimals uint64 `meddler:"decimals"`
  64. TokenUSD *float64 `meddler:"usd"`
  65. TokenUSDUpdate *time.Time `meddler:"usd_update"`
  66. }