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.

45 lines
1.8 KiB

  1. package api
  2. import (
  3. "math/big"
  4. "strconv"
  5. "time"
  6. ethCommon "github.com/ethereum/go-ethereum/common"
  7. "github.com/hermeznetwork/hermez-node/common"
  8. "github.com/iden3/go-merkletree"
  9. )
  10. func AddAditionalInformation(blocks []common.BlockData) {
  11. for i := range blocks {
  12. blocks[i].Block.Timestamp = time.Now().Add(time.Second * 13).UTC()
  13. blocks[i].Block.Hash = ethCommon.BigToHash(big.NewInt(blocks[i].Block.EthBlockNum))
  14. for j := range blocks[i].Rollup.AddedTokens {
  15. blocks[i].Rollup.AddedTokens[j].Name = "NAME" + strconv.Itoa(int(blocks[i].Rollup.AddedTokens[j].TokenID))
  16. blocks[i].Rollup.AddedTokens[j].Symbol = strconv.Itoa(int(blocks[i].Rollup.AddedTokens[j].TokenID))
  17. blocks[i].Rollup.AddedTokens[j].Decimals = uint64(blocks[i].Rollup.AddedTokens[j].TokenID + 1)
  18. }
  19. for x := range blocks[i].Rollup.Batches {
  20. for q := range blocks[i].Rollup.Batches[x].CreatedAccounts {
  21. blocks[i].Rollup.Batches[x].CreatedAccounts[q].Balance =
  22. big.NewInt(int64(blocks[i].Rollup.Batches[x].CreatedAccounts[q].Idx * 10000000))
  23. }
  24. for y := range blocks[i].Rollup.Batches[x].ExitTree {
  25. blocks[i].Rollup.Batches[x].ExitTree[y].MerkleProof =
  26. &merkletree.CircomVerifierProof{
  27. Root: &merkletree.Hash{byte(y), byte(y + 1)},
  28. Siblings: []*merkletree.Hash{
  29. merkletree.NewHashFromBigInt(big.NewInt(int64(y) * 10)),
  30. merkletree.NewHashFromBigInt(big.NewInt(int64(y)*100 + 1)),
  31. merkletree.NewHashFromBigInt(big.NewInt(int64(y)*1000 + 2))},
  32. OldKey: &merkletree.Hash{byte(y * 1), byte(y*1 + 1)},
  33. OldValue: &merkletree.Hash{byte(y * 2), byte(y*2 + 1)},
  34. IsOld0: y%2 == 0,
  35. Key: &merkletree.Hash{byte(y * 3), byte(y*3 + 1)},
  36. Value: &merkletree.Hash{byte(y * 4), byte(y*4 + 1)},
  37. Fnc: y % 2,
  38. }
  39. }
  40. }
  41. }
  42. }