Add TxID calculation & New{Layer}Tx Type

Add TxID calculation & New{Layer}Tx Type

New{Layer}Tx methods that compute the `TxID` & `TxType` values from the
transaction values:
- NewL1Tx
- NewL2Tx
- NewPoolL2Tx

Add TxID Scanner & Valuer for database/sql

HistoryDB & L2DB & API packages tests will need to be addapted to the
TestTransaction generation once is done.
This commit is contained in:
arnaucube
2020-09-30 14:05:51 +02:00
parent c6f70f3177
commit 9bb4a4ec1b
21 changed files with 422 additions and 131 deletions

View File

@@ -319,16 +319,19 @@ func (s *StateDB) processL2Tx(exitTree *merkletree.MerkleTree, tx *common.PoolL2
// case ToEthAddr!=0 && ToBJJ=0
idx, err = s.GetIdxByEthAddr(tx.ToEthAddr)
if err != nil {
log.Error(err)
return nil, nil, false, ErrToIdxNotFound
}
} else if !bytes.Equal(tx.ToEthAddr.Bytes(), common.EmptyAddr.Bytes()) && tx.ToBJJ != nil {
// case ToEthAddr!=0 && ToBJJ!=0
idx, err = s.GetIdxByEthAddrBJJ(tx.ToEthAddr, tx.ToBJJ)
if err != nil {
log.Error(err)
return nil, nil, false, ErrToIdxNotFound
}
} else {
// rest of cases (included case ToEthAddr==0) are not possible
log.Error(err)
return nil, nil, false, ErrToIdxNotFound
}
s.zki.AuxToIdx[s.i] = idx.BigInt()