A very experimental PLC implementation which uses BFT consensus for decentralization
19
fork

Configure Feed

Select the types of activity you want to include in your feed.

Fix multiple authoritative import bugs

gbl08ma 67bf9fda f1b03f77

+19 -8
+10
abciapp/app.go
··· 219 219 return stacktrace.Propagate(err) 220 220 } 221 221 222 + // ensure we resume importing even if there is no pending AuthoritativeImport tx 223 + readTx := d.txFactory.ReadWorking(time.Now()) 224 + 225 + plc, err := store.Consensus.AuthoritativePLC(readTx) 226 + if err != nil { 227 + return stacktrace.Propagate(err) 228 + } 229 + 230 + _ = d.buildAuthoritativeOperationsFetcher(plc) 231 + 222 232 return nil 223 233 } 224 234
+1 -1
abciapp/execution.go
··· 318 318 d.destroyAuthoritativeOperationsFetcher() 319 319 } 320 320 321 - if d.aoc == nil { 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 - ctx, cancel := context.WithTimeout(ctx, 30*time.Second) 101 - defer cancel() 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 - url = url.JoinPath(a.plcURL, "/export/stream") 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 - c, _, err := websocket.Dial(ctx, url.String(), &websocket.DialOptions{ 115 + 116 + dialCtx, cancel := context.WithTimeout(ctx, 30*time.Second) 117 + defer cancel() 118 + 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 - if expectedPlcUrl != tx.Arguments.PLCURL { 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 - if tx.Arguments.Count > MaxOpsPerImportTx { 131 + if tx.Arguments.Count > MaxOpsPerImportTx || tx.Arguments.Count == 0 { 132 132 return &processResult{ 133 133 Code: 4112, 134 134 Info: "Unexpected import count",