Whoops, ingestion actually does *not* work. Maybe the `.chomp` in #render is tainting signatures?

This commit is contained in:
Netscape Navigator 2020-03-31 07:46:11 -05:00
parent 75a4492acf
commit 1348433d2f
4 changed files with 17 additions and 19 deletions

View File

@ -16,12 +16,7 @@ module Pigeon
def self.ingest(file_path)
bundle = File.read(file_path)
tokens = Pigeon::Lexer.tokenize(bundle)
Pigeon::Parser.parse(tokens)
end
private
def initialize
Pigeon::Parser.parse(tokens).map(&:save!)
end
end
end

View File

@ -20,7 +20,7 @@ module Pigeon
body: draft.body,
depth: depth,
prev: prev)
msg.sign!
msg.save!
draft.discard
msg
end
@ -45,15 +45,11 @@ module Pigeon
"#{MESSAGE_SIGIL}#{sha256}#{BLOB_FOOTER}"
end
def verify!
def save!
calculate_signature
verify_depth_prev_and_depth
verify_signature
self.freeze
end
def sign!
calculate_signature
verify!
store.save_message(self)
self
end

View File

@ -2,15 +2,15 @@ require "pstore"
module Pigeon
class Storage
def self.current
@current ||= self.new
end
def self.reset
File.delete(PIGEON_DB_PATH) if File.file?(PIGEON_DB_PATH)
@current = nil
end
def self.current
@current ||= self.new
end
def get_message_by_depth(multihash, depth)
raise "Expected string, got #{multihash.class}" unless multihash.is_a?(String) # Delete later
# Map<[multihash(str), depth(int)], Signature>
@ -40,9 +40,8 @@ module Pigeon
read { store[MESG_NS].fetch(multihash) }
end
def find_all
def find_all(author = Pigeon::LocalIdentity.current)
# TODO: Ability to pass an author ID to `find-all`
author = Pigeon::LocalIdentity.current
store = Pigeon::Storage.current
all = []
depth = -1

View File

@ -45,4 +45,12 @@ RSpec.describe Pigeon::Storage do
expect(s.all_blocks).to include(IDS[1])
expect(s.all_blocks.count).to eq(1)
end
it "finds all authored by a particular feed" do
ingested_messages = Pigeon::Bundle.ingest("./example.bundle")
author = ingested_messages.first.author.public_key
actual_messages = Pigeon::Storage.current.find_all(author)
search_results = Pigeon::Storage.current.find_all(author)
binding.pry
end
end