MCPcopy Create free account
hub / github.com/blobcache/blobcache / Create

Method Create

src/bccore/handles.go:21–43  ·  view source on GitHub ↗

Create creates a new handle.

(target blobcache.OID, rights blobcache.ActionSet, createdAt, expiresAt time.Time)

Source from the content-addressed store, hash-verified

19
20// Create creates a new handle.
21func (hs *handleSystem) Create(target blobcache.OID, rights blobcache.ActionSet, createdAt, expiresAt time.Time) blobcache.Handle {
22 secret := [16]byte{}
23 if _, err := rand.Read(secret[:]); err != nil {
24 panic(err)
25 }
26 ret := blobcache.Handle{OID: target, Secret: secret}
27 hs.mu.Lock()
28 defer hs.mu.Unlock()
29 if hs.handles == nil {
30 hs.handles = make(map[[32]byte]handle)
31 }
32 hs.handles[handleKey(ret)] = handle{
33 target: target,
34 createdAt: createdAt,
35 expiresAt: expiresAt,
36 rights: rights,
37 }
38 if hs.active == nil {
39 hs.active = make(map[blobcache.OID]uint32)
40 }
41 hs.active[target] += 1
42 return ret
43}
44
45func (hs *handleSystem) Drop(h blobcache.Handle) {
46 k := handleKey(h)

Callers

nothing calls this directly

Calls 4

handleKeyFunction · 0.85
ReadMethod · 0.80
LockMethod · 0.80
UnlockMethod · 0.80

Tested by

no test coverage detected