github.com/ethereum/go-ethereum@v1.16.1/p2p/config_toml.go (about) 1 // Code generated by github.com/fjl/gencodec. DO NOT EDIT. 2 3 package p2p 4 5 import ( 6 "crypto/ecdsa" 7 8 "github.com/ethereum/go-ethereum/log" 9 "github.com/ethereum/go-ethereum/p2p/enode" 10 "github.com/ethereum/go-ethereum/p2p/nat" 11 "github.com/ethereum/go-ethereum/p2p/netutil" 12 ) 13 14 var _ = (*configMarshaling)(nil) 15 16 // MarshalTOML marshals as TOML. 17 func (c Config) MarshalTOML() (interface{}, error) { 18 type Config struct { 19 PrivateKey *ecdsa.PrivateKey `toml:"-"` 20 MaxPeers int 21 MaxPendingPeers int `toml:",omitempty"` 22 DialRatio int `toml:",omitempty"` 23 NoDiscovery bool 24 DiscoveryV4 bool `toml:",omitempty"` 25 DiscoveryV5 bool `toml:",omitempty"` 26 Name string `toml:"-"` 27 BootstrapNodes []*enode.Node 28 BootstrapNodesV5 []*enode.Node `toml:",omitempty"` 29 StaticNodes []*enode.Node 30 TrustedNodes []*enode.Node 31 NetRestrict *netutil.Netlist `toml:",omitempty"` 32 NodeDatabase string `toml:",omitempty"` 33 Protocols []Protocol `toml:"-" json:"-"` 34 ListenAddr string 35 DiscAddr string 36 NAT nat.Interface `toml:",omitempty"` 37 Dialer NodeDialer `toml:"-"` 38 NoDial bool `toml:",omitempty"` 39 EnableMsgEvents bool 40 Logger log.Logger `toml:"-"` 41 } 42 var enc Config 43 enc.PrivateKey = c.PrivateKey 44 enc.MaxPeers = c.MaxPeers 45 enc.MaxPendingPeers = c.MaxPendingPeers 46 enc.DialRatio = c.DialRatio 47 enc.NoDiscovery = c.NoDiscovery 48 enc.DiscoveryV4 = c.DiscoveryV4 49 enc.DiscoveryV5 = c.DiscoveryV5 50 enc.Name = c.Name 51 enc.BootstrapNodes = c.BootstrapNodes 52 enc.BootstrapNodesV5 = c.BootstrapNodesV5 53 enc.StaticNodes = c.StaticNodes 54 enc.TrustedNodes = c.TrustedNodes 55 enc.NetRestrict = c.NetRestrict 56 enc.NodeDatabase = c.NodeDatabase 57 enc.Protocols = c.Protocols 58 enc.ListenAddr = c.ListenAddr 59 enc.DiscAddr = c.DiscAddr 60 enc.NAT = c.NAT 61 enc.Dialer = c.Dialer 62 enc.NoDial = c.NoDial 63 enc.EnableMsgEvents = c.EnableMsgEvents 64 enc.Logger = c.Logger 65 return &enc, nil 66 } 67 68 // UnmarshalTOML unmarshals from TOML. 69 func (c *Config) UnmarshalTOML(unmarshal func(interface{}) error) error { 70 type Config struct { 71 PrivateKey *ecdsa.PrivateKey `toml:"-"` 72 MaxPeers *int 73 MaxPendingPeers *int `toml:",omitempty"` 74 DialRatio *int `toml:",omitempty"` 75 NoDiscovery *bool 76 DiscoveryV4 *bool `toml:",omitempty"` 77 DiscoveryV5 *bool `toml:",omitempty"` 78 Name *string `toml:"-"` 79 BootstrapNodes []*enode.Node 80 BootstrapNodesV5 []*enode.Node `toml:",omitempty"` 81 StaticNodes []*enode.Node 82 TrustedNodes []*enode.Node 83 NetRestrict *netutil.Netlist `toml:",omitempty"` 84 NodeDatabase *string `toml:",omitempty"` 85 Protocols []Protocol `toml:"-" json:"-"` 86 ListenAddr *string 87 DiscAddr *string 88 NAT *configNAT `toml:",omitempty"` 89 Dialer NodeDialer `toml:"-"` 90 NoDial *bool `toml:",omitempty"` 91 EnableMsgEvents *bool 92 Logger log.Logger `toml:"-"` 93 } 94 var dec Config 95 if err := unmarshal(&dec); err != nil { 96 return err 97 } 98 if dec.PrivateKey != nil { 99 c.PrivateKey = dec.PrivateKey 100 } 101 if dec.MaxPeers != nil { 102 c.MaxPeers = *dec.MaxPeers 103 } 104 if dec.MaxPendingPeers != nil { 105 c.MaxPendingPeers = *dec.MaxPendingPeers 106 } 107 if dec.DialRatio != nil { 108 c.DialRatio = *dec.DialRatio 109 } 110 if dec.NoDiscovery != nil { 111 c.NoDiscovery = *dec.NoDiscovery 112 } 113 if dec.DiscoveryV4 != nil { 114 c.DiscoveryV4 = *dec.DiscoveryV4 115 } 116 if dec.DiscoveryV5 != nil { 117 c.DiscoveryV5 = *dec.DiscoveryV5 118 } 119 if dec.Name != nil { 120 c.Name = *dec.Name 121 } 122 if dec.BootstrapNodes != nil { 123 c.BootstrapNodes = dec.BootstrapNodes 124 } 125 if dec.BootstrapNodesV5 != nil { 126 c.BootstrapNodesV5 = dec.BootstrapNodesV5 127 } 128 if dec.StaticNodes != nil { 129 c.StaticNodes = dec.StaticNodes 130 } 131 if dec.TrustedNodes != nil { 132 c.TrustedNodes = dec.TrustedNodes 133 } 134 if dec.NetRestrict != nil { 135 c.NetRestrict = dec.NetRestrict 136 } 137 if dec.NodeDatabase != nil { 138 c.NodeDatabase = *dec.NodeDatabase 139 } 140 if dec.Protocols != nil { 141 c.Protocols = dec.Protocols 142 } 143 if dec.ListenAddr != nil { 144 c.ListenAddr = *dec.ListenAddr 145 } 146 if dec.DiscAddr != nil { 147 c.DiscAddr = *dec.DiscAddr 148 } 149 if dec.NAT != nil { 150 c.NAT = dec.NAT 151 } 152 if dec.Dialer != nil { 153 c.Dialer = dec.Dialer 154 } 155 if dec.NoDial != nil { 156 c.NoDial = *dec.NoDial 157 } 158 if dec.EnableMsgEvents != nil { 159 c.EnableMsgEvents = *dec.EnableMsgEvents 160 } 161 if dec.Logger != nil { 162 c.Logger = dec.Logger 163 } 164 return nil 165 }