-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
btcjson+rpcclient: add compatibility for bitcoind v0.19.0 #1484
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is quite an elegant solution to the problem, looks pretty good 👍
btcjson/chainsvrresults.go
Outdated
@@ -92,7 +92,7 @@ type SoftForkDescription struct { | |||
type Bip9SoftForkDescription struct { | |||
Status string `json:"status"` | |||
Bit uint8 `json:"bit"` | |||
StartTime int64 `json:"startTime"` | |||
StartTime int64 `json:"start_time"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does this break compat with older nodes? or was it always incorrect?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question...it would appears that it does, unless the json
library falls back to a fuzzy match on the field name within the struct itself?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does this break compat with older nodes?
It does...
unless the json library falls back to a fuzzy match on the field name within the struct itself?
Doesn't seem to be the case unfortunately due to the _
. How should we address this? This same way we did with SoftForks
and UnifiedSoftForks
in GetBlockChainInfoResult
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we attempt to unmarshal the result into this struct, if start_time
is not set, unmarshal into a new struct having the startTime
field, and override?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can. I'm wondering if this is even worth the hassle though, as it would only affect bitcoind < 0.19.0
and it wouldn't affect btcd
at all. Also there's no failure from unmarshaling in this case, the StartTime
field just wouldn't be set.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's an option: remove this field, and add two new fields StartTime1
and StartTime2
, then create a new method StartTime
that returns the value. This breaks old clients, but gracefully (imo) as they'll likely see a compile error that they're passing in a method, when it's expecting an int64
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First pass through, haven't yet run it yet to verify the open question w.r.t backwards compatibility.
btcjson/chainsvrresults.go
Outdated
@@ -92,7 +92,7 @@ type SoftForkDescription struct { | |||
type Bip9SoftForkDescription struct { | |||
Status string `json:"status"` | |||
Bit uint8 `json:"bit"` | |||
StartTime int64 `json:"startTime"` | |||
StartTime int64 `json:"start_time"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question...it would appears that it does, unless the json
library falls back to a fuzzy match on the field name within the struct itself?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks more or less good to me now, pending start_time
compat
btcjson/chainsvrresults.go
Outdated
@@ -92,7 +92,7 @@ type SoftForkDescription struct { | |||
type Bip9SoftForkDescription struct { | |||
Status string `json:"status"` | |||
Bit uint8 `json:"bit"` | |||
StartTime int64 `json:"startTime"` | |||
StartTime int64 `json:"start_time"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we attempt to unmarshal the result into this struct, if start_time
is not set, unmarshal into a new struct having the startTime
field, and override?
Travis failure seems related to some weird caching issue. The test passes locally. |
Cleared the cache, the build passes now. |
btcjson/chainsvrresults.go
Outdated
@@ -92,7 +92,7 @@ type SoftForkDescription struct { | |||
type Bip9SoftForkDescription struct { | |||
Status string `json:"status"` | |||
Bit uint8 `json:"bit"` | |||
StartTime int64 `json:"startTime"` | |||
StartTime int64 `json:"start_time"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's an option: remove this field, and add two new fields StartTime1
and StartTime2
, then create a new method StartTime
that returns the value. This breaks old clients, but gracefully (imo) as they'll likely see a compile error that they're passing in a method, when it's expecting an int64
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👑
This PR aims to remedy the breaking RPC changes introduced in
bitcoind v0.19.0
:This required being able to interpret the backend version the client connects to, which wasn't previously supported.
btcd
andbitcoind
have different methods to expose this,GetInfo
andGetNetworkInfo
respectively.