Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor events handlers #342

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion benchmarks/testinstance/testinstance.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ func NewInstance(ctx context.Context, net tn.Network, tempDir string, diskBasedD

linkSystem := storeutil.LinkSystemForBlockstore(bstore)
gs := gsimpl.New(ctx, gsNet, linkSystem, gsimpl.RejectAllRequestsByDefault())
transport := gstransport.NewTransport(p, gs, dtNet)
transport := gstransport.NewTransport(gs, dtNet)
dt, err := dtimpl.NewDataTransfer(namespace.Wrap(dstore, datastore.NewKey("/data-transfers/transfers")), p, transport)
if err != nil {
return Instance{}, err
Expand Down
133 changes: 0 additions & 133 deletions channels/caches.go

This file was deleted.

43 changes: 31 additions & 12 deletions channels/channel_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,22 +50,22 @@ func (c channelState) Voucher() datatransfer.TypedVoucher {
return datatransfer.TypedVoucher{Voucher: ev.Voucher.Node, Type: ev.Type}
}

// ReceivedCidsTotal returns the number of (non-unique) cids received so far
// on the channel - note that a block can exist in more than one place in the DAG
func (c channelState) ReceivedCidsTotal() int64 {
return c.ic.ReceivedBlocksTotal
// ReceivedIndex returns the index, a transport specific identifier for "where"
// we are in receiving data for a transfer
func (c channelState) ReceivedIndex() datamodel.Node {
return c.ic.ReceivedIndex.Node
}

// QueuedCidsTotal returns the number of (non-unique) cids queued so far
// on the channel - note that a block can exist in more than one place in the DAG
func (c channelState) QueuedCidsTotal() int64 {
return c.ic.QueuedBlocksTotal
// QueuedIndex returns the index, a transport specific identifier for "where"
// we are in queing data for a transfer
func (c channelState) QueuedIndex() datamodel.Node {
return c.ic.QueuedIndex.Node
}

// SentCidsTotal returns the number of (non-unique) cids sent so far
// on the channel - note that a block can exist in more than one place in the DAG
func (c channelState) SentCidsTotal() int64 {
return c.ic.SentBlocksTotal
// SentIndex returns the index, a transport specific identifier for "where"
// we are in sending data for a transfer
func (c channelState) SentIndex() datamodel.Node {
return c.ic.SentIndex.Node
}

// Sender returns the peer id for the node that is sending data
Expand Down Expand Up @@ -139,6 +139,25 @@ func (c channelState) RequiresFinalization() bool {
return c.ic.RequiresFinalization
}

func (c channelState) InitiatorPaused() bool {
return c.ic.InitiatorPaused
}

func (c channelState) ResponderPaused() bool {
return c.ic.ResponderPaused || c.ic.Status == datatransfer.Finalizing
}

func (c channelState) BothPaused() bool {
return c.InitiatorPaused() && c.ResponderPaused()
}

func (c channelState) SelfPaused() bool {
if c.ic.SelfPeer == c.ic.Initiator {
return c.InitiatorPaused()
}
return c.ResponderPaused()
}

// Stages returns the current ChannelStages object, or an empty object.
// It is unsafe for the caller to modify the return value, and changes may not
// be persisted. It should be treated as immutable.
Expand Down
Loading