From bfdce2f5ca404c0c7c5dec43c22fa62b1bd4583f Mon Sep 17 00:00:00 2001 From: Linus Nordberg Date: Tue, 28 Feb 2017 17:06:08 +0100 Subject: Rename a couple functions and variables; add two comments. --- src/catlfish.erl | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/catlfish.erl b/src/catlfish.erl index 04b3332..6d8d430 100644 --- a/src/catlfish.erl +++ b/src/catlfish.erl @@ -103,9 +103,9 @@ sct_data(TimestampedEntry) -> serialise_signature_type(certificate_timestamp), serialise(TimestampedEntry)]). -calc_sct(TimestampedEntry, Signatures) -> +calc_sct_sig(TimestampedEntry, Signatures) -> plop:serialise( - plop:spt(sct_data(TimestampedEntry), Signatures)). + plop:spt_sig(sct_data(TimestampedEntry), Signatures)). create_logentry(Type, LeafCert, CertChain) -> EntryType = case Type of @@ -126,16 +126,21 @@ get_ratelimit_token(Type) -> maybe_add_to_db(Hash, LogEntry, TimestampedEntry, HasEntry) -> - CachedSCTSig = plop:get_spt(Hash), - - case {HasEntry, CachedSCTSig} of - {true, SCT} when is_binary(SCT) -> - SCT; + CachedSCTSig = plop:get_spt_sig(Hash), + HasSig = is_binary(CachedSCTSig), + + case {HasEntry, HasSig} of + {true, true} -> + %% Entry is present in the database and a signature was + %% found in the SCT cache. + CachedSCTSig; _ -> + %% We don't have the entry or we don't have the SCT in the + %% cache. {ok, Signatures} = plop:add(LogEntry, Hash), - SCT = calc_sct(TimestampedEntry, Signatures), - plop:add_spt(Hash, SCT), - SCT + SCT_sig = calc_sct_sig(TimestampedEntry, Signatures), + ok = plop:add_spt_sig(Hash, SCT_sig), + SCT_sig end. -spec add_chain(binary(), [binary()], normal|precert) -> {[{_,_},...]}. -- cgit v1.1