func ListBlock(apiClient drive.APIClient) ([]*drive.BlockInfo, error) { blockInfos, err := apiClient.ListBlock( context.Background(), &drive.ListBlockRequest{}, ) if err != nil { return nil, err } return blockInfos.BlockInfo, nil }
func PutBlock(apiClient drive.APIClient, reader io.Reader) (*drive.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 drive.APIClient, hash string) (*drive.BlockInfo, error) { blockInfo, err := apiClient.InspectBlock( context.Background(), &drive.InspectBlockRequest{ Block: &drive.Block{ Hash: hash, }, }, ) if err != nil { return nil, err } return blockInfo, nil }
func GetBlock(apiClient drive.APIClient, hash string, offsetBytes uint64) (io.Reader, error) { apiGetBlockClient, err := apiClient.GetBlock( context.Background(), &drive.GetBlockRequest{ Block: &drive.Block{ Hash: hash, }, OffsetBytes: offsetBytes, }, ) if err != nil { return nil, err } return protostream.NewStreamingBytesReader(apiGetBlockClient), nil }