Whoops, ingestion actually does *not* work. Maybe the .chomp
in #render is tainting signatures?
This commit is contained in:
parent
75a4492acf
commit
1348433d2f
7
dist/pigeon/bundle.rb
vendored
7
dist/pigeon/bundle.rb
vendored
|
@ -16,12 +16,7 @@ module Pigeon
|
||||||
def self.ingest(file_path)
|
def self.ingest(file_path)
|
||||||
bundle = File.read(file_path)
|
bundle = File.read(file_path)
|
||||||
tokens = Pigeon::Lexer.tokenize(bundle)
|
tokens = Pigeon::Lexer.tokenize(bundle)
|
||||||
Pigeon::Parser.parse(tokens)
|
Pigeon::Parser.parse(tokens).map(&:save!)
|
||||||
end
|
|
||||||
|
|
||||||
private
|
|
||||||
|
|
||||||
def initialize
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
10
dist/pigeon/message.rb
vendored
10
dist/pigeon/message.rb
vendored
|
@ -20,7 +20,7 @@ module Pigeon
|
||||||
body: draft.body,
|
body: draft.body,
|
||||||
depth: depth,
|
depth: depth,
|
||||||
prev: prev)
|
prev: prev)
|
||||||
msg.sign!
|
msg.save!
|
||||||
draft.discard
|
draft.discard
|
||||||
msg
|
msg
|
||||||
end
|
end
|
||||||
|
@ -45,15 +45,11 @@ module Pigeon
|
||||||
"#{MESSAGE_SIGIL}#{sha256}#{BLOB_FOOTER}"
|
"#{MESSAGE_SIGIL}#{sha256}#{BLOB_FOOTER}"
|
||||||
end
|
end
|
||||||
|
|
||||||
def verify!
|
def save!
|
||||||
|
calculate_signature
|
||||||
verify_depth_prev_and_depth
|
verify_depth_prev_and_depth
|
||||||
verify_signature
|
verify_signature
|
||||||
self.freeze
|
self.freeze
|
||||||
end
|
|
||||||
|
|
||||||
def sign!
|
|
||||||
calculate_signature
|
|
||||||
verify!
|
|
||||||
store.save_message(self)
|
store.save_message(self)
|
||||||
self
|
self
|
||||||
end
|
end
|
||||||
|
|
11
dist/pigeon/storage.rb
vendored
11
dist/pigeon/storage.rb
vendored
|
@ -2,15 +2,15 @@ require "pstore"
|
||||||
|
|
||||||
module Pigeon
|
module Pigeon
|
||||||
class Storage
|
class Storage
|
||||||
|
def self.current
|
||||||
|
@current ||= self.new
|
||||||
|
end
|
||||||
|
|
||||||
def self.reset
|
def self.reset
|
||||||
File.delete(PIGEON_DB_PATH) if File.file?(PIGEON_DB_PATH)
|
File.delete(PIGEON_DB_PATH) if File.file?(PIGEON_DB_PATH)
|
||||||
@current = nil
|
@current = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.current
|
|
||||||
@current ||= self.new
|
|
||||||
end
|
|
||||||
|
|
||||||
def get_message_by_depth(multihash, depth)
|
def get_message_by_depth(multihash, depth)
|
||||||
raise "Expected string, got #{multihash.class}" unless multihash.is_a?(String) # Delete later
|
raise "Expected string, got #{multihash.class}" unless multihash.is_a?(String) # Delete later
|
||||||
# Map<[multihash(str), depth(int)], Signature>
|
# Map<[multihash(str), depth(int)], Signature>
|
||||||
|
@ -40,9 +40,8 @@ module Pigeon
|
||||||
read { store[MESG_NS].fetch(multihash) }
|
read { store[MESG_NS].fetch(multihash) }
|
||||||
end
|
end
|
||||||
|
|
||||||
def find_all
|
def find_all(author = Pigeon::LocalIdentity.current)
|
||||||
# TODO: Ability to pass an author ID to `find-all`
|
# TODO: Ability to pass an author ID to `find-all`
|
||||||
author = Pigeon::LocalIdentity.current
|
|
||||||
store = Pigeon::Storage.current
|
store = Pigeon::Storage.current
|
||||||
all = []
|
all = []
|
||||||
depth = -1
|
depth = -1
|
||||||
|
|
|
@ -45,4 +45,12 @@ RSpec.describe Pigeon::Storage do
|
||||||
expect(s.all_blocks).to include(IDS[1])
|
expect(s.all_blocks).to include(IDS[1])
|
||||||
expect(s.all_blocks.count).to eq(1)
|
expect(s.all_blocks.count).to eq(1)
|
||||||
end
|
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
|
end
|
||||||
|
|
Loading…
Reference in New Issue
Block a user