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.

49 lines
1.4 KiB

  1. package blockchain
  2. import "fmt"
  3. import "encoding/hex"
  4. import log "github.com/sirupsen/logrus"
  5. import "github.com/deroproject/derosuite/crypto"
  6. import "github.com/deroproject/derosuite/globals"
  7. var mainnet_static_checkpoints = map[crypto.Hash]uint64{}
  8. var testnet_static_checkpoints = map[crypto.Hash]uint64{}
  9. // initialize the checkpoints
  10. func init_checkpoints() {
  11. switch globals.Config.Name {
  12. case "mainnet":
  13. ADD_CHECKPOINT(mainnet_static_checkpoints, 1, "cea3eb82889a1d063aa6205011a27a108e727f2ac66721a46bec8b7ee9e83d7e")
  14. ADD_CHECKPOINT(mainnet_static_checkpoints, 10, "a8feb533ad2ad021f356b964957f4880445f89d6c6658a9407d63ce5144fe8ea")
  15. ADD_CHECKPOINT(mainnet_static_checkpoints, 100, "462ef1347bd00511ad6e7be463cba4d44a69dbf8b7d1d478ff1fd68507dfc9e2")
  16. log.Debugf("Added %d static checkpoints to mainnnet\n", len(mainnet_static_checkpoints))
  17. case "testnet":
  18. default:
  19. panic(fmt.Sprintf("Unknown Network \"%s\"", globals.Config.Name))
  20. }
  21. }
  22. // add a checkpoint to specific network
  23. func ADD_CHECKPOINT(x map[crypto.Hash]uint64, Height uint64, hash_hex string) {
  24. var hash crypto.Hash
  25. hash_raw, err := hex.DecodeString(hash_hex)
  26. if err != nil {
  27. panic(fmt.Sprintf("Cannot hex decode checkpint hash \"%s\"", hash_hex))
  28. }
  29. if len(hash_raw) != 32 {
  30. panic(fmt.Sprintf(" hash not 32 byte size Cannot hex decode checkpint hash \"%s\"", hash_hex))
  31. }
  32. copy(hash[:], hash_raw)
  33. x[hash] = Height
  34. }