Skip to content

Commit

Permalink
add network type
Browse files Browse the repository at this point in the history
  • Loading branch information
loongy committed Sep 2, 2020
1 parent 526dba6 commit fd334b3
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions multichain.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,3 +197,29 @@ func (chainType ChainType) Marshal(buf []byte, rem int) ([]byte, int, error) {
func (chainType *ChainType) Unmarshal(buf []byte, rem int) ([]byte, int, error) {
return surge.UnmarshalString((*string)(chainType), buf, rem)
}

type Network string

const (
NetworkLocalnet = Network("localnet")
NetworkTestnet = Network("testnet")
NetworkMainnet = Network("mainnet")
)

// SizeHint returns the number of bytes required to represent the network in
// binary.
func (net Network) SizeHint() int {
return surge.SizeHintString(string(net))
}

// Marshal the network to binary. You should not call this function directly,
// unless you are implementing marshalling for a container type.
func (net Network) Marshal(buf []byte, rem int) ([]byte, int, error) {
return surge.MarshalString(string(net), buf, rem)
}

// Unmarshal the network from binary. You should not call this function
// directly, unless you are implementing unmarshalling for a container type.
func (net *Network) Unmarshal(buf []byte, rem int) ([]byte, int, error) {
return surge.UnmarshalString((*string)(net), buf, rem)
}

0 comments on commit fd334b3

Please sign in to comment.