-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #318 from iotaledger/feat/rewards
Update performance tracker and rewards
- Loading branch information
Showing
22 changed files
with
788 additions
and
306 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package model | ||
|
||
import ( | ||
iotago "github.com/iotaledger/iota.go/v4" | ||
) | ||
|
||
type ValidatorPerformance struct { | ||
// works if ValidatorBlocksPerSlot is less than 32 because we use it as bit vector | ||
SlotActivityVector uint32 `serix:"0"` | ||
// can be uint8 because max count per slot is maximally ValidatorBlocksPerSlot + 1 | ||
BlockIssuedCount uint8 `serix:"1"` | ||
HighestSupportedVersionAndHash VersionAndHash `serix:"2"` | ||
} | ||
|
||
func NewValidatorPerformance() *ValidatorPerformance { | ||
return &ValidatorPerformance{ | ||
SlotActivityVector: 0, | ||
BlockIssuedCount: 0, | ||
HighestSupportedVersionAndHash: VersionAndHash{}, | ||
} | ||
} | ||
|
||
func ValidatorPerformanceFromBytes(decodeAPI iotago.API) func([]byte) (*ValidatorPerformance, int, error) { | ||
return func(bytes []byte) (*ValidatorPerformance, int, error) { | ||
validatorPerformance := new(ValidatorPerformance) | ||
consumedBytes, err := decodeAPI.Decode(bytes, validatorPerformance) | ||
if err != nil { | ||
return nil, 0, err | ||
} | ||
|
||
return validatorPerformance, consumedBytes, nil | ||
} | ||
} | ||
|
||
func (p *ValidatorPerformance) Bytes(api iotago.API) ([]byte, error) { | ||
return api.Encode(p) | ||
} |
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.