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.

17 lines
461 B

  1. package blockchain
  2. // this package identifies the 2nd level caller of this function
  3. // this is done to ensure checks regarding locking etc and to be sure no spuros calls are possible
  4. import "runtime"
  5. func CallerName() string {
  6. pc, _, _, ok := runtime.Caller(1)
  7. details := runtime.FuncForPC(pc)
  8. if ok && details != nil {
  9. //fmt.Printf("called from %s\n", details.Name()) // we should only give last parse after .
  10. return details.Name()
  11. }
  12. return ""
  13. }