This results in _localPeer.generate returning the result of a database operation in the property {peerId} when no existing localPeer exists, but if a localPeer already exists, the function errors and returns the peerId itself and not an object:
So basically _localPeers.generate has an inconsistent return type for {peerId}. Sometimes {peerId} is a string and if the localPeer creation succeeds it is an object.
On initial generation of a
localPeer
:https://github.com/digitalbazaar/bedrock-ledger-consensus-continuity/blob/52ac4a1b48e618df0cc649833b1033d41e32a657/lib/localPeers.js#L56-L68
localPeer.generate
returns the result of_generateLocalPeer
._generateLocalPeer
returns the result ofapi.storage.add
https://github.com/digitalbazaar/bedrock-ledger-consensus-continuity/blob/52ac4a1b48e618df0cc649833b1033d41e32a657/lib/localPeers.js#L245-L255
api.storage.add
returns the result of the mongodb operation:https://github.com/digitalbazaar/bedrock-ledger-consensus-continuity/blob/52ac4a1b48e618df0cc649833b1033d41e32a657/lib/localPeers.js#L168-L193
This results in
_localPeer.generate
returning the result of a database operation in the property{peerId}
when no existing localPeer exists, but if a localPeer already exists, the function errors and returns the peerId itself and not an object:https://github.com/digitalbazaar/bedrock-ledger-consensus-continuity/blob/52ac4a1b48e618df0cc649833b1033d41e32a657/lib/localPeers.js#L257-L260
So basically
_localPeers.generate
has an inconsistent return type for{peerId}
. Sometimes{peerId}
is a string and if the localPeer creation succeeds it is an object.