tangled
alpha
login
or
join now
gbl08ma.com
/
didplcbft
24
fork
atom
A very experimental PLC implementation which uses BFT consensus for decentralization
24
fork
atom
overview
issues
pulls
pipelines
Fix multiple authoritative import bugs
gbl08ma.com
1 month ago
67bf9fda
f1b03f77
verified
This commit was signed with the committer's
known signature
.
gbl08ma.com
SSH Key Fingerprint:
SHA256:NkaTDGnGWRZlEnrKxt4ih8fpbNEuHeYdbkJk7VYd+1o=
+19
-8
4 changed files
expand all
collapse all
unified
split
abciapp
app.go
execution.go
import.go
tx_import.go
+10
abciapp/app.go
···
219
219
return stacktrace.Propagate(err)
220
220
}
221
221
222
222
+
// ensure we resume importing even if there is no pending AuthoritativeImport tx
223
223
+
readTx := d.txFactory.ReadWorking(time.Now())
224
224
+
225
225
+
plc, err := store.Consensus.AuthoritativePLC(readTx)
226
226
+
if err != nil {
227
227
+
return stacktrace.Propagate(err)
228
228
+
}
229
229
+
230
230
+
_ = d.buildAuthoritativeOperationsFetcher(plc)
231
231
+
222
232
return nil
223
233
}
224
234
+1
-1
abciapp/execution.go
···
318
318
d.destroyAuthoritativeOperationsFetcher()
319
319
}
320
320
321
321
-
if d.aoc == nil {
321
321
+
if d.aoc == nil && plc != "" {
322
322
d.aoc = newAuthoritativeOperationsFetcher(d.runnerContext, d.logger, plc, d.triggerBlockCreation)
323
323
}
324
324
+6
-5
abciapp/import.go
···
97
97
}
98
98
99
99
func (a *authoritativeOperationsFetcher) launchWebsocketClient(ctx context.Context, cursor uint64) {
100
100
-
ctx, cancel := context.WithTimeout(ctx, 30*time.Second)
101
101
-
defer cancel()
102
102
-
103
100
url, err := url.Parse(a.plcURL)
104
101
if err != nil {
105
102
// this really shouldn't happen
···
108
105
}
109
106
110
107
url.Scheme = "wss"
111
111
-
url = url.JoinPath(a.plcURL, "/export/stream")
108
108
+
url = url.JoinPath("/export/stream")
112
109
q := url.Query()
113
110
q.Add("cursor", fmt.Sprint(cursor))
114
111
url.RawQuery = q.Encode()
115
112
116
113
header := http.Header{}
117
114
header.Set("User-Agent", SoftwareUserAgent)
118
118
-
c, _, err := websocket.Dial(ctx, url.String(), &websocket.DialOptions{
115
115
+
116
116
+
dialCtx, cancel := context.WithTimeout(ctx, 30*time.Second)
117
117
+
defer cancel()
118
118
+
119
119
+
c, _, err := websocket.Dial(dialCtx, url.String(), &websocket.DialOptions{
119
120
HTTPClient: a.client,
120
121
HTTPHeader: header,
121
122
})
+2
-2
abciapp/tx_import.go
···
107
107
return nil, stacktrace.Propagate(err)
108
108
}
109
109
110
110
-
if expectedPlcUrl != tx.Arguments.PLCURL {
110
110
+
if expectedPlcUrl != tx.Arguments.PLCURL || expectedPlcUrl == "" {
111
111
return &processResult{
112
112
Code: 4110,
113
113
Info: "Unexpected Authoritative PLC URL",
···
128
128
}, nil
129
129
}
130
130
131
131
-
if tx.Arguments.Count > MaxOpsPerImportTx {
131
131
+
if tx.Arguments.Count > MaxOpsPerImportTx || tx.Arguments.Count == 0 {
132
132
return &processResult{
133
133
Code: 4112,
134
134
Info: "Unexpected import count",