Skip to content

Commit

Permalink
Add md setters for updateset interval and size (#885)
Browse files Browse the repository at this point in the history
* Add md setters for updateset interval and size
  • Loading branch information
matejmode authored Dec 16, 2023
1 parent c5bf6b0 commit e32f706
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 1 deletion.
16 changes: 16 additions & 0 deletions cmd/util-db/db/insert.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,22 @@ func insertMetadata(ctx *cli.Context) error {
if err = md.SetDbHash(hash); err != nil {
return err
}
case substate.UpdatesetIntervalKey:
val, err = strconv.ParseUint(valArg, 10, 64)
if err != nil {
return fmt.Errorf("cannot parse uint %v; %v", valArg, err)
}
if err = md.SetUpdatesetInterval(val); err != nil {
return err
}
case substate.UpdatesetSizeKey:
val, err = strconv.ParseUint(valArg, 10, 64)
if err != nil {
return fmt.Errorf("cannot parse uint %v; %v", valArg, err)
}
if err = md.SetUpdatesetSize(val); err != nil {
return err
}
default:
return fmt.Errorf("incorrect keyArg: %v", keyArg)
}
Expand Down
1 change: 0 additions & 1 deletion utildb/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,6 @@ func printUpdateSetInfo(m *utils.AidaDbMetadata) {
} else {
u := bigendian.BytesToUint64(sizeBytes)

// todo convert to mb
log.Infof("Size: %.1f MB", float64(u)/float64(1_000_000))
}
}
Expand Down
23 changes: 23 additions & 0 deletions utils/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -1139,3 +1139,26 @@ func HasStateHashPatch(path string) (bool, error) {
func (md *AidaDbMetadata) SetHasHashPatch() error {
return md.Db.Put([]byte(HasStateHashPatchPrefix), []byte{1})
}

func (md *AidaDbMetadata) SetUpdatesetInterval(val uint64) error {
byteInterval := make([]byte, 8)
binary.BigEndian.PutUint64(byteInterval, val)

if err := md.Db.Put([]byte(substate.UpdatesetIntervalKey), byteInterval); err != nil {
return err
}
md.log.Info("METADATA: Updateset interval saved successfully")

return nil
}

func (md *AidaDbMetadata) SetUpdatesetSize(val uint64) error {
sizeInterval := make([]byte, 8)
binary.BigEndian.PutUint64(sizeInterval, val)

if err := md.Db.Put([]byte(substate.UpdatesetSizeKey), sizeInterval); err != nil {
return err
}
md.log.Info("METADATA: Updateset size saved successfully")
return nil
}

0 comments on commit e32f706

Please sign in to comment.