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.

33 lines
837 B

  1. package mock
  2. import (
  3. "github.com/hermeznetwork/hermez-node/txselector/common"
  4. )
  5. type MockDB struct {
  6. Txs map[uint64][]common.Tx
  7. // AccountDB is the LocalAccountDB copy of the original AccountDB
  8. AccountDB map[[36]byte]common.Account // [36]byte is tx.ToEthAddr + tx.TokenID
  9. PendingRegistersDB map[[36]byte]common.Account // [36]byte is tx.ToEthAddr + tx.TokenID
  10. }
  11. func New() *MockDB {
  12. return &MockDB{
  13. Txs: make(map[uint64][]common.Tx),
  14. AccountDB: make(map[[36]byte]common.Account),
  15. PendingRegistersDB: make(map[[36]byte]common.Account),
  16. }
  17. }
  18. func (m *MockDB) AddTx(batchID uint64, tx common.Tx) {
  19. if _, ok := m.Txs[batchID]; !ok {
  20. m.Txs[batchID] = []common.Tx{}
  21. }
  22. m.Txs[batchID] = append(m.Txs[batchID], tx)
  23. }
  24. func (m *MockDB) GetTxs(batchID uint64) []common.Tx {
  25. return m.Txs[batchID]
  26. }