swarm: mock store listings (#19157)
* swarm/storage/mock: implement listings methods for mem and rpc stores * swarm/storage/mock/rpc: add comments and newTestStore helper function * swarm/storage/mock/mem: add missing comments * swarm/storage/mock: add comments to new types and constants * swarm/storage/mock/db: implement listings for mock/db global store * swarm/storage/mock/test: add comments for MockStoreListings * swarm/storage/mock/explorer: initial implementation * cmd/swarm/global-store: add chunk explorer * cmd/swarm/global-store: add chunk explorer tests * swarm/storage/mock/explorer: add tests * swarm/storage/mock/explorer: add swagger api definition * swarm/storage/mock/explorer: not-zero test values for invalid addr and key * swarm/storage/mock/explorer: test wildcard cors origin * swarm/storage/mock/db: renames based on Fabio's suggestions * swarm/storage/mock/explorer: add more comments to testHandler function * cmd/swarm/global-store: terminate subprocess with Kill in tests
This commit is contained in:
committed by
Viktor Trón
parent
02c28046a0
commit
64d10c0872
@@ -88,3 +88,27 @@ func (s *GlobalStore) HasKey(addr common.Address, key []byte) bool {
|
||||
}
|
||||
return has
|
||||
}
|
||||
|
||||
// Keys returns a paginated list of keys on all nodes.
|
||||
func (s *GlobalStore) Keys(startKey []byte, limit int) (keys mock.Keys, err error) {
|
||||
err = s.client.Call(&keys, "mockStore_keys", startKey, limit)
|
||||
return keys, err
|
||||
}
|
||||
|
||||
// Nodes returns a paginated list of all known nodes.
|
||||
func (s *GlobalStore) Nodes(startAddr *common.Address, limit int) (nodes mock.Nodes, err error) {
|
||||
err = s.client.Call(&nodes, "mockStore_nodes", startAddr, limit)
|
||||
return nodes, err
|
||||
}
|
||||
|
||||
// NodeKeys returns a paginated list of keys on a node with provided address.
|
||||
func (s *GlobalStore) NodeKeys(addr common.Address, startKey []byte, limit int) (keys mock.Keys, err error) {
|
||||
err = s.client.Call(&keys, "mockStore_nodeKeys", addr, startKey, limit)
|
||||
return keys, err
|
||||
}
|
||||
|
||||
// KeyNodes returns a paginated list of nodes that contain a particular key.
|
||||
func (s *GlobalStore) KeyNodes(key []byte, startAddr *common.Address, limit int) (nodes mock.Nodes, err error) {
|
||||
err = s.client.Call(&nodes, "mockStore_keyNodes", key, startAddr, limit)
|
||||
return nodes, err
|
||||
}
|
||||
|
Reference in New Issue
Block a user