Rename .public_key attributes to .multihash for consistency
This commit is contained in:
parent
6d6e8ffa37
commit
dd7456cc88
|
@ -46,7 +46,8 @@ Eg: `pigeon identity show` becomes `./pigeon-cli show`.
|
||||||
- [X] Implement pigeon message find-all for peer feed. I will need to add index for `author => message_count`
|
- [X] Implement pigeon message find-all for peer feed. I will need to add index for `author => message_count`
|
||||||
- [X] Switch to Crockford base32- Simplifies support for legacy systems. Easy to implement.
|
- [X] Switch to Crockford base32- Simplifies support for legacy systems. Easy to implement.
|
||||||
- [X] Fix `scratchpad.sh` to use Base32
|
- [X] Fix `scratchpad.sh` to use Base32
|
||||||
- [ ] Rename (RemoteIdentity|LocalIdentity)#public_key to #multihash for consistency with other types.
|
- [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`.
|
- [ ] refactor `Bundle.create` to use `message find-all`.
|
||||||
- [ ] Need a way of importing / exporting a feeds blobs. (see "Bundle Brainstorming" below)
|
- [ ] 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)
|
- [ ] Need a way of adding peers messages / gossip to bundles. (see "Bundle Brainstorming" below)
|
||||||
|
|
|
@ -117,7 +117,7 @@ module Pigeon
|
||||||
def self.verify_string(identity, string_signature, string)
|
def self.verify_string(identity, string_signature, string)
|
||||||
binary_signature = decode_multihash(string_signature)
|
binary_signature = decode_multihash(string_signature)
|
||||||
|
|
||||||
string_key = identity.public_key
|
string_key = identity.multihash
|
||||||
binary_key = decode_multihash(string_key)
|
binary_key = decode_multihash(string_key)
|
||||||
verify_key = Ed25519::VerifyKey.new(binary_key)
|
verify_key = Ed25519::VerifyKey.new(binary_key)
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ module Pigeon
|
||||||
author = Pigeon::LocalIdentity.current
|
author = Pigeon::LocalIdentity.current
|
||||||
range = (0...last).to_a
|
range = (0...last).to_a
|
||||||
content = range
|
content = range
|
||||||
.map { |depth| s.get_message_by_depth(author.public_key, depth) }
|
.map { |depth| s.get_message_by_depth(author.multihash, depth) }
|
||||||
.map { |multihash| s.find_message(multihash) }
|
.map { |multihash| s.find_message(multihash) }
|
||||||
.map { |message| message.render }
|
.map { |message| message.render }
|
||||||
.join(BUNDLE_MESSAGE_SEPARATOR)
|
.join(BUNDLE_MESSAGE_SEPARATOR)
|
||||||
|
|
|
@ -30,11 +30,11 @@ module Pigeon
|
||||||
@private_key ||= Helpers.b32_encode(@seed)
|
@private_key ||= Helpers.b32_encode(@seed)
|
||||||
end
|
end
|
||||||
|
|
||||||
def public_key
|
def multihash
|
||||||
bytes = @signing_key.verify_key.to_bytes
|
bytes = @signing_key.verify_key.to_bytes
|
||||||
b64 = Helpers.b32_encode(bytes)
|
b64 = Helpers.b32_encode(bytes)
|
||||||
|
|
||||||
@public_key ||= [IDENTITY_SIGIL, b64, IDENTITY_FOOTER].join("")
|
@multihash ||= [IDENTITY_SIGIL, b64, IDENTITY_FOOTER].join("")
|
||||||
end
|
end
|
||||||
|
|
||||||
def sign(string)
|
def sign(string)
|
||||||
|
|
|
@ -12,9 +12,9 @@ module Pigeon
|
||||||
author = LocalIdentity.current
|
author = LocalIdentity.current
|
||||||
depth = Pigeon::Storage
|
depth = Pigeon::Storage
|
||||||
.current
|
.current
|
||||||
.get_message_count_for(author.public_key)
|
.get_message_count_for(author.multihash)
|
||||||
count = store.get_message_count_for(author.public_key)
|
count = store.get_message_count_for(author.multihash)
|
||||||
prev = store.get_message_by_depth(author.public_key, count - 1)
|
prev = store.get_message_by_depth(author.multihash, count - 1)
|
||||||
msg = self.new(author: author,
|
msg = self.new(author: author,
|
||||||
kind: draft.kind,
|
kind: draft.kind,
|
||||||
body: draft.body,
|
body: draft.body,
|
||||||
|
@ -65,8 +65,8 @@ module Pigeon
|
||||||
end
|
end
|
||||||
|
|
||||||
def verify_depth_prev_and_depth
|
def verify_depth_prev_and_depth
|
||||||
count = store.get_message_count_for(author.public_key)
|
count = store.get_message_count_for(author.multihash)
|
||||||
expected_prev = store.get_message_by_depth(author.public_key, count - 1) || Pigeon::EMPTY_MESSAGE
|
expected_prev = store.get_message_by_depth(author.multihash, count - 1) || Pigeon::EMPTY_MESSAGE
|
||||||
assert("depth", count, depth)
|
assert("depth", count, depth)
|
||||||
assert("prev", prev, expected_prev)
|
assert("prev", prev, expected_prev)
|
||||||
end
|
end
|
||||||
|
|
|
@ -21,7 +21,7 @@ module Pigeon
|
||||||
private
|
private
|
||||||
|
|
||||||
def do_render(template)
|
def do_render(template)
|
||||||
author = message.author.public_key
|
author = message.author.multihash
|
||||||
body = message.body
|
body = message.body
|
||||||
depth = message.depth
|
depth = message.depth
|
||||||
kind = message.kind
|
kind = message.kind
|
||||||
|
|
|
@ -6,10 +6,10 @@ module Pigeon
|
||||||
# help us maintain our sanity when the Gem's API
|
# help us maintain our sanity when the Gem's API
|
||||||
# changes.
|
# changes.
|
||||||
class RemoteIdentity
|
class RemoteIdentity
|
||||||
attr_reader :public_key
|
attr_reader :multihash
|
||||||
|
|
||||||
def initialize(multihash)
|
def initialize(multihash)
|
||||||
@public_key = multihash
|
@multihash = multihash
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -136,7 +136,7 @@ module Pigeon
|
||||||
end
|
end
|
||||||
|
|
||||||
def insert_and_update_index(message)
|
def insert_and_update_index(message)
|
||||||
pub_key = message.author.public_key
|
pub_key = message.author.multihash
|
||||||
# STEP 1: Update MESG_NS, the main storage spot.
|
# STEP 1: Update MESG_NS, the main storage spot.
|
||||||
store[MESG_NS][message.multihash] = message
|
store[MESG_NS][message.multihash] = message
|
||||||
|
|
||||||
|
|
10
pigeon-cli
10
pigeon-cli
|
@ -32,13 +32,13 @@ module Pigeon
|
||||||
end
|
end
|
||||||
kp = Pigeon::LocalIdentity.new()
|
kp = Pigeon::LocalIdentity.new()
|
||||||
kp.save!
|
kp.save!
|
||||||
puts kp.public_key
|
puts kp.multihash
|
||||||
end
|
end
|
||||||
|
|
||||||
desc "show", "Prints your identiy string to STDOUT"
|
desc "show", "Prints your identiy string to STDOUT"
|
||||||
|
|
||||||
def show
|
def show
|
||||||
puts Pigeon::LocalIdentity.current.public_key
|
puts Pigeon::LocalIdentity.current.multihash
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -138,7 +138,7 @@ module Pigeon
|
||||||
|
|
||||||
desc "find-all", "Find a pigeon message in the local DB"
|
desc "find-all", "Find a pigeon message in the local DB"
|
||||||
|
|
||||||
def find_all(author = Pigeon::LocalIdentity.current.public_key)
|
def find_all(author = Pigeon::LocalIdentity.current.multihash)
|
||||||
# TODO: Ability to find-all messages by author ID
|
# TODO: Ability to find-all messages by author ID
|
||||||
puts Pigeon::Storage
|
puts Pigeon::Storage
|
||||||
.current
|
.current
|
||||||
|
@ -151,7 +151,7 @@ module Pigeon
|
||||||
def last
|
def last
|
||||||
me = Pigeon::LocalIdentity.current
|
me = Pigeon::LocalIdentity.current
|
||||||
store = Pigeon::Storage.current
|
store = Pigeon::Storage.current
|
||||||
multihash = store.get_message_by_depth(me.public_key, store.message_count - 1)
|
multihash = store.get_message_by_depth(me.multihash, store.message_count - 1)
|
||||||
puts multihash
|
puts multihash
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -166,7 +166,7 @@ module Pigeon
|
||||||
_) ( Peers: #{Pigeon::Storage.current.all_peers.count}
|
_) ( Peers: #{Pigeon::Storage.current.all_peers.count}
|
||||||
/ ) Blocked: #{Pigeon::Storage.current.all_blocks.count}
|
/ ) Blocked: #{Pigeon::Storage.current.all_blocks.count}
|
||||||
/_,' / Logs: #{Pigeon::Storage.current.message_count}
|
/_,' / Logs: #{Pigeon::Storage.current.message_count}
|
||||||
\\ / Ident: #{Pigeon::LocalIdentity.current.public_key}
|
\\ / Ident: #{Pigeon::LocalIdentity.current.multihash}
|
||||||
===m" "m===
|
===m" "m===
|
||||||
"
|
"
|
||||||
end
|
end
|
||||||
|
|
|
@ -25,7 +25,7 @@ RSpec.describe Pigeon::Draft do
|
||||||
].join("\n")
|
].join("\n")
|
||||||
|
|
||||||
it "renders a message" do
|
it "renders a message" do
|
||||||
pk = Pigeon::LocalIdentity.current.public_key
|
pk = Pigeon::LocalIdentity.current.multihash
|
||||||
actual = message.render
|
actual = message.render
|
||||||
expected = MSG.gsub("___", pk)
|
expected = MSG.gsub("___", pk)
|
||||||
expect(actual).to start_with(expected)
|
expect(actual).to start_with(expected)
|
||||||
|
|
|
@ -139,7 +139,7 @@ RSpec.describe Pigeon::Lexer do
|
||||||
h
|
h
|
||||||
end
|
end
|
||||||
|
|
||||||
expect(hash[:AUTHOR]).to eq(message.author.public_key)
|
expect(hash[:AUTHOR]).to eq(message.author.multihash)
|
||||||
expect(hash[:BODY]).to eq(message.body)
|
expect(hash[:BODY]).to eq(message.body)
|
||||||
expect(hash[:DEPTH]).to eq(message.depth)
|
expect(hash[:DEPTH]).to eq(message.depth)
|
||||||
expect(hash[:KIND]).to eq(message.kind)
|
expect(hash[:KIND]).to eq(message.kind)
|
||||||
|
|
|
@ -17,7 +17,7 @@ RSpec.describe Pigeon::LocalIdentity do
|
||||||
|
|
||||||
it "generates a pair from a seed" do
|
it "generates a pair from a seed" do
|
||||||
x = "@XSZY1ME6QMA5BBSJ8QSDJCSG6EVDTCKYNMV221SB7B2NZR5K09J0.ed25519"
|
x = "@XSZY1ME6QMA5BBSJ8QSDJCSG6EVDTCKYNMV221SB7B2NZR5K09J0.ed25519"
|
||||||
expect(kp.public_key).to eq(x)
|
expect(kp.multihash).to eq(x)
|
||||||
y = "2PRTG7F13HWF1HPW9FF9NDSYGSQS5VXQ2WMZY0A510J64AE9G840"
|
y = "2PRTG7F13HWF1HPW9FF9NDSYGSQS5VXQ2WMZY0A510J64AE9G840"
|
||||||
expect(kp.private_key).to eq(y)
|
expect(kp.private_key).to eq(y)
|
||||||
end
|
end
|
||||||
|
|
|
@ -54,7 +54,7 @@ RSpec.describe Pigeon::Message do
|
||||||
"",
|
"",
|
||||||
"signature __SIGNATURE__",
|
"signature __SIGNATURE__",
|
||||||
].join("\n")
|
].join("\n")
|
||||||
.gsub("__AUTHOR__", message.author.public_key)
|
.gsub("__AUTHOR__", message.author.multihash)
|
||||||
.gsub("__SIGNATURE__", message.signature)
|
.gsub("__SIGNATURE__", message.signature)
|
||||||
expect(actual).to eq(expected)
|
expect(actual).to eq(expected)
|
||||||
end
|
end
|
||||||
|
|
|
@ -52,7 +52,7 @@ RSpec.describe Pigeon::Storage do
|
||||||
|
|
||||||
it "finds all authored by a particular feed" do
|
it "finds all authored by a particular feed" do
|
||||||
ingested_messages = Pigeon::Bundle.ingest("./spec/fixtures/normal.bundle")
|
ingested_messages = Pigeon::Bundle.ingest("./spec/fixtures/normal.bundle")
|
||||||
author = ingested_messages.first.author.public_key
|
author = ingested_messages.first.author.multihash
|
||||||
actual_messages = Pigeon::Storage.current.find_all(author)
|
actual_messages = Pigeon::Storage.current.find_all(author)
|
||||||
search_results = Pigeon::Storage.current.find_all(author)
|
search_results = Pigeon::Storage.current.find_all(author)
|
||||||
end
|
end
|
||||||
|
@ -67,10 +67,10 @@ RSpec.describe Pigeon::Storage do
|
||||||
"e" => Pigeon::Storage.current.set_blob(File.read("./logo.png")),
|
"e" => Pigeon::Storage.current.set_blob(File.read("./logo.png")),
|
||||||
}),
|
}),
|
||||||
Pigeon::Helpers.create_message("g", {
|
Pigeon::Helpers.create_message("g", {
|
||||||
"me_myself_and_i" => Pigeon::LocalIdentity.current.public_key,
|
"me_myself_and_i" => Pigeon::LocalIdentity.current.multihash,
|
||||||
}),
|
}),
|
||||||
]
|
]
|
||||||
me = Pigeon::LocalIdentity.current.public_key
|
me = Pigeon::LocalIdentity.current.multihash
|
||||||
results = Pigeon::Storage.current.find_all(me)
|
results = Pigeon::Storage.current.find_all(me)
|
||||||
expect(results.length).to eq(3)
|
expect(results.length).to eq(3)
|
||||||
expect(msgs[0].multihash).to eq(results[0])
|
expect(msgs[0].multihash).to eq(results[0])
|
||||||
|
|
|
@ -12,7 +12,7 @@ RSpec.describe Pigeon::MessageSerializer do
|
||||||
EXPECTED_DRAFT = TOP_HALF + BOTTOM_HALF
|
EXPECTED_DRAFT = TOP_HALF + BOTTOM_HALF
|
||||||
|
|
||||||
class FakeLocalIdentity
|
class FakeLocalIdentity
|
||||||
def self.public_key
|
def self.multihash
|
||||||
"FAKE_AUTHOR"
|
"FAKE_AUTHOR"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue