Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
briar
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
briar
briar
Commits
0c99ef0e
Verified
Commit
0c99ef0e
authored
6 years ago
by
akwizgran
Browse files
Options
Downloads
Patches
Plain Diff
Clean up some duplicated code.
parent
faba9a6b
No related branches found
No related tags found
1 merge request
!1082
Generate and store handshake key pair at startup if necessary
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
bramble-core/src/main/java/org/briarproject/bramble/identity/IdentityManagerImpl.java
+12
-14
12 additions, 14 deletions
...rg/briarproject/bramble/identity/IdentityManagerImpl.java
with
12 additions
and
14 deletions
bramble-core/src/main/java/org/briarproject/bramble/identity/IdentityManagerImpl.java
+
12
−
14
View file @
0c99ef0e
...
@@ -98,9 +98,7 @@ class IdentityManagerImpl implements IdentityManager, OpenDatabaseHook {
...
@@ -98,9 +98,7 @@ class IdentityManagerImpl implements IdentityManager, OpenDatabaseHook {
@Override
@Override
public
void
onDatabaseOpened
(
Transaction
txn
)
throws
DbException
{
public
void
onDatabaseOpened
(
Transaction
txn
)
throws
DbException
{
Account
cached
=
cachedAccount
;
Account
cached
=
getCachedAccount
(
txn
);
if
(
cached
==
null
)
cachedAccount
=
cached
=
loadAccountWithKeyPair
(
txn
);
if
(
shouldStoreAccount
)
{
if
(
shouldStoreAccount
)
{
db
.
addAccount
(
txn
,
cached
);
db
.
addAccount
(
txn
,
cached
);
LOG
.
info
(
"Account stored"
);
LOG
.
info
(
"Account stored"
);
...
@@ -116,32 +114,32 @@ class IdentityManagerImpl implements IdentityManager, OpenDatabaseHook {
...
@@ -116,32 +114,32 @@ class IdentityManagerImpl implements IdentityManager, OpenDatabaseHook {
@Override
@Override
public
LocalAuthor
getLocalAuthor
()
throws
DbException
{
public
LocalAuthor
getLocalAuthor
()
throws
DbException
{
Account
cached
=
cachedAccount
;
Account
cached
=
cachedAccount
;
if
(
cached
==
null
)
{
if
(
cached
==
null
)
cachedAccount
=
cached
=
db
.
transactionWithResult
(
true
,
cached
=
db
.
transactionWithResult
(
true
,
this
::
getCachedAccount
);
this
::
loadAccountWithKeyPair
);
}
return
cached
.
getLocalAuthor
();
return
cached
.
getLocalAuthor
();
}
}
@Override
@Override
public
LocalAuthor
getLocalAuthor
(
Transaction
txn
)
throws
DbException
{
public
LocalAuthor
getLocalAuthor
(
Transaction
txn
)
throws
DbException
{
Account
cached
=
cachedAccount
;
return
getCachedAccount
(
txn
).
getLocalAuthor
();
if
(
cached
==
null
)
cachedAccount
=
cached
=
loadAccountWithKeyPair
(
txn
);
return
cached
.
getLocalAuthor
();
}
}
@Override
@Override
public
byte
[][]
getHandshakeKeys
(
Transaction
txn
)
throws
DbException
{
public
byte
[][]
getHandshakeKeys
(
Transaction
txn
)
throws
DbException
{
Account
cached
=
cachedAccount
;
Account
cached
=
getCachedAccount
(
txn
);
if
(
cached
==
null
)
cachedAccount
=
cached
=
loadAccountWithKeyPair
(
txn
);
return
new
byte
[][]
{
return
new
byte
[][]
{
cached
.
getHandshakePublicKey
(),
cached
.
getHandshakePublicKey
(),
cached
.
getHandshakePrivateKey
()
cached
.
getHandshakePrivateKey
()
};
};
}
}
private
Account
getCachedAccount
(
Transaction
txn
)
throws
DbException
{
Account
cached
=
cachedAccount
;
if
(
cached
==
null
)
cachedAccount
=
cached
=
loadAccountWithKeyPair
(
txn
);
return
cached
;
}
private
Account
loadAccountWithKeyPair
(
Transaction
txn
)
throws
DbException
{
private
Account
loadAccountWithKeyPair
(
Transaction
txn
)
throws
DbException
{
Account
a
=
loadAccount
(
txn
);
Account
a
=
loadAccount
(
txn
);
LOG
.
info
(
"Account loaded"
);
LOG
.
info
(
"Account loaded"
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment