diff --git a/README.md b/README.md index 0471ef0..56adb6e 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,9 @@ Eg: `pigeon identity show` becomes `./pigeon-cli show`. - [X] Put all the [HEADER, string, FOOTER].join("") nonsense into Pigeon::Helpers - [X] Use raw SHA256 hashes for blob multihashes, not hex. - [X] Change all the `{40,90}` values in ::Lexer to real length values - - [ ] Is it possible signature verification is failing beecause a CR is being prepended to the front? + - [X] Don't double-ingest messages. It will screw up indexes. + - [ ] Handle the three outcomes of bundle ingestion: `ok`, `blocked`, `already_saved`. + - [ ] Check blocklist before ingesting bundles. - [ ] Rename (RemoteIdentity|LocalIdentity)#public_key to #multihash for consistency with other types. - [ ] Rename `message find` to `message read`, since other finders return a multihash. - [ ] Don't allow carriage return in `kind` or `string` keys. Write a test for this. diff --git a/dist/pigeon/message.rb b/dist/pigeon/message.rb index 641de6a..6f705ae 100644 --- a/dist/pigeon/message.rb +++ b/dist/pigeon/message.rb @@ -46,6 +46,7 @@ module Pigeon end def save! + return store.find_message(multihash) if store.message?(multihash) calculate_signature verify_depth_prev_and_depth verify_signature @@ -66,7 +67,6 @@ module Pigeon def verify_depth_prev_and_depth count = store.get_message_count_for(author.public_key) expected_prev = store.get_message_by_depth(author.public_key, count - 1) || Pigeon::EMPTY_MESSAGE - assert("depth", depth, count) assert("prev", prev, expected_prev) end @@ -88,6 +88,7 @@ module Pigeon def calculate_signature return if @signature + #TODO: Verify that the author is Pigeon::LocalIdentity.current? @signature = author.sign(template.render_without_signature) end diff --git a/dist/pigeon/storage.rb b/dist/pigeon/storage.rb index 45b83a5..1d24c85 100644 --- a/dist/pigeon/storage.rb +++ b/dist/pigeon/storage.rb @@ -41,6 +41,10 @@ module Pigeon read { store[MESG_NS].fetch(multihash) } end + def message?(multihash) + read { store[MESG_NS].fetch(multihash, false) } + end + def find_all(author = Pigeon::LocalIdentity.current.public_key) # TODO: Ability to pass an author ID to `find-all` store = Pigeon::Storage.current diff --git a/spec/pigeon/bundle_spec.rb b/spec/pigeon/bundle_spec.rb index dca6658..c136a83 100644 --- a/spec/pigeon/bundle_spec.rb +++ b/spec/pigeon/bundle_spec.rb @@ -23,7 +23,6 @@ RSpec.describe Pigeon::Message do end it "debugs a problem" do - pending("Pigeon::Bundle.ingest is broke. Will fix after investigation.") seed = "\xA3@\x12\xA6\x8Cl\x83\xF5)\x97\xED\xE67\x91\xAD\xFD\xCFf\xF4(\xEF\x81P\xBBD\xF7\x8C\xF7\x8D\xC0\xA9\f" ident = Pigeon::LocalIdentity.new(seed) Pigeon::LocalIdentity.instance_variable_set(:@current, ident)