Update Coordinator & BatchBuilder & TxSelector to new SQL schemas changes

This commit is contained in:
arnaucube
2020-08-17 12:36:36 +02:00
parent cb1b820256
commit c702442287
10 changed files with 80 additions and 25 deletions

View File

@@ -25,3 +25,16 @@ type L1Tx struct {
// Extra metadata, may be uninitialized
Type TxType `meddler:"-"` // optional, descrives which kind of tx it's
}
func (tx *L1Tx) Tx() *Tx {
return &Tx{
TxID: tx.TxID,
FromIdx: tx.FromIdx,
ToIdx: tx.ToIdx,
TokenID: tx.TokenID,
Amount: tx.Amount,
Nonce: 0,
Fee: 0,
Type: tx.Type,
}
}

View File

@@ -40,6 +40,19 @@ type PoolL2Tx struct {
RqTxCompressedData []byte `meddler:"-"` // 253 bits, optional for atomic txs
}
func (tx *PoolL2Tx) Tx() *Tx {
return &Tx{
TxID: tx.TxID,
FromIdx: tx.FromIdx,
ToIdx: tx.ToIdx,
TokenID: tx.TokenID,
Amount: tx.Amount,
Nonce: tx.Nonce,
Fee: tx.Fee,
Type: tx.Type,
}
}
// PoolL2TxState is a struct that represents the status of a L2 transaction
type PoolL2TxState string

View File

@@ -58,3 +58,16 @@ const (
// TxTypeTransferToBJJ TBD
TxTypeTransferToBJJ TxType = "TxTypeTransferToBJJ"
)
// Tx is a struct used by the TxSelector & BatchBuilder as a generic type generated from L1Tx & PoolL2Tx
type Tx struct {
TxID TxID
FromIdx Idx // FromIdx is used by L1Tx/Deposit to indicate the Idx receiver of the L1Tx.LoadAmount (deposit)
ToIdx Idx // ToIdx is ignored in L1Tx/Deposit, but used in the L1Tx/DepositAndTransfer
TokenID TokenID
Amount *big.Int
Nonce uint64 // effective 48 bits used
Fee FeeSelector
Type TxType // optional, descrives which kind of tx it's
BatchNum BatchNum // batchNum in which this tx was forged. Presence indicates "forged" state.
}