refactor(datatransfer): implement style fixes
implement style fixes suggested by Magic6k
This commit is contained in:
parent
4b3bab371b
commit
311556346e
@ -151,10 +151,7 @@ func (c *ClientRequestValidator) ValidatePull(
|
|||||||
}
|
}
|
||||||
|
|
||||||
var deal ClientDeal
|
var deal ClientDeal
|
||||||
err := c.deals.Mutate(dealVoucher.Proposal, func(d *ClientDeal) error {
|
err := c.deals.Get(dealVoucher.Proposal, &deal)
|
||||||
deal = *d
|
|
||||||
return nil
|
|
||||||
})
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return xerrors.Errorf("Proposal CID %s: %w", dealVoucher.Proposal.String(), ErrNoDeal)
|
return xerrors.Errorf("Proposal CID %s: %w", dealVoucher.Proposal.String(), ErrNoDeal)
|
||||||
}
|
}
|
||||||
|
@ -167,10 +167,7 @@ func (m *ProviderRequestValidator) ValidatePush(
|
|||||||
}
|
}
|
||||||
|
|
||||||
var deal MinerDeal
|
var deal MinerDeal
|
||||||
err := m.deals.Mutate(dealVoucher.Proposal, func(d *MinerDeal) error {
|
err := m.deals.Get(dealVoucher.Proposal, &deal)
|
||||||
deal = *d
|
|
||||||
return nil
|
|
||||||
})
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return xerrors.Errorf("Proposal CID %s: %w", dealVoucher.Proposal.String(), ErrNoDeal)
|
return xerrors.Errorf("Proposal CID %s: %w", dealVoucher.Proposal.String(), ErrNoDeal)
|
||||||
}
|
}
|
||||||
|
@ -14,28 +14,28 @@ import (
|
|||||||
|
|
||||||
var (
|
var (
|
||||||
// ErrWrongVoucherType means the voucher was not the correct type can validate against
|
// ErrWrongVoucherType means the voucher was not the correct type can validate against
|
||||||
ErrWrongVoucherType = errors.New("cannot validate voucher type")
|
ErrWrongVoucherType = errors.New("cannot validate voucher type.")
|
||||||
|
|
||||||
// ErrNoPushAccepted just means clients do not accept pushes for storage deals
|
// ErrNoPushAccepted just means clients do not accept pushes for storage deals
|
||||||
ErrNoPushAccepted = errors.New("Client should not receive data for a storage deal")
|
ErrNoPushAccepted = errors.New("client should not receive data for a storage deal.")
|
||||||
|
|
||||||
// ErrNoPullAccepted just means providers do not accept pulls for storage deals
|
// ErrNoPullAccepted just means providers do not accept pulls for storage deals
|
||||||
ErrNoPullAccepted = errors.New("Provider should not send data for a storage deal")
|
ErrNoPullAccepted = errors.New("provider should not send data for a storage deal.")
|
||||||
|
|
||||||
// ErrNoDeal means no active deal was found for this vouchers proposal cid
|
// ErrNoDeal means no active deal was found for this vouchers proposal cid
|
||||||
ErrNoDeal = errors.New("No deal found for this proposal")
|
ErrNoDeal = errors.New("no deal found for this proposal.")
|
||||||
|
|
||||||
// ErrWrongPeer means that the other peer for this data transfer request does not match
|
// ErrWrongPeer means that the other peer for this data transfer request does not match
|
||||||
// the other peer for the deal
|
// the other peer for the deal
|
||||||
ErrWrongPeer = errors.New("Data Transfer peer id and Deal peer id do not match")
|
ErrWrongPeer = errors.New("data Transfer peer id and Deal peer id do not match.")
|
||||||
|
|
||||||
// ErrWrongPiece means that the pieceref for this data transfer request does not match
|
// ErrWrongPiece means that the pieceref for this data transfer request does not match
|
||||||
// the one specified in the deal
|
// the one specified in the deal
|
||||||
ErrWrongPiece = errors.New("Base CID for deal does not match CID for piece")
|
ErrWrongPiece = errors.New("base CID for deal does not match CID for piece.")
|
||||||
|
|
||||||
// ErrInacceptableDealState means the deal for this transfer is not in a deal state
|
// ErrInacceptableDealState means the deal for this transfer is not in a deal state
|
||||||
// where transfer can be performed
|
// where transfer can be performed
|
||||||
ErrInacceptableDealState = errors.New("Deal is not a in a state where deals are accepted")
|
ErrInacceptableDealState = errors.New("deal is not a in a state where deals are accepted.")
|
||||||
|
|
||||||
// DataTransferStates are the states in which it would make sense to actually start a data transfer
|
// DataTransferStates are the states in which it would make sense to actually start a data transfer
|
||||||
DataTransferStates = []api.DealState{api.DealAccepted, api.DealUnknown}
|
DataTransferStates = []api.DealState{api.DealAccepted, api.DealUnknown}
|
||||||
|
@ -23,20 +23,20 @@ type Voucher interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Status is the status of transfer for a given channel
|
// Status is the status of transfer for a given channel
|
||||||
type Status string
|
type Status int
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// Ongoing means the data transfer is in progress
|
// Ongoing means the data transfer is in progress
|
||||||
Ongoing = Status("Ongoing")
|
Ongoing Status = iota
|
||||||
|
|
||||||
// Completed means the data transfer is completed successfully
|
// Completed means the data transfer is completed successfully
|
||||||
Completed = Status("Completed")
|
Completed
|
||||||
|
|
||||||
// Failed means the data transfer failed
|
// Failed means the data transfer failed
|
||||||
Failed = Status("Failed")
|
Failed
|
||||||
|
|
||||||
// ChannelNotFoundError means the searched for data transfer does not exist
|
// ChannelNotFoundError means the searched for data transfer does not exist
|
||||||
ChannelNotFoundError = Status("ChannelNotFoundError")
|
ChannelNotFoundError
|
||||||
)
|
)
|
||||||
|
|
||||||
// TransferID is an identifier for a data transfer, shared between
|
// TransferID is an identifier for a data transfer, shared between
|
||||||
@ -106,20 +106,20 @@ func (c ChannelState) Sent() uint64 { return c.sent }
|
|||||||
func (c ChannelState) Received() uint64 { return c.received }
|
func (c ChannelState) Received() uint64 { return c.received }
|
||||||
|
|
||||||
// Event is a name for an event that occurs on a data transfer channel
|
// Event is a name for an event that occurs on a data transfer channel
|
||||||
type Event string
|
type Event int
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// Open is an event occurs when a channel is first opened
|
// Open is an event occurs when a channel is first opened
|
||||||
Open = Event("Open")
|
Open Event = iota
|
||||||
|
|
||||||
// Progress is an event that gets emitted every time more data is transferred
|
// Progress is an event that gets emitted every time more data is transferred
|
||||||
Progress = Event("Progress")
|
Progress
|
||||||
|
|
||||||
// Error is an event that emits when an error occurs in a data transfer
|
// Error is an event that emits when an error occurs in a data transfer
|
||||||
Error = Event("Error")
|
Error
|
||||||
|
|
||||||
// Complete is emitted when a data transfer is complete
|
// Complete is emitted when a data transfer is complete
|
||||||
Complete = Event("Complete")
|
Complete
|
||||||
)
|
)
|
||||||
|
|
||||||
// Subscriber is a callback that is called when events are emitted
|
// Subscriber is a callback that is called when events are emitted
|
||||||
|
Loading…
Reference in New Issue
Block a user