a97ed10d0b
This commit introduces an api.Cid type and replaces the usage of cid.Cid everywhere. The main motivation here is to override MarshalJSON so that Cids are JSON-ified as '"Qm...."' instead of '{ "/": "Qm....." }', as this "ipld" representation of IDs is horrible to work with, and our APIs are not issuing IPLD objects to start with. Unfortunately, there is no way to do this cleanly, and the best way is to just switch everything to our own type.
28 lines
474 B
Go
28 lines
474 B
Go
package state
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/ipfs/ipfs-cluster/api"
|
|
)
|
|
|
|
type empty struct{}
|
|
|
|
func (e *empty) List(ctx context.Context, out chan<- api.Pin) error {
|
|
close(out)
|
|
return nil
|
|
}
|
|
|
|
func (e *empty) Has(ctx context.Context, c api.Cid) (bool, error) {
|
|
return false, nil
|
|
}
|
|
|
|
func (e *empty) Get(ctx context.Context, c api.Cid) (api.Pin, error) {
|
|
return api.Pin{}, ErrNotFound
|
|
}
|
|
|
|
// Empty returns an empty read-only state.
|
|
func Empty() ReadOnly {
|
|
return &empty{}
|
|
}
|