Skip to content

Commit

Permalink
Add comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
nickeskov committed Aug 24, 2024
1 parent ed71652 commit 6b4d87b
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 0 deletions.
8 changes: 8 additions & 0 deletions pkg/ride/environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,14 @@ func (ws *WrappedState) uncheckedWavesBalance(addr proto.WavesAddress) (diffBala
return ws.diff.loadWavesBalance(addr.ID())
}

// NewestFullWavesBalance returns a full Waves balance of account.
// The method must be used ONLY in the Ride environment.
// The boundaries of the generating balance are calculated for the current height of applying block,
// instead of the last block height.
//
// For example, for the block validation we are use min effective balance of the account from height 1 to 1000.
// This function uses heights from 2 to 1001, where 1001 is the height of the applying block.
// All changes of effective balance during the applying block are affecting the generating balance.
func (ws *WrappedState) NewestFullWavesBalance(account proto.Recipient) (*proto.FullWavesBalance, error) {
addr, err := ws.NewestRecipientToAddress(account)
if err != nil {
Expand Down
18 changes: 18 additions & 0 deletions pkg/state/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -1030,6 +1030,14 @@ func (s *stateManager) FullWavesBalance(account proto.Recipient) (*proto.FullWav
}, nil
}

// NewestFullWavesBalance returns a full Waves balance of account.
// The method must be used ONLY in the Ride environment.
// The boundaries of the generating balance are calculated for the current height of applying block,
// instead of the last block height.
//
// For example, for the block validation we are use min effective balance of the account from height 1 to 1000.
// This function uses heights from 2 to 1001, where 1001 is the height of the applying block.
// All changes of effective balance during the applying block are affecting the generating balance.
func (s *stateManager) NewestFullWavesBalance(account proto.Recipient) (*proto.FullWavesBalance, error) {
addr, err := s.NewestRecipientToAddress(account)
if err != nil {
Expand Down Expand Up @@ -1068,6 +1076,16 @@ func (s *stateManager) NewestFullWavesBalance(account proto.Recipient) (*proto.F
}, nil
}

// WavesBalanceProfile returns WavesBalanceProfile structure retrieved by proto.AddressID of an account.
// This function always returns the newest available state of Waves balance of account.
// Thought, it can't be used during transaction processing, because the state does no hold changes between txs.
// The method must be used ONLY in the Ride environment for retrieving data from state.
// The boundaries of the generating balance are calculated for the current height of applying block,
// instead of the last block height.
//
// For example, for the block validation we are use min effective balance of the account from height 1 to 1000.
// This function uses heights from 2 to 1001, where 1001 is the height of the applying block.
// All changes of effective balance during the applying block are affecting the generating balance.
func (s *stateManager) WavesBalanceProfile(id proto.AddressID) (*types.WavesBalanceProfile, error) {
profile, err := s.newestWavesBalanceProfile(id)
if err != nil {
Expand Down
16 changes: 16 additions & 0 deletions pkg/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,14 @@ type SmartState interface {
IsStateUntouched(account proto.Recipient) (bool, error)
NewestAssetBalance(account proto.Recipient, assetID crypto.Digest) (uint64, error)
NewestWavesBalance(account proto.Recipient) (uint64, error)
// NewestFullWavesBalance returns a full Waves balance of account.
// The method must be used ONLY in the Ride environment.
// The boundaries of the generating balance are calculated for the current height of applying block,
// instead of the last block height.
//
// For example, for the block validation we are use min effective balance of the account from height 1 to 1000.
// This function uses heights from 2 to 1001, where 1001 is the height of the applying block.
// All changes of effective balance during the applying block are affecting the generating balance.
NewestFullWavesBalance(account proto.Recipient) (*proto.FullWavesBalance, error)
RetrieveNewestIntegerEntry(account proto.Recipient, key string) (*proto.IntegerDataEntry, error)
RetrieveNewestBooleanEntry(account proto.Recipient, key string) (*proto.BooleanDataEntry, error)
Expand All @@ -81,6 +89,14 @@ type SmartState interface {

// WavesBalanceProfile returns WavesBalanceProfile structure retrieved by proto.AddressID of an account.
// This function always returns the newest available state of Waves balance of account.
// Thought, it can't be used during transaction processing, because the state does no hold changes between txs.
// The method must be used ONLY in the Ride environment for retrieving data from state.
// The boundaries of the generating balance are calculated for the current height of applying block,
// instead of the last block height.
//
// For example, for the block validation we are use min effective balance of the account from height 1 to 1000.
// This function uses heights from 2 to 1001, where 1001 is the height of the applying block.
// All changes of effective balance during the applying block are affecting the generating balance.
WavesBalanceProfile(id proto.AddressID) (*WavesBalanceProfile, error)

// NewestAssetBalanceByAddressID returns the most actual asset balance by given proto.AddressID and
Expand Down

0 comments on commit 6b4d87b

Please sign in to comment.