MCPcopy Create free account
hub / github.com/akash-network/node / hasContinuousL3History

Method hasContinuousL3History

x/verification/keeper/msg.go:1373–1419  ·  view source on GitHub ↗
(ctx sdk.Context, provider sdk.AccAddress, duration time.Duration)

Source from the content-addressed store, hash-verified

1371}
1372
1373func (k *keeper) hasContinuousL3History(ctx sdk.Context, provider sdk.AccAddress, duration time.Duration) bool {
1374 if duration == 0 {
1375 return true
1376 }
1377
1378 start := ctx.BlockTime().Add(-duration)
1379 end := ctx.BlockTime()
1380 intervals := make([]attestationInterval, 0)
1381 k.WithProviderAttestations(ctx, provider, vtypes.AttestationStatusUnspecified, func(record vtypes.AttestationRecord) bool {
1382 if !vtypes.TierAtLeast(record.Tier, vtypes.TierEstablished) {
1383 return false
1384 }
1385 if record.Status != vtypes.AttestationStatusValid && record.Status != vtypes.AttestationStatusExpired {
1386 return false
1387 }
1388 if !record.ExpiresAt.After(start) || record.CreatedAt.After(end) {
1389 return false
1390 }
1391 intervals = append(intervals, attestationInterval{
1392 start: record.CreatedAt,
1393 end: record.ExpiresAt,
1394 })
1395 return false
1396 })
1397 if len(intervals) == 0 {
1398 return false
1399 }
1400
1401 sort.Slice(intervals, func(i, j int) bool {
1402 return intervals[i].start.Before(intervals[j].start)
1403 })
1404
1405 coveredUntil := start
1406 for _, interval := range intervals {
1407 if !interval.end.After(coveredUntil) {
1408 continue
1409 }
1410 if interval.start.After(coveredUntil) {
1411 return false
1412 }
1413 coveredUntil = interval.end
1414 if !coveredUntil.Before(end) {
1415 return true
1416 }
1417 }
1418 return false
1419}
1420
1421func (k *keeper) validateProviderAge(ctx sdk.Context, provider sdk.AccAddress, tier vtypes.VerificationTier, params vtypes.Params) error {
1422 if k.provider == nil {

Callers 1

Calls 3

AfterMethod · 0.80
BeforeMethod · 0.80

Tested by

no test coverage detected