fix: revert to using cid for paych wait sentinel
This commit is contained in:
parent
43586ed9a1
commit
e689c305d2
@ -400,7 +400,7 @@ type FullNode interface {
|
|||||||
// The Paych methods are for interacting with and managing payment channels
|
// The Paych methods are for interacting with and managing payment channels
|
||||||
|
|
||||||
PaychGet(ctx context.Context, from, to address.Address, amt types.BigInt) (*ChannelInfo, error)
|
PaychGet(ctx context.Context, from, to address.Address, amt types.BigInt) (*ChannelInfo, error)
|
||||||
PaychGetWaitReady(context.Context, PaychWaitSentinel) (address.Address, error)
|
PaychGetWaitReady(context.Context, cid.Cid) (address.Address, error)
|
||||||
PaychList(context.Context) ([]address.Address, error)
|
PaychList(context.Context) ([]address.Address, error)
|
||||||
PaychStatus(context.Context, address.Address) (*PaychStatus, error)
|
PaychStatus(context.Context, address.Address) (*PaychStatus, error)
|
||||||
PaychSettle(context.Context, address.Address) (cid.Cid, error)
|
PaychSettle(context.Context, address.Address) (cid.Cid, error)
|
||||||
@ -511,16 +511,14 @@ type PaychStatus struct {
|
|||||||
Direction PCHDir
|
Direction PCHDir
|
||||||
}
|
}
|
||||||
|
|
||||||
type PaychWaitSentinel cid.Cid
|
|
||||||
|
|
||||||
type ChannelInfo struct {
|
type ChannelInfo struct {
|
||||||
Channel address.Address
|
Channel address.Address
|
||||||
WaitSentinel PaychWaitSentinel
|
WaitSentinel cid.Cid
|
||||||
}
|
}
|
||||||
|
|
||||||
type PaymentInfo struct {
|
type PaymentInfo struct {
|
||||||
Channel address.Address
|
Channel address.Address
|
||||||
WaitSentinel PaychWaitSentinel
|
WaitSentinel cid.Cid
|
||||||
Vouchers []*paych.SignedVoucher
|
Vouchers []*paych.SignedVoucher
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -195,7 +195,7 @@ type FullNodeStruct struct {
|
|||||||
MarketEnsureAvailable func(context.Context, address.Address, address.Address, types.BigInt) (cid.Cid, error) `perm:"sign"`
|
MarketEnsureAvailable func(context.Context, address.Address, address.Address, types.BigInt) (cid.Cid, error) `perm:"sign"`
|
||||||
|
|
||||||
PaychGet func(ctx context.Context, from, to address.Address, amt types.BigInt) (*api.ChannelInfo, error) `perm:"sign"`
|
PaychGet func(ctx context.Context, from, to address.Address, amt types.BigInt) (*api.ChannelInfo, error) `perm:"sign"`
|
||||||
PaychGetWaitReady func(context.Context, api.PaychWaitSentinel) (address.Address, error) `perm:"sign"`
|
PaychGetWaitReady func(context.Context, cid.Cid) (address.Address, error) `perm:"sign"`
|
||||||
PaychList func(context.Context) ([]address.Address, error) `perm:"read"`
|
PaychList func(context.Context) ([]address.Address, error) `perm:"read"`
|
||||||
PaychStatus func(context.Context, address.Address) (*api.PaychStatus, error) `perm:"read"`
|
PaychStatus func(context.Context, address.Address) (*api.PaychStatus, error) `perm:"read"`
|
||||||
PaychSettle func(context.Context, address.Address) (cid.Cid, error) `perm:"sign"`
|
PaychSettle func(context.Context, address.Address) (cid.Cid, error) `perm:"sign"`
|
||||||
@ -844,7 +844,7 @@ func (c *FullNodeStruct) PaychGet(ctx context.Context, from, to address.Address,
|
|||||||
return c.Internal.PaychGet(ctx, from, to, amt)
|
return c.Internal.PaychGet(ctx, from, to, amt)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *FullNodeStruct) PaychGetWaitReady(ctx context.Context, sentinel api.PaychWaitSentinel) (address.Address, error) {
|
func (c *FullNodeStruct) PaychGetWaitReady(ctx context.Context, sentinel cid.Cid) (address.Address, error) {
|
||||||
return c.Internal.PaychGetWaitReady(ctx, sentinel)
|
return c.Internal.PaychGetWaitReady(ctx, sentinel)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,59 +14,6 @@ import (
|
|||||||
|
|
||||||
var _ = xerrors.Errorf
|
var _ = xerrors.Errorf
|
||||||
|
|
||||||
func (t *PaychWaitSentinel) MarshalCBOR(w io.Writer) error {
|
|
||||||
if t == nil {
|
|
||||||
_, err := w.Write(cbg.CborNull)
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if _, err := w.Write([]byte{160}); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (t *PaychWaitSentinel) UnmarshalCBOR(r io.Reader) error {
|
|
||||||
*t = PaychWaitSentinel{}
|
|
||||||
|
|
||||||
br := cbg.GetPeeker(r)
|
|
||||||
scratch := make([]byte, 8)
|
|
||||||
|
|
||||||
maj, extra, err := cbg.CborReadHeaderBuf(br, scratch)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if maj != cbg.MajMap {
|
|
||||||
return fmt.Errorf("cbor input should be of type map")
|
|
||||||
}
|
|
||||||
|
|
||||||
if extra > cbg.MaxLength {
|
|
||||||
return fmt.Errorf("PaychWaitSentinel: map struct too large (%d)", extra)
|
|
||||||
}
|
|
||||||
|
|
||||||
var name string
|
|
||||||
n := extra
|
|
||||||
|
|
||||||
for i := uint64(0); i < n; i++ {
|
|
||||||
|
|
||||||
{
|
|
||||||
sval, err := cbg.ReadStringBuf(br, scratch)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
name = string(sval)
|
|
||||||
}
|
|
||||||
|
|
||||||
switch name {
|
|
||||||
|
|
||||||
default:
|
|
||||||
return fmt.Errorf("unknown struct field %d: '%s'", i, name)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
func (t *PaymentInfo) MarshalCBOR(w io.Writer) error {
|
func (t *PaymentInfo) MarshalCBOR(w io.Writer) error {
|
||||||
if t == nil {
|
if t == nil {
|
||||||
_, err := w.Write(cbg.CborNull)
|
_, err := w.Write(cbg.CborNull)
|
||||||
@ -94,7 +41,7 @@ func (t *PaymentInfo) MarshalCBOR(w io.Writer) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// t.WaitSentinel (api.PaychWaitSentinel) (struct)
|
// t.WaitSentinel (cid.Cid) (struct)
|
||||||
if len("WaitSentinel") > cbg.MaxLength {
|
if len("WaitSentinel") > cbg.MaxLength {
|
||||||
return xerrors.Errorf("Value in field \"WaitSentinel\" was too long")
|
return xerrors.Errorf("Value in field \"WaitSentinel\" was too long")
|
||||||
}
|
}
|
||||||
@ -106,8 +53,8 @@ func (t *PaymentInfo) MarshalCBOR(w io.Writer) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := t.WaitSentinel.MarshalCBOR(w); err != nil {
|
if err := cbg.WriteCidBuf(scratch, w, t.WaitSentinel); err != nil {
|
||||||
return err
|
return xerrors.Errorf("failed to write cid field t.WaitSentinel: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// t.Vouchers ([]*paych.SignedVoucher) (slice)
|
// t.Vouchers ([]*paych.SignedVoucher) (slice)
|
||||||
@ -180,15 +127,18 @@ func (t *PaymentInfo) UnmarshalCBOR(r io.Reader) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
// t.WaitSentinel (api.PaychWaitSentinel) (struct)
|
// t.WaitSentinel (cid.Cid) (struct)
|
||||||
case "WaitSentinel":
|
case "WaitSentinel":
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
||||||
if err := t.WaitSentinel.UnmarshalCBOR(br); err != nil {
|
c, err := cbg.ReadCid(br)
|
||||||
return xerrors.Errorf("unmarshaling t.WaitSentinel: %w", err)
|
if err != nil {
|
||||||
|
return xerrors.Errorf("failed to read cid field t.WaitSentinel: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
t.WaitSentinel = c
|
||||||
|
|
||||||
}
|
}
|
||||||
// t.Vouchers ([]*paych.SignedVoucher) (slice)
|
// t.Vouchers ([]*paych.SignedVoucher) (slice)
|
||||||
case "Vouchers":
|
case "Vouchers":
|
||||||
|
@ -43,7 +43,6 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
err = gen.WriteMapEncodersToFile("./api/cbor_gen.go", "api",
|
err = gen.WriteMapEncodersToFile("./api/cbor_gen.go", "api",
|
||||||
api.PaychWaitSentinel{},
|
|
||||||
api.PaymentInfo{},
|
api.PaymentInfo{},
|
||||||
api.SealedRef{},
|
api.SealedRef{},
|
||||||
api.SealedRefs{},
|
api.SealedRefs{},
|
||||||
|
@ -36,12 +36,12 @@ func (a *PaychAPI) PaychGet(ctx context.Context, from, to address.Address, amt t
|
|||||||
|
|
||||||
return &api.ChannelInfo{
|
return &api.ChannelInfo{
|
||||||
Channel: ch,
|
Channel: ch,
|
||||||
WaitSentinel: api.PaychWaitSentinel(mcid),
|
WaitSentinel: mcid,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *PaychAPI) PaychGetWaitReady(ctx context.Context, sentinel api.PaychWaitSentinel) (address.Address, error) {
|
func (a *PaychAPI) PaychGetWaitReady(ctx context.Context, sentinel cid.Cid) (address.Address, error) {
|
||||||
return a.PaychMgr.GetPaychWaitReady(ctx, cid.Cid(sentinel))
|
return a.PaychMgr.GetPaychWaitReady(ctx, sentinel)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *PaychAPI) PaychAllocateLane(ctx context.Context, ch address.Address) (uint64, error) {
|
func (a *PaychAPI) PaychAllocateLane(ctx context.Context, ch address.Address) (uint64, error) {
|
||||||
|
Loading…
Reference in New Issue
Block a user