Documentation ¶
Index ¶
- Constants
- func ConstructDesiredState(past []model.Match, future []model.Match, l int) map[string]string
- func CreateData()
- func CreateWinnerMap(m []model.Match) map[string]string
- func PopSlashSource(selection *goquery.Selection) string
- func ReverseMatches(s []model.Match)
- func SplitMatchesAge(m []model.Match, threshold time.Duration, now time.Time) ([]model.Match, []model.Match)
- type API
- type HLTV
- type Oracle
- type OracleConfig
- type StubAPI
Constants ¶
const PastMatchesTTL = time.Hour * 72 // 3 days
PastMatchesTTL is the minimum duration that a past match should live on the blockchain. The duration is measured starting from the model.Match Date field. A past match that is published on the chain will remain on it for this time.
Variables ¶
This section is empty.
Functions ¶
func ConstructDesiredState ¶
ConstructDesiredState returns the desired state of a buffer of size l that the Oracle wishes to integrate onto the AlgorandBuffer. There are two factors for desirability.
- Past matches should remain on the buffer until their Date is older than the PastMatchesTTL
- Remove past matches that are older than their TTL.
The desired state also depends on the current time of the system (e.g. because of wanting to discard old data).
func CreateData ¶
func CreateData()
func CreateWinnerMap ¶
CreateWinnerMap converts a slice []Match into a map, where the key is the match ID, and the value is the Match winner. If there is no winner yet, the value will be empty.
func PopSlashSource ¶
func ReverseMatches ¶
ReverseMatches reverses the order of a match array.
func SplitMatchesAge ¶
func SplitMatchesAge(m []model.Match, threshold time.Duration, now time.Time) ([]model.Match, []model.Match)
SplitMatchesAge returns a partition of matches. The first return value contains matches that concluded longer than threshold ago, whereas the second return value contains matches that are at most threshold old. The distance is measured from a given present time `now`.
Types ¶
type API ¶
type API interface { // Fetch returns a list of past and future CSGO pro matches. // The reference implementation is provided by HLTV Fetch() (past, future []model.Match, err error) }
API is a provider of CSGO match data. It provides methods for fetching past and future matches. Which matches are selected is up to the API implementation.
type Oracle ¶
type Oracle struct {
// contains filtered or unexported fields
}
Oracle fetches, compares, and pushes data to the Blockchain
func NewOracle ¶
func NewOracle(b *siam.AlgorandBuffer, cfg *OracleConfig) *Oracle
NewOracle creates and initializes an Oracle struct. Requires an API to fetch and collect data, as well as a siam.AlgorandBuffer, in order to publish changes to the blockchain.
func (*Oracle) Serve ¶
func (o *Oracle) Serve()
Serve spawns a cancelable goroutine that aims to keep the AlgorandBuffer in a desired state. See ConstructDesiredState.
Any goroutines spawned by the Oracle can be cancelled anytime via Stop.
type OracleConfig ¶
type OracleConfig struct { // PrimaryAPI is the primary source of information. Only data proposed from this API // is put onto the blockchain. PrimaryAPI API // VerificationAPIs is an optional list of verification APIs used to verify the correctness // of the PrimaryAPI. If the data proposed from the PrimaryAPI does not match data from each // of verification APIs, the data is not written to the blockchain. VerificationAPIs []API // MaxVerifyTime does not need to be set if VerificationAPIs is nil. If the VerificationAPIs // do not agree with the PrimaryAPI's proposal within MaxVerifyTime, then the proposed data // gets discarded MaxVerifyTime time.Duration // RefreshInterval is the pause between two API fetch commands. // If the API accesses a rate-limited resource, then set RefreshInterval high enough // as to not trigger a rate-limit or blacklist event. RefreshInterval time.Duration }
OracleConfig defines the oracles behavior
type StubAPI ¶
StubAPI is a stub that implements API. You can explicitly set the match data that shall be returned by the API functions, by modifying the public fields or calling SetMatches. You can also specify if the stub should return an error.