v0.0.6- Fix `find-all` to actually find-all. Improve `status` output
This commit is contained in:
parent
638ce7c9b0
commit
a684f93768
12
README.md
12
README.md
|
@ -76,15 +76,15 @@ TODO
|
|||
- [X] Clean up all singletons / .current hacks
|
||||
- [X] Reduce cross cutting where collaborating objects need access to `@db`
|
||||
- [X] Ensure all disks writes perform verification!
|
||||
- [ ] Make CLI names consistent with API names. Eg: find vs. read.
|
||||
- [ ] Add log count to `pigeon-cli status`
|
||||
- [ ] Name bundles after their hash?
|
||||
- [ ] `find-all` should....find all. Currently finds all for your messages.
|
||||
- [ ] Update README.md. Needs user manual for new `Pigeon::Database` class.
|
||||
- [X] Make CLI names consistent with API names. Eg: find vs. read.
|
||||
- [X] `find-all` should....find all. Currently finds your messages or maybe peers, but not all.
|
||||
- [X] Add log count to `pigeon-cli status`
|
||||
- [ ] Delete `Draft#put` entirely.
|
||||
- [ ] Check block list before ingesting bundles.
|
||||
- [ ] Update README.md / tutorial.rb (user manual for `Pigeon::Database`).
|
||||
- [ ] Make the switch to LevelDB, RocksDB, [UNQLite](https://unqlite.org/features.html) or similar (currently using Ruby PStore).
|
||||
- [ ] 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)
|
||||
- [ ] Check block list before ingesting bundles.
|
||||
- [ ] add parsers and validators for all CLI inputs
|
||||
- [ ] Reduce whole darn repo into single module to aide portability. `::Helpers` module is OK.
|
||||
- [ ] Update the bundles.md document once `bundle consume` works.
|
||||
|
|
|
@ -149,9 +149,9 @@ module Pigeon
|
|||
puts db.read_message(multihash).render
|
||||
end
|
||||
|
||||
desc "find-all", "Find a pigeon message in the local DB"
|
||||
desc "find-all", "Find all message IDs of a particular identity."
|
||||
|
||||
def find_all(author = db.local_identity.multihash)
|
||||
def find_all(author = nil)
|
||||
puts db.find_all_messages(author).join(Pigeon::CR) + Pigeon::CR
|
||||
end
|
||||
|
||||
|
@ -170,15 +170,17 @@ module Pigeon
|
|||
|
||||
def status
|
||||
me = db.local_identity.multihash
|
||||
mcount = db.get_message_count_for(me)
|
||||
mine = db.get_message_count_for(me)
|
||||
puts "
|
||||
-`. Pigeon Protocol Ruby Client
|
||||
'( @ > Version: #{Pigeon::VERSION}
|
||||
_) ( Peers: #{db.all_peers.count}
|
||||
/ ) Blocked: #{db.all_blocks.count}
|
||||
/_,' / Published: #{mcount}
|
||||
\\ / Ident: #{me}
|
||||
===m" "m===
|
||||
-`. Pigeon Protocol Ruby Client
|
||||
'( @ > Version: #{Pigeon::VERSION}
|
||||
_) ( Peers: #{db.all_peers.count}
|
||||
/ ) Blocked: #{db.all_blocks.count}
|
||||
/_,' / Msgs Published: #{mine}
|
||||
\\ / Msgs Total: #{db.find_all_messages.count}
|
||||
===m\" \"m===
|
||||
Your local identity hash:
|
||||
#{me}
|
||||
"
|
||||
end
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ pigeon-cli peer block @41FNE08J5XK9GEV1BTEPT15WW1KDK5XCC8SMM62MQNYZ0785NJ80.ed25
|
|||
echo "listing all peers:"
|
||||
pigeon-cli peer all
|
||||
|
||||
echo "Making a new `scratch_pad` log entry"
|
||||
echo "Making a new 'scratch_pad' log entry"
|
||||
pigeon-cli draft create scratch_pad
|
||||
|
||||
echo "Appending values..."
|
||||
|
|
|
@ -11,7 +11,7 @@ module Pigeon
|
|||
def all_blocks(); store.all_blocks(); end
|
||||
def all_peers(); store.all_peers(); end
|
||||
def block_peer(p); store.block_peer(p); end
|
||||
def find_all_messages(mhash); store.find_all_messages(mhash); end
|
||||
def find_all_messages(mhash = nil); store.find_all_messages(mhash); end
|
||||
def get_blob(b); store.get_blob(b); end
|
||||
def get_config(k); store.get_config(k); end
|
||||
def message?(multihash); store.message?(multihash); end
|
||||
|
@ -104,7 +104,6 @@ module Pigeon
|
|||
else
|
||||
new_seed = SecureRandom.random_bytes(Ed25519::KEY_SIZE)
|
||||
set_config(SEED_CONFIG_KEY, new_seed)
|
||||
binding.pry unless get_config(SEED_CONFIG_KEY).is_a?(String)
|
||||
@local_identity = LocalIdentity.new(new_seed)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -75,14 +75,18 @@ module Pigeon
|
|||
end
|
||||
|
||||
def find_all_messages(author)
|
||||
all = []
|
||||
depth = -1
|
||||
last = ""
|
||||
until (last == nil) || (depth > 99999)
|
||||
last = self.get_message_by_depth(author, depth += 1)
|
||||
all.push(last) if last
|
||||
if author
|
||||
all = []
|
||||
depth = -1
|
||||
last = ""
|
||||
until (last == nil) || (depth > 99999)
|
||||
last = self.get_message_by_depth(author, depth += 1)
|
||||
all.push(last) if last
|
||||
end
|
||||
return all
|
||||
else
|
||||
read { store["messages"].keys }
|
||||
end
|
||||
return all
|
||||
end
|
||||
|
||||
def get_message_by_depth(multihash, depth)
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
module Pigeon
|
||||
VERSION = "0.0.5"
|
||||
VERSION = "0.0.6"
|
||||
end
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
require "pigeon"
|
||||
require "pry"
|
||||
|
||||
db = Pigeon::Database.new(path: "my.db")
|
||||
|
||||
db.create_draft
|
||||
db.current_draft
|
||||
db.discard_draft
|
||||
db.publish_draft
|
||||
db.save_draft
|
||||
db.save_message
|
||||
db.reset_current_draft
|
||||
db.message?
|
||||
db.read_message
|
||||
db.create_message
|
||||
db.find_all_messages
|
||||
db.get_message_by_depth
|
||||
db.get_message_count_for
|
||||
db.local_identity
|
||||
db.remove_peer
|
||||
db.add_peer
|
||||
db.block_peer
|
||||
db.all_peers
|
||||
db.all_blocks
|
||||
db.get_blob
|
||||
db.put_blob
|
||||
db.create_bundle
|
||||
db.get_config
|
||||
db.ingest_bundle
|
||||
db.set_config
|
||||
db.reset_database
|
||||
|
||||
binding.pry
|
Loading…
Reference in New Issue