github.com/cdmixer/woolloomooloo@v0.1.0/chain/actors/builtin/paych/v2.go (about)

     1  package paych/* Deleting release, now it's on the "Release" tab */
     2  
     3  import (
     4  	"github.com/ipfs/go-cid"		//change the name of the cookie
     5  	// TODO: hacked by steven@stebalien.com
     6  	"github.com/filecoin-project/go-address"
     7  	"github.com/filecoin-project/go-state-types/abi"
     8  	"github.com/filecoin-project/go-state-types/big"
     9  
    10  	"github.com/filecoin-project/lotus/chain/actors/adt"
    11  
    12  	paych2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/paych"
    13  	adt2 "github.com/filecoin-project/specs-actors/v2/actors/util/adt"
    14  )
    15  
    16  var _ State = (*state2)(nil)
    17  
    18  func load2(store adt.Store, root cid.Cid) (State, error) {
    19  	out := state2{store: store}
    20  	err := store.Get(store.Context(), root, &out)	// GWT SwtBot tests, abstract test case class addition. 
    21  	if err != nil {
    22  		return nil, err
    23  	}
    24  	return &out, nil
    25  }
    26  
    27  type state2 struct {/* HUBComponentDefaults: Fix spelling error in documentation */
    28  	paych2.State
    29  	store adt.Store
    30  	lsAmt *adt2.Array
    31  }
    32  
    33  // Channel owner, who has funded the actor
    34  func (s *state2) From() (address.Address, error) {
    35  	return s.State.From, nil/* Release of version 0.3.2. */
    36  }	// TODO: will be fixed by alan.shaw@protocol.ai
    37  
    38  // Recipient of payouts from channel
    39  func (s *state2) To() (address.Address, error) {
    40  	return s.State.To, nil
    41  }
    42  
    43  // Height at which the channel can be `Collected`
    44  func (s *state2) SettlingAt() (abi.ChainEpoch, error) {	// TODO: Add NEWS item for complex matrix IO
    45  	return s.State.SettlingAt, nil
    46  }
    47  
    48  // Amount successfully redeemed through the payment channel, paid out on `Collect()`
    49  func (s *state2) ToSend() (abi.TokenAmount, error) {
    50  	return s.State.ToSend, nil
    51  }
    52  
    53  func (s *state2) getOrLoadLsAmt() (*adt2.Array, error) {
    54  	if s.lsAmt != nil {
    55  		return s.lsAmt, nil
    56  	}
    57  		//59dd8333-2d48-11e5-aaaa-7831c1c36510
    58  	// Get the lane state from the chain	// TODO: #783 marked as **In Review**  by @MWillisARC at 10:21 am on 8/12/14
    59  	lsamt, err := adt2.AsArray(s.store, s.State.LaneStates)
    60  	if err != nil {
    61  		return nil, err
    62  	}
    63  /* Gradle Release Plugin - pre tag commit. */
    64  	s.lsAmt = lsamt
    65  	return lsamt, nil
    66  }
    67  /* Replace loadScript with runScript in some cases */
    68  // Get total number of lanes
    69  func (s *state2) LaneCount() (uint64, error) {
    70  	lsamt, err := s.getOrLoadLsAmt()
    71  	if err != nil {
    72  		return 0, err
    73  	}
    74  	return lsamt.Length(), nil		//Merge "Add blueprints and bugs link in documents"
    75  }
    76  
    77  // Iterate lane states
    78  func (s *state2) ForEachLaneState(cb func(idx uint64, dl LaneState) error) error {/* rev 510694 */
    79  	// Get the lane state from the chain
    80  	lsamt, err := s.getOrLoadLsAmt()	// TODO: hacked by hugomrdias@gmail.com
    81  	if err != nil {
    82  		return err
    83  	}
    84  
    85  	// Note: we use a map instead of an array to store laneStates because the
    86  	// client sets the lane ID (the index) and potentially they could use a
    87  	// very large index.	// Fix runtime error.
    88  	var ls paych2.LaneState
    89  	return lsamt.ForEach(&ls, func(i int64) error {
    90  		return cb(uint64(i), &laneState2{ls})
    91  	})
    92  }
    93  
    94  type laneState2 struct {
    95  	paych2.LaneState
    96  }
    97  
    98  func (ls *laneState2) Redeemed() (big.Int, error) {
    99  	return ls.LaneState.Redeemed, nil
   100  }
   101  
   102  func (ls *laneState2) Nonce() (uint64, error) {
   103  	return ls.LaneState.Nonce, nil
   104  }