github.com/0chain/gosdk@v1.17.11/core/util/uuid.go (about)

     1  package util
     2  
     3  import (
     4  	"github.com/google/uuid"
     5  )
     6  
     7  // GetSHA1Uuid will give version 5 uuid. It depends on already existing uuid.
     8  // The main idea is to synchronize uuid among blobbers. So for example, if
     9  // a file is being uploaded to 4 blobbers then we require that file in each blobber
    10  // have same uuid. All the goroutine that assigns uuid, calculates hashes and commits to blobber
    11  // will use initial version 1 uuid and updates the uuid with recently calculated uuid so that
    12  // the file will get same uuid in all blobbers.
    13  func GetSHA1Uuid(u uuid.UUID, name string) uuid.UUID {
    14  	return uuid.NewSHA1(u, []byte(name))
    15  }
    16  
    17  // GetNewUUID will give new version1 uuid. It will panic if any error occurred
    18  func GetNewUUID() uuid.UUID {
    19  	uid, err := uuid.NewUUID()
    20  	if err != nil {
    21  		panic("could not get new uuid. Error: " + err.Error())
    22  	}
    23  	return uid
    24  }