0chain / blobber

A storage provider (blobber) interface to the blockchain and consumers of storage.
Other
19 stars 23 forks source link

NewConnectionID isn't global unique #288

Closed cnlangzi closed 3 years ago

cnlangzi commented 3 years ago

https://github.com/0chain/blobber/blob/44b88fbebc42ef3f96b3b928ee6c684dd978c3d2/code/go/0chain.net/blobbercore/allocation/workers.go#L300

connection_id is primary key in blobber's database. But NewConnectionID isn't global unique. It is a simple random number. It will make a lot of upload fail when blobber is running for long time.

func NewConnectionId() string { nBig, err := rand.Int(rand.Reader, big.NewInt(0xffffffff)) if err != nil { panic(err) } return fmt.Sprintf("%d", nBig.Int64()) }

linked to https://github.com/0chain/gosdk/issues/178

kushthedude commented 3 years ago

Use uuid here rather than any random number generator.