Skip to content

Class BSV::KVStore::Global

Inherits: Object

Read-only client for the global KVStore overlay service.

Queries the ls_kvstore lookup service via a {BSV::Overlay::LookupResolver}, decodes PushDrop tokens (5-field legacy and 6-field current formats), verifies the token signature, and returns typed {Entry} objects.

Set/remove operations require wallet writes and are out of scope — those live in the bsv-wallet gem.

Selector requirement

{#get} raises ArgumentError unless at least one of key, controller, protocol_id, or a non-empty tags array is supplied in the query.

Always returns Array

{#get} always returns +Array+, even for single-result selectors such as +key + controller+. Callers that expect at most one result should use .first.

Silent skipping

Outputs that fail BEEF parsing, PushDrop decoding, field-count validation, or signature verification are silently skipped (matching the TS SDK contract).

Public Instance Methods

get(query, include_token: = false, history: = false)

Query the overlay for KVStore entries. - @param query [Hash] selector: +:key+, +:controller+, +:protocol_id+, +:tags+, +:tag_query_mode+. At least one of the first four must be present. - @param include_token [Boolean] populate {Token} on each entry when true - @param history [Boolean] populate history via {BSV::Overlay::Historian} when true - @raise [ArgumentError] if no selector is provided - @return [Array] matching entries (empty array when nothing matches)

initialize(network_preset: = :mainnet, lookup_resolver: = nil, service_name: = 'ls_kvstore', proto_wallet: = nil)

  • @param network_preset [Symbol] :mainnet, :testnet, or :local
  • @param lookup_resolver [BSV::Overlay::LookupResolver, nil] injectable resolver
  • @param service_name [String] lookup service identifier
  • @param proto_wallet [BSV::Wallet::ProtoWallet, nil] injectable wallet used for signature verification; defaults to +ProtoWallet.new('anyone')+. Tests can substitute a double to avoid +allow_any_instance_of+.
  • @return [Global] a new instance of Global