Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
IRMA
Github mirrors
irmago
Commits
5999bcfb
Commit
5999bcfb
authored
Oct 08, 2019
by
Sietse Ringers
Browse files
refactor: rename some log functions and vars
parent
ad669a7c
Changes
2
Hide whitespace changes
Inline
Side-by-side
irmaclient/storage.go
View file @
5999bcfb
...
...
@@ -224,18 +224,18 @@ func (s *storage) LoadKeyshareServers() (ksses map[irma.SchemeManagerIdentifier]
return
ksses
,
nil
}
// Returns all logs stored before log with ID '
startBeforeI
ndex' sorted from new to old with
// Returns all logs stored before log with ID '
i
ndex' sorted from new to old with
// a maximum result length of 'max'.
func
(
s
*
storage
)
LoadLogsBefore
(
startBeforeI
ndex
uint64
,
max
int
)
([]
*
LogEntry
,
error
)
{
return
s
.
loadLogs
FromBbolt
(
max
,
func
(
c
*
bbolt
.
Cursor
)
(
key
,
value
[]
byte
)
{
c
.
Seek
(
s
.
logEntryKeyToBytes
(
startBeforeI
ndex
))
func
(
s
*
storage
)
LoadLogsBefore
(
i
ndex
uint64
,
max
int
)
([]
*
LogEntry
,
error
)
{
return
s
.
loadLogs
(
max
,
func
(
c
*
bbolt
.
Cursor
)
(
key
,
value
[]
byte
)
{
c
.
Seek
(
s
.
logEntryKeyToBytes
(
i
ndex
))
return
c
.
Prev
()
})
}
// Returns the latest logs stored sorted from new to old with a maximum result length of 'max'
func
(
s
*
storage
)
LoadNewestLogs
(
max
int
)
([]
*
LogEntry
,
error
)
{
return
s
.
loadLogs
FromBbolt
(
max
,
func
(
c
*
bbolt
.
Cursor
)
(
key
,
value
[]
byte
)
{
return
s
.
loadLogs
(
max
,
func
(
c
*
bbolt
.
Cursor
)
(
key
,
value
[]
byte
)
{
return
c
.
Last
()
})
}
...
...
@@ -243,8 +243,8 @@ func (s *storage) LoadNewestLogs(max int) ([]*LogEntry, error) {
// Returns the logs stored sorted from new to old with a maximum result length of 'max' where the starting position
// of the bbolt cursor can be manipulated by the anonymous function 'startAt'. 'startAt' should return
// the key and the value of the first element from the bbolt database that should be loaded.
func
(
s
*
storage
)
loadLogs
FromBbolt
(
max
int
,
startAt
func
(
*
bbolt
.
Cursor
)
(
key
,
value
[]
byte
))
([]
*
LogEntry
,
error
)
{
var
logs
[]
*
LogEntry
func
(
s
*
storage
)
loadLogs
(
max
int
,
startAt
func
(
*
bbolt
.
Cursor
)
(
key
,
value
[]
byte
))
([]
*
LogEntry
,
error
)
{
logs
:=
make
(
[]
*
LogEntry
,
0
,
max
)
return
logs
,
s
.
db
.
View
(
func
(
tx
*
bbolt
.
Tx
)
error
{
bucket
:=
tx
.
Bucket
([]
byte
(
logsBucket
))
if
bucket
==
nil
{
...
...
irmaclient/updates.go
View file @
5999bcfb
...
...
@@ -2,7 +2,6 @@ package irmaclient
import
(
"encoding/json"
"fmt"
"time"
"github.com/privacybydesign/irmago"
...
...
@@ -47,16 +46,9 @@ var clientUpdates = []func(client *Client) error{
func
(
client
*
Client
)
error
{
var
logs
[]
*
LogEntry
var
err
error
start
:=
time
.
Now
()
fmt
.
Println
(
start
.
UnixNano
(),
"started"
)
if
err
=
client
.
storage
.
load
(
&
logs
,
logsFile
);
err
!=
nil
{
return
err
}
loaded
:=
time
.
Now
()
fmt
.
Println
(
loaded
.
Sub
(
start
),
"loaded"
)
// Open one bolt transaction to process all our log entries in
err
=
client
.
storage
.
db
.
Update
(
func
(
tx
*
bbolt
.
Tx
)
error
{
for
_
,
log
:=
range
logs
{
...
...
@@ -77,10 +69,6 @@ var clientUpdates = []func(client *Client) error{
}
return
nil
})
done
:=
time
.
Now
()
fmt
.
Println
(
done
.
Sub
(
loaded
),
"done converting"
,
len
(
logs
),
"logs"
)
return
err
},
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment