A very experimental PLC implementation which uses BFT consensus for decentralization

Reliably set User-Agent on requests to authoritative PLC

gbl08ma.com 92b8e6ce 9f40f718

verified
+12 -2
+4 -1
abciapp/import.go
··· 113 113 q.Add("cursor", fmt.Sprint(cursor)) 114 114 url.RawQuery = q.Encode() 115 115 116 + header := http.Header{} 117 + header.Set("User-Agent", SoftwareUserAgent) 116 118 c, _, err := websocket.Dial(ctx, url.String(), &websocket.DialOptions{ 117 119 HTTPClient: a.client, 120 + HTTPHeader: header, 118 121 }) 119 122 if err != nil { 120 123 a.logger.Error("authoritative operations fetcher failed to dial websocket", ··· 270 273 return nil, 0, stacktrace.Propagate(err, "") 271 274 } 272 275 273 - req.Header.Set("User-Agent", "didplcbft") 276 + req.Header.Set("User-Agent", SoftwareUserAgent) 274 277 275 278 requestCount := min(1000, maxCount-uint64(len(entries))) 276 279
+8 -1
abciapp/info.go
··· 4 4 "context" 5 5 "encoding/json" 6 6 "errors" 7 + "fmt" 7 8 "net/http" 8 9 "net/url" 10 + "runtime" 9 11 "time" 10 12 11 13 abcitypes "github.com/cometbft/cometbft/abci/types" ··· 15 17 "tangled.org/gbl08ma.com/didplcbft/transaction" 16 18 ) 17 19 20 + const SoftwareVersion = "0.1.2" 21 + const SoftwareName = "didplcbft" 22 + 23 + var SoftwareUserAgent = fmt.Sprintf("%s/%s (%s; %s)", SoftwareName, SoftwareVersion, runtime.GOOS, runtime.GOARCH) 24 + 18 25 // Info implements [types.Application]. 19 26 func (d *DIDPLCApplication) Info(ctx context.Context, req *abcitypes.RequestInfo) (*abcitypes.ResponseInfo, error) { 20 27 return &abcitypes.ResponseInfo{ 21 28 Data: "", // TODO some status report as JSON? Information about CometBFT itself can be obtained from RequestInfo 22 - Version: "0.1.1", 29 + Version: SoftwareVersion, 23 30 AppVersion: 0, // TODO, included in the header of every block. move these values to constants 24 31 LastBlockHeight: d.tree.Version(), 25 32 LastBlockAppHash: d.tree.Hash(),