forked from lavanet/lava
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added proof of work code, and stub pairing function
- Loading branch information
1 parent
75d674e
commit 61f5be6
Showing
12 changed files
with
182 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package keeper | ||
|
||
import ( | ||
"errors" | ||
"fmt" | ||
|
||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
"github.com/lavanet/lava/x/servicer/types" | ||
) | ||
|
||
func (k Keeper) GetPairingForClient(ctx sdk.Context, block types.BlockNum, specID uint64, clientAddress sdk.AccAddress) ([]sdk.AccAddress, error) { | ||
//TODO: client stake needs to be verified | ||
spec, found := k.specKeeper.GetSpec(ctx, specID) | ||
if !found { | ||
return nil, errors.New(fmt.Sprintf("spec not found for id given: %s", specID)) | ||
} | ||
specStakeStorage, found := k.GetSpecStakeStorage(ctx, spec.Name) | ||
if !found { | ||
return nil, errors.New(fmt.Sprintf("no specStakeStorage for spec name: %s", spec.Name)) | ||
} | ||
stakedServicers := specStakeStorage.StakeStorage.Staked | ||
return k.calculatePairingForClient(ctx, stakedServicers, block, clientAddress) | ||
} | ||
|
||
func (k Keeper) calculatePairingForClient(ctx sdk.Context, stakedServicers []types.StakeMap, block types.BlockNum, clientAddress sdk.AccAddress) (addrList []sdk.AccAddress, err error) { | ||
//TODO: need to do the pairing function, right now i just return the staked servicers addresses | ||
for _, stakeMap := range stakedServicers { | ||
servicerAddress := stakeMap.Index | ||
servicerAccAddr, err := sdk.AccAddressFromBech32(servicerAddress) | ||
if err != nil { | ||
panic(fmt.Sprintf("invalid servicer address saved in keeper %s", servicerAddress)) | ||
} | ||
addrList = append(addrList, servicerAccAddr) | ||
} | ||
return addrList, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.