Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
timothe
duniter
Commits
982a6fab
Commit
982a6fab
authored
May 28, 2019
by
Cédric Moreau
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[enh] logging: failure details for identity while coming to mempool
parent
a260d458
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
32 deletions
+37
-32
app/service/IdentityService.ts
app/service/IdentityService.ts
+37
-32
No files found.
app/service/IdentityService.ts
View file @
982a6fab
...
...
@@ -119,48 +119,53 @@ export class IdentityService extends FIFOService {
const
hash
=
idtyObj
.
getHash
()
return
this
.
pushFIFO
<
DBIdentity
>
(
hash
,
async
()
=>
{
this
.
logger
.
info
(
'
⬇ IDTY %s %s
'
,
idty
.
pubkey
,
idty
.
uid
);
// Check signature's validity
let
verified
=
verify
(
createIdentity
,
idty
.
sig
,
idty
.
pubkey
);
if
(
!
verified
)
{
throw
constants
.
ERRORS
.
SIGNATURE_DOES_NOT_MATCH
;
}
let
existing
=
await
this
.
dal
.
getGlobalIdentityByHashForExistence
(
toSave
.
hash
);
if
(
existing
)
{
throw
constants
.
ERRORS
.
ALREADY_UP_TO_DATE
;
}
else
{
// Create if not already written uid/pubkey
let
used
=
await
GLOBAL_RULES_HELPERS
.
checkExistsPubkey
(
idty
.
pubkey
,
this
.
dal
)
if
(
used
)
{
throw
constants
.
ERRORS
.
PUBKEY_ALREADY_USED
;
try
{
// Check signature's validity
let
verified
=
verify
(
createIdentity
,
idty
.
sig
,
idty
.
pubkey
);
if
(
!
verified
)
{
throw
constants
.
ERRORS
.
SIGNATURE_DOES_NOT_MATCH
;
}
used
=
await
GLOBAL_RULES_HELPERS
.
checkExistsUserID
(
idty
.
uid
,
this
.
dal
)
if
(
used
)
{
throw
constants
.
ERRORS
.
UID_
ALREADY_U
SED
;
let
existing
=
await
this
.
dal
.
getGlobalIdentityByHashForExistence
(
toSave
.
hash
);
if
(
existing
)
{
throw
constants
.
ERRORS
.
ALREADY_U
P_TO_DATE
;
}
const
current
=
await
this
.
dal
.
getCurrentBlockOrNull
();
if
(
idty
.
buid
==
'
0-E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855
'
&&
current
)
{
throw
constants
.
ERRORS
.
BLOCKSTAMP_DOES_NOT_MATCH_A_BLOCK
;
}
else
if
(
current
)
{
let
basedBlock
=
await
this
.
dal
.
getAbsoluteValidBlockInForkWindowByBlockstamp
(
idty
.
buid
);
if
(
!
basedBlock
)
{
else
{
// Create if not already written uid/pubkey
let
used
=
await
GLOBAL_RULES_HELPERS
.
checkExistsPubkey
(
idty
.
pubkey
,
this
.
dal
)
if
(
used
)
{
throw
constants
.
ERRORS
.
PUBKEY_ALREADY_USED
;
}
used
=
await
GLOBAL_RULES_HELPERS
.
checkExistsUserID
(
idty
.
uid
,
this
.
dal
)
if
(
used
)
{
throw
constants
.
ERRORS
.
UID_ALREADY_USED
;
}
const
current
=
await
this
.
dal
.
getCurrentBlockOrNull
();
if
(
idty
.
buid
==
'
0-E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855
'
&&
current
)
{
throw
constants
.
ERRORS
.
BLOCKSTAMP_DOES_NOT_MATCH_A_BLOCK
;
}
else
if
(
current
)
{
let
basedBlock
=
await
this
.
dal
.
getAbsoluteValidBlockInForkWindowByBlockstamp
(
idty
.
buid
);
if
(
!
basedBlock
)
{
throw
constants
.
ERRORS
.
BLOCKSTAMP_DOES_NOT_MATCH_A_BLOCK
;
}
toSave
.
expires_on
=
basedBlock
.
medianTime
+
this
.
conf
.
idtyWindow
;
}
toSave
.
expires_on
=
basedBlock
.
medianTime
+
this
.
conf
.
idtyWindow
;
}
await
GLOBAL_RULES_FUNCTIONS
.
checkIdentitiesAreWritable
({
identities
:
[
idtyObj
.
inline
()],
version
:
(
current
&&
current
.
version
)
||
constants
.
BLOCK_GENERATED_VERSION
},
this
.
conf
,
this
.
dal
);
if
(
byAbsorption
!==
BY_ABSORPTION
)
{
if
(
!
(
await
this
.
dal
.
idtyDAL
.
sandbox
.
acceptNewSandBoxEntry
({
await
GLOBAL_RULES_FUNCTIONS
.
checkIdentitiesAreWritable
({
identities
:
[
idtyObj
.
inline
()],
version
:
(
current
&&
current
.
version
)
||
constants
.
BLOCK_GENERATED_VERSION
},
this
.
conf
,
this
.
dal
);
if
(
byAbsorption
!==
BY_ABSORPTION
)
{
if
(
!
(
await
this
.
dal
.
idtyDAL
.
sandbox
.
acceptNewSandBoxEntry
({
certsCount
:
0
,
issuers
:
[
idty
.
pubkey
],
ref_block
:
parseInt
(
idty
.
buid
.
split
(
'
-
'
)[
0
])
},
this
.
conf
.
pair
&&
this
.
conf
.
pair
.
pub
)))
{
throw
constants
.
ERRORS
.
SANDBOX_FOR_IDENTITY_IS_FULL
;
throw
constants
.
ERRORS
.
SANDBOX_FOR_IDENTITY_IS_FULL
;
}
}
await
this
.
dal
.
savePendingIdentity
(
toSave
)
this
.
logger
.
info
(
'
✔ IDTY %s %s
'
,
idty
.
pubkey
,
idty
.
uid
);
return
toSave
}
await
this
.
dal
.
savePendingIdentity
(
toSave
)
this
.
logger
.
info
(
'
✔
IDTY %s %s
'
,
idty
.
pubkey
,
idty
.
uid
);
return
toSav
e
}
catch
(
e
)
{
this
.
logger
.
info
(
'
✘
IDTY %s %s
'
,
idty
.
pubkey
,
idty
.
uid
);
throw
e
}
})
}
...
...
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