MCPcopy
hub / github.com/canopy-network/canopy / getLatestCommitID

Function getLatestCommitID

store/store.go:448–462  ·  view source on GitHub ↗

getLatestCommitID() retrieves the latest CommitID from the database

(db *pebble.DB, log lib.LoggerI)

Source from the content-addressed store, hash-verified

446
447// getLatestCommitID() retrieves the latest CommitID from the database
448func getLatestCommitID(db *pebble.DB, log lib.LoggerI) (id *lib.CommitID) {
449 reader := db.NewSnapshot()
450 defer reader.Close()
451 vs := NewVersionedStore(reader, nil, lssVersion)
452 tx := NewTxn(vs, nil, nil, false, false, true, 0)
453 bz, err := tx.Get(lastCommitIDPrefix)
454 if err != nil {
455 log.Fatalf("getLatestCommitID() failed with err: %s", err.Error())
456 }
457 id = new(lib.CommitID)
458 if err = lib.Unmarshal(bz, id); err != nil {
459 log.Fatalf("unmarshalCommitID() failed with err: %s", err.Error())
460 }
461 return
462}
463
464// MaybeCompact() checks if it is time to compact the LSS and HSS respectively
465func (s *Store) MaybeCompact() {

Callers 1

NewStoreWithDBFunction · 0.85

Calls 7

GetMethod · 0.95
UnmarshalFunction · 0.92
NewVersionedStoreFunction · 0.85
NewTxnFunction · 0.85
CloseMethod · 0.65
FatalfMethod · 0.65
ErrorMethod · 0.65

Tested by

no test coverage detected