refactor: replace msgpack functions with common package equivalents for ratchet data serialization
This commit is contained in:
@@ -10,8 +10,8 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"git.quad4.io/Networks/Reticulum-Go/pkg/common"
|
||||||
"git.quad4.io/Networks/Reticulum-Go/pkg/debug"
|
"git.quad4.io/Networks/Reticulum-Go/pkg/debug"
|
||||||
"github.com/vmihailenco/msgpack/v5"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type Manager struct {
|
type Manager struct {
|
||||||
@@ -88,7 +88,7 @@ func (m *Manager) SaveRatchet(identityHash []byte, ratchetKey []byte) error {
|
|||||||
Received: time.Now().Unix(),
|
Received: time.Now().Unix(),
|
||||||
}
|
}
|
||||||
|
|
||||||
data, err := msgpack.Marshal(ratchetData)
|
data, err := common.MsgpackMarshal(ratchetData)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to marshal ratchet data: %w", err)
|
return fmt.Errorf("failed to marshal ratchet data: %w", err)
|
||||||
}
|
}
|
||||||
@@ -146,7 +146,7 @@ func (m *Manager) LoadRatchets(identityHash []byte) (map[string][]byte, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var ratchetData RatchetData
|
var ratchetData RatchetData
|
||||||
if err := msgpack.Unmarshal(data, &ratchetData); err != nil {
|
if err := common.MsgpackUnmarshal(data, &ratchetData); err != nil {
|
||||||
debug.Log(debug.DEBUG_ERROR, "Corrupted ratchet data", "file", entry.Name(), "error", err)
|
debug.Log(debug.DEBUG_ERROR, "Corrupted ratchet data", "file", entry.Name(), "error", err)
|
||||||
_ = os.Remove(filePath)
|
_ = os.Remove(filePath)
|
||||||
continue
|
continue
|
||||||
|
|||||||
Reference in New Issue
Block a user