From 8a7eec964aebe6a56c7ce6415ca32d2b9575d88e Mon Sep 17 00:00:00 2001 From: Rick Carlino Date: Mon, 6 Apr 2020 07:32:19 -0500 Subject: [PATCH] Use `find_all` when creating bundles --- README.md | 6 +++--- dist/pigeon/bundle.rb | 8 +++----- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index c01792a..58dd5a7 100644 --- a/README.md +++ b/README.md @@ -47,11 +47,11 @@ Eg: `pigeon identity show` becomes `./pigeon-cli show`. - [X] Switch to Crockford base32- Simplifies support for legacy systems. Easy to implement. - [X] Fix `scratchpad.sh` to use Base32 - [X] Rename (RemoteIdentity|LocalIdentity)#public_key to #multihash for consistency with other types. - - [ ] Fix diagram in spec doc - - [ ] refactor `Bundle.create` to use `message find-all`. + - [X] Fix diagram in spec doc + - [X] refactor `Bundle.create` to use `message find-all`. + - [ ] Add Lipmaa links like the Bamboo folks do. - [ ] Need a way of importing / exporting a feeds blobs. (see "Bundle Brainstorming" below) - [ ] Need a way of adding peers messages / gossip to bundles. (see "Bundle Brainstorming" below) - - [ ] Add Lipmaa links like the Bamboo folks do. - [ ] Add mandatory `--since=` arg to `bundle create` - [ ] Make the switch to LevelDB, RocksDB or similar (currently using Ruby PStore). - [ ] Rename `message find` to `message read`, since other finders return a multihash. diff --git a/dist/pigeon/bundle.rb b/dist/pigeon/bundle.rb index f60c0b8..fd6f3de 100644 --- a/dist/pigeon/bundle.rb +++ b/dist/pigeon/bundle.rb @@ -2,12 +2,10 @@ module Pigeon class Bundle def self.create(file_path = DEFAULT_BUNDLE_PATH) s = Pigeon::Storage.current - last = s.message_count - author = Pigeon::LocalIdentity.current - range = (0...last).to_a - content = range - .map { |depth| s.get_message_by_depth(author.multihash, depth) } + content = s + .find_all(Pigeon::LocalIdentity.current.multihash) .map { |multihash| s.find_message(multihash) } + .sort_by(&:depth) .map { |message| message.render } .join(BUNDLE_MESSAGE_SEPARATOR) File.write(file_path, content + CR)