func ListBlock(apiClient pfs.BlockAPIClient) ([]*pfs.BlockInfo, error) { blockInfos, err := apiClient.ListBlock( context.Background(), &pfs.ListBlockRequest{}, ) if err != nil { return nil, err } return blockInfos.BlockInfo, nil }
func PutBlock(apiClient pfs.BlockAPIClient, reader io.Reader) (*pfs.BlockRefs, error) { putBlockClient, err := apiClient.PutBlock(context.Background()) if err != nil { return nil, err } if _, err := io.Copy(protostream.NewStreamingBytesWriter(putBlockClient), reader); err != nil { return nil, err } return putBlockClient.CloseAndRecv() }
func InspectBlock(apiClient pfs.BlockAPIClient, hash string) (*pfs.BlockInfo, error) { blockInfo, err := apiClient.InspectBlock( context.Background(), &pfs.InspectBlockRequest{ Block: NewBlock(hash), }, ) if err != nil { return nil, err } return blockInfo, nil }
func GetBlock(apiClient pfs.BlockAPIClient, hash string, offsetBytes uint64, sizeBytes uint64) (io.Reader, error) { apiGetBlockClient, err := apiClient.GetBlock( context.Background(), &pfs.GetBlockRequest{ Block: NewBlock(hash), OffsetBytes: offsetBytes, SizeBytes: sizeBytes, }, ) if err != nil { return nil, err } return protostream.NewStreamingBytesReader(apiGetBlockClient), nil }