Skip to content

Commit

Permalink
Merge pull request #142 from SiaFoundation/nate/remove-netaddress
Browse files Browse the repository at this point in the history
Rename NetAddress to Transport
  • Loading branch information
lukechampine committed Mar 1, 2024
2 parents d97c1d5 + cb1df26 commit 66b2f8f
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 14 deletions.
2 changes: 2 additions & 0 deletions rhp/v2/rhp.go
Expand Up @@ -75,6 +75,7 @@ type HostSettings struct {
MaxEphemeralAccountBalance types.Currency `json:"maxephemeralaccountbalance"`
RevisionNumber uint64 `json:"revisionnumber"`
Version string `json:"version"`
Release string `json:"release"`
SiaMuxPort string `json:"siamuxport"`
}

Expand Down Expand Up @@ -104,6 +105,7 @@ func (hs HostSettings) MarshalJSON() ([]byte, error) {
"maxephemeralaccountbalance": hs.MaxEphemeralAccountBalance,
"revisionnumber": hs.RevisionNumber,
"version": hs.Version,
"release": hs.Release,
"siamuxport": hs.SiaMuxPort,
})
}
Expand Down
22 changes: 12 additions & 10 deletions rhp/v4/encoding.go
Expand Up @@ -33,11 +33,12 @@ func (hp *HostPrices) DecodeFrom(d *types.Decoder) {

// EncodeTo implements types.EncoderTo.
func (hs HostSettings) EncodeTo(e *types.Encoder) {
e.Write(hs.Version[:])
e.WritePrefix(len(hs.NetAddresses))
for i := range hs.NetAddresses {
e.WriteString(hs.NetAddresses[i].Protocol)
e.WriteString(hs.NetAddresses[i].Address)
e.Write(hs.ProtocolVersion[:])
e.WriteString(hs.Release)
e.WritePrefix(len(hs.Transports))
for i := range hs.Transports {
e.WriteString(hs.Transports[i].Protocol)
e.WriteString(hs.Transports[i].Address)
}
hs.WalletAddress.EncodeTo(e)
e.WriteBool(hs.AcceptingContracts)
Expand All @@ -50,11 +51,12 @@ func (hs HostSettings) EncodeTo(e *types.Encoder) {

// DecodeFrom implements types.DecoderFrom.
func (hs *HostSettings) DecodeFrom(d *types.Decoder) {
d.Read(hs.Version[:])
hs.NetAddresses = make([]NetAddress, d.ReadPrefix())
for i := range hs.NetAddresses {
hs.NetAddresses[i].Protocol = d.ReadString()
hs.NetAddresses[i].Address = d.ReadString()
d.Read(hs.ProtocolVersion[:])
hs.Release = d.ReadString()
hs.Transports = make([]Transport, d.ReadPrefix())
for i := range hs.Transports {
hs.Transports[i].Protocol = d.ReadString()
hs.Transports[i].Address = d.ReadString()
}
hs.WalletAddress.DecodeFrom(d)
hs.AcceptingContracts = d.ReadBool()
Expand Down
9 changes: 5 additions & 4 deletions rhp/v4/rhp.go
Expand Up @@ -22,8 +22,8 @@ func round4KiB(n uint64) uint64 {
return (n + (1<<12 - 1)) &^ (1<<12 - 1)
}

// A NetAddress is a pair of protocol and address that a host may be reached on.
type NetAddress struct {
// A Transport is a pair of protocol and address that a host may be reached on.
type Transport struct {
Protocol string `json:"protocol"`
Address string `json:"address"`
}
Expand Down Expand Up @@ -53,8 +53,9 @@ func (hp HostPrices) WriteSectorCost(sector []byte) types.Currency {

// HostSettings specify the settings of a host.
type HostSettings struct {
Version [3]uint8 `json:"version"`
NetAddresses []NetAddress `json:"netAddresses"`
ProtocolVersion [3]uint8 `json:"protocolVersion"`
Release string `json:"release"`
Transports []Transport `json:"transports"`
WalletAddress types.Address `json:"walletAddress"`
AcceptingContracts bool `json:"acceptingContracts"`
MaxCollateral types.Currency `json:"maxCollateral"`
Expand Down

0 comments on commit 66b2f8f

Please sign in to comment.