Skip to content

Commit 0fb24e9

Browse files
authored
Use BigEndian in badger (#618)
1 parent 6e6c030 commit 0fb24e9

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

storage/posix/antispam/badger.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ func (d *AntispamStorage) index(ctx context.Context, h []byte) (*uint64, error)
142142
d.numHits.Add(1)
143143

144144
return item.Value(func(v []byte) error {
145-
i := binary.LittleEndian.Uint64(v)
145+
i := binary.BigEndian.Uint64(v)
146146
idx = &i
147147
return nil
148148
})
@@ -247,7 +247,7 @@ func (f *follower) Follow(ctx context.Context, lr tessera.LogReader) {
247247
return fmt.Errorf("failed to get nextIdx: %v", err)
248248
default:
249249
if err := row.Value(func(val []byte) error {
250-
followFrom = binary.LittleEndian.Uint64(val)
250+
followFrom = binary.BigEndian.Uint64(val)
251251
return nil
252252
}); err != nil {
253253
return fmt.Errorf("failed to get nextIdx value: %v", err)
@@ -308,7 +308,7 @@ func (f *follower) Follow(ctx context.Context, lr tessera.LogReader) {
308308
for i, e := range curEntries {
309309
if _, err := txn.Get(e); err == badger.ErrKeyNotFound {
310310
b := make([]byte, 8)
311-
binary.LittleEndian.PutUint64(b, curIndex+uint64(i))
311+
binary.BigEndian.PutUint64(b, curIndex+uint64(i))
312312
if err := txn.Set(e, b); err != nil {
313313
return err
314314
}
@@ -321,7 +321,7 @@ func (f *follower) Follow(ctx context.Context, lr tessera.LogReader) {
321321

322322
// and update the follower state
323323
b := make([]byte, 8)
324-
binary.LittleEndian.PutUint64(b, curIndex+numAdded)
324+
binary.BigEndian.PutUint64(b, curIndex+numAdded)
325325
if err := txn.Set(nextKey, b); err != nil {
326326
return fmt.Errorf("failed to update follower state: %v", err)
327327
}
@@ -353,7 +353,7 @@ func (f *follower) EntriesProcessed(ctx context.Context) (uint64, error) {
353353
return fmt.Errorf("failed to read nextKey: %v", err)
354354
default:
355355
return item.Value(func(val []byte) error {
356-
nextIdx = binary.LittleEndian.Uint64(val)
356+
nextIdx = binary.BigEndian.Uint64(val)
357357
return nil
358358
})
359359
}

0 commit comments

Comments
 (0)