Skip to content

Commit 7ba87dc

Browse files
committed
forcing runtime 1502 as minimum
1 parent bcb8061 commit 7ba87dc

File tree

6 files changed

+3
-337
lines changed

6 files changed

+3
-337
lines changed

config/client.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package config
33
import (
44
"embed"
55
"fmt"
6-
"log"
76
"math/rand"
87
"time"
98
)
@@ -59,17 +58,13 @@ func GetChainConfig(
5958
},
6059
DialTimeout: 10 * time.Second,
6160
SubscribeTimeout: 5 * time.Second,
62-
NetworkSpecs: "moonbeam",
61+
NetworkSpecs: "moonbeam.1502",
6362
NetworkSpecsVersion: 1300,
6463
}
6564
}
6665

6766
// ReadSpecs will read network specification from the embedded file
6867
func (cg *ChainConfig) ReadSpecs() ([]byte, error) {
69-
if cg.NetworkSpecsVersion >= 1500 {
70-
log.Printf("Loading decoder for spec 1500")
71-
return networkSpecs.ReadFile(fmt.Sprintf("specs/%v.1500.json", cg.NetworkSpecs))
72-
}
7368
return networkSpecs.ReadFile(fmt.Sprintf("specs/%v.json", cg.NetworkSpecs))
7469
}
7570

config/specs/moonbeam.json

Lines changed: 0 additions & 275 deletions
This file was deleted.

internal/client/collators.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ func (cp *CollatorPool) computeRevokes(firstRound uint32, lastRound uint32) {
435435
for round := firstRound; round <= lastRound; round++ {
436436
roundPool := make([]sortEntry, 0)
437437
// First we compute new total
438-
for i, _ := range cp.Collators {
438+
for i := range cp.Collators {
439439
if cp.Collators[i].Revokes == nil {
440440
cp.Collators[i].Revokes = make(map[uint32]RevokeRound)
441441
}

internal/client/delegator.go

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,6 @@ type DelegatorState struct {
6161
}
6262

6363
func (c *Client) FetchDelegatorState(collator string, address string) (DelegatorState, error) {
64-
if c.SpecVersion < 1500 {
65-
return c.fetchDelegatorStateV1300(collator, address)
66-
}
67-
return c.fetchDelegatorStateV1500(collator, address)
68-
}
69-
70-
func (c *Client) fetchDelegatorStateV1500(collator string, address string) (DelegatorState, error) {
7164
delegatorAccount, _ := types.HexDecodeString(address)
7265
collatorAccount, _ := types.HexDecodeString(collator)
7366
var delegator delegatorStateUnmarshalV1500
@@ -128,50 +121,3 @@ func (c *Client) fetchDelegatorStateV1500(collator string, address string) (Dele
128121
}
129122
return r, nil
130123
}
131-
132-
func (c *Client) fetchDelegatorStateV1300(collator string, address string) (DelegatorState, error) {
133-
account, _ := types.HexDecodeString(address)
134-
var delegator delegatorStateUnmarshal
135-
err := c.GetStorageRaw(
136-
"ParachainStaking",
137-
"DelegatorState",
138-
"DelegatorState<Balance>",
139-
&delegator,
140-
account,
141-
)
142-
if err != nil {
143-
log.Printf("Unable to decode delegator state for %v\n", address)
144-
return DelegatorState{}, err
145-
}
146-
// Fetch collator relative data
147-
totalDelegated := big.NewInt(0)
148-
for _, delegation := range delegator.Delegations {
149-
if strings.EqualFold(delegation.Owner, collator) {
150-
totalDelegated.Add(totalDelegated, delegation.Amount.AsBigInt())
151-
}
152-
}
153-
// Fetch revokes
154-
revokeAmount := TokenAmount{big.NewInt(0)}
155-
revokeReason := ""
156-
revokeRound := uint32(0)
157-
for _, request := range delegator.Requests.Requests {
158-
if strings.EqualFold(request.Collator, collator) {
159-
revokeReason = request.Request.Action.Value()
160-
revokeRound = request.Request.Round
161-
revokeAmount = request.Request.Amount
162-
break
163-
}
164-
}
165-
// Ok
166-
r := DelegatorState{
167-
Address: address,
168-
Amount: TokenBalance{
169-
info: &c.TokenInfo,
170-
Balance: &TokenAmount{totalDelegated},
171-
},
172-
RevokeAmount: revokeAmount.AsBalance(&c.TokenInfo),
173-
RevokeReason: revokeReason,
174-
RevokeRound: revokeRound,
175-
}
176-
return r, nil
177-
}

internal/server/data.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ func (c *ChainData) Update() error {
7676
return err
7777
}
7878
// Fetch collator pool
79-
log.Printf("Fetching collator pool")
79+
log.Printf("Fetching collator pool history:%v revokes:%v\n", 28, true)
8080
collatorPool, err := chainClient.FetchCollatorPool(config.CollatorsPoolConfig{
8181
HistoryRounds: 28,
8282
Revokes: true,

0 commit comments

Comments
 (0)