all: format golang files (#1548)

Co-authored-by: wit <wit765765346@gmail>
This commit is contained in:
wit liu 2025-09-21 19:41:54 +08:00 committed by GitHub
parent 03c18e9d47
commit d9ae317a38
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
16 changed files with 122 additions and 119 deletions

View file

@ -113,7 +113,7 @@ func (Failure_FailureType) EnumDescriptor() ([]byte, []int) {
return file_messages_common_proto_rawDescGZIP(), []int{1, 0} return file_messages_common_proto_rawDescGZIP(), []int{1, 0}
} }
//* // *
// Type of button request // Type of button request
type ButtonRequest_ButtonRequestType int32 type ButtonRequest_ButtonRequestType int32
@ -210,7 +210,7 @@ func (ButtonRequest_ButtonRequestType) EnumDescriptor() ([]byte, []int) {
return file_messages_common_proto_rawDescGZIP(), []int{2, 0} return file_messages_common_proto_rawDescGZIP(), []int{2, 0}
} }
//* // *
// Type of PIN request // Type of PIN request
type PinMatrixRequest_PinMatrixRequestType int32 type PinMatrixRequest_PinMatrixRequestType int32
@ -271,7 +271,7 @@ func (PinMatrixRequest_PinMatrixRequestType) EnumDescriptor() ([]byte, []int) {
return file_messages_common_proto_rawDescGZIP(), []int{4, 0} return file_messages_common_proto_rawDescGZIP(), []int{4, 0}
} }
//* // *
// Response: Success of the previous request // Response: Success of the previous request
// @end // @end
type Success struct { type Success struct {
@ -321,7 +321,7 @@ func (x *Success) GetMessage() string {
return "" return ""
} }
//* // *
// Response: Failure of the previous request // Response: Failure of the previous request
// @end // @end
type Failure struct { type Failure struct {
@ -379,7 +379,7 @@ func (x *Failure) GetMessage() string {
return "" return ""
} }
//* // *
// Response: Device is waiting for HW button press. // Response: Device is waiting for HW button press.
// @auxstart // @auxstart
// @next ButtonAck // @next ButtonAck
@ -438,7 +438,7 @@ func (x *ButtonRequest) GetData() string {
return "" return ""
} }
//* // *
// Request: Computer agrees to wait for HW button press // Request: Computer agrees to wait for HW button press
// @auxend // @auxend
type ButtonAck struct { type ButtonAck struct {
@ -530,7 +530,7 @@ func (x *PinMatrixRequest) GetType() PinMatrixRequest_PinMatrixRequestType {
return PinMatrixRequest_PinMatrixRequestType_Current return PinMatrixRequest_PinMatrixRequestType_Current
} }
//* // *
// Request: Computer responds with encoded PIN // Request: Computer responds with encoded PIN
// @auxend // @auxend
type PinMatrixAck struct { type PinMatrixAck struct {
@ -580,7 +580,7 @@ func (x *PinMatrixAck) GetPin() string {
return "" return ""
} }
//* // *
// Response: Device awaits encryption passphrase // Response: Device awaits encryption passphrase
// @auxstart // @auxstart
// @next PassphraseAck // @next PassphraseAck
@ -631,7 +631,7 @@ func (x *PassphraseRequest) GetOnDevice() bool {
return false return false
} }
//* // *
// Request: Send passphrase back // Request: Send passphrase back
// @next PassphraseStateRequest // @next PassphraseStateRequest
type PassphraseAck struct { type PassphraseAck struct {
@ -689,7 +689,7 @@ func (x *PassphraseAck) GetState() []byte {
return nil return nil
} }
//* // *
// Response: Device awaits passphrase state // Response: Device awaits passphrase state
// @next PassphraseStateAck // @next PassphraseStateAck
type PassphraseStateRequest struct { type PassphraseStateRequest struct {
@ -739,7 +739,7 @@ func (x *PassphraseStateRequest) GetState() []byte {
return nil return nil
} }
//* // *
// Request: Send passphrase state back // Request: Send passphrase state back
// @auxend // @auxend
type PassphraseStateAck struct { type PassphraseStateAck struct {

View file

@ -24,7 +24,7 @@ const (
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
) )
//* // *
// Request: Ask device for public key corresponding to address_n path // Request: Ask device for public key corresponding to address_n path
// @start // @start
// @next EthereumPublicKey // @next EthereumPublicKey
@ -84,7 +84,7 @@ func (x *EthereumGetPublicKey) GetShowDisplay() bool {
return false return false
} }
//* // *
// Response: Contains public key derived from device private seed // Response: Contains public key derived from device private seed
// @end // @end
type EthereumPublicKey struct { type EthereumPublicKey struct {
@ -142,7 +142,7 @@ func (x *EthereumPublicKey) GetXpub() string {
return "" return ""
} }
//* // *
// Request: Ask device for Ethereum address corresponding to address_n path // Request: Ask device for Ethereum address corresponding to address_n path
// @start // @start
// @next EthereumAddress // @next EthereumAddress
@ -202,7 +202,7 @@ func (x *EthereumGetAddress) GetShowDisplay() bool {
return false return false
} }
//* // *
// Response: Contains an Ethereum address derived from device private seed // Response: Contains an Ethereum address derived from device private seed
// @end // @end
type EthereumAddress struct { type EthereumAddress struct {
@ -260,7 +260,7 @@ func (x *EthereumAddress) GetAddressHex() string {
return "" return ""
} }
//* // *
// Request: Ask device to sign transaction // Request: Ask device to sign transaction
// All fields are optional from the protocol's point of view. Each field defaults to value `0` if missing. // All fields are optional from the protocol's point of view. Each field defaults to value `0` if missing.
// Note: the first at most 1024 bytes of data MUST be transmitted as part of this message. // Note: the first at most 1024 bytes of data MUST be transmitted as part of this message.
@ -394,7 +394,7 @@ func (x *EthereumSignTx) GetTxType() uint32 {
return 0 return 0
} }
//* // *
// Response: Device asks for more data from transaction payload, or returns the signature. // Response: Device asks for more data from transaction payload, or returns the signature.
// If data_length is set, device awaits that many more bytes of payload. // If data_length is set, device awaits that many more bytes of payload.
// Otherwise, the signature_* fields contain the computed transaction signature. All three fields will be present. // Otherwise, the signature_* fields contain the computed transaction signature. All three fields will be present.
@ -471,7 +471,7 @@ func (x *EthereumTxRequest) GetSignatureS() []byte {
return nil return nil
} }
//* // *
// Request: Transaction payload data. // Request: Transaction payload data.
// @next EthereumTxRequest // @next EthereumTxRequest
type EthereumTxAck struct { type EthereumTxAck struct {
@ -521,7 +521,7 @@ func (x *EthereumTxAck) GetDataChunk() []byte {
return nil return nil
} }
//* // *
// Request: Ask device to sign message // Request: Ask device to sign message
// @start // @start
// @next EthereumMessageSignature // @next EthereumMessageSignature
@ -581,7 +581,7 @@ func (x *EthereumSignMessage) GetMessage() []byte {
return nil return nil
} }
//* // *
// Response: Signed message // Response: Signed message
// @end // @end
type EthereumMessageSignature struct { type EthereumMessageSignature struct {
@ -647,7 +647,7 @@ func (x *EthereumMessageSignature) GetAddressHex() string {
return "" return ""
} }
//* // *
// Request: Ask device to verify message // Request: Ask device to verify message
// @start // @start
// @next Success // @next Success

View file

@ -24,7 +24,7 @@ const (
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
) )
//* // *
// Structure representing passphrase source // Structure representing passphrase source
type ApplySettings_PassphraseSourceType int32 type ApplySettings_PassphraseSourceType int32
@ -85,7 +85,7 @@ func (ApplySettings_PassphraseSourceType) EnumDescriptor() ([]byte, []int) {
return file_messages_management_proto_rawDescGZIP(), []int{4, 0} return file_messages_management_proto_rawDescGZIP(), []int{4, 0}
} }
//* // *
// Type of recovery procedure. These should be used as bitmask, e.g., // Type of recovery procedure. These should be used as bitmask, e.g.,
// `RecoveryDeviceType_ScrambledWords | RecoveryDeviceType_Matrix` // `RecoveryDeviceType_ScrambledWords | RecoveryDeviceType_Matrix`
// listing every method supported by the host computer. // listing every method supported by the host computer.
@ -149,7 +149,7 @@ func (RecoveryDevice_RecoveryDeviceType) EnumDescriptor() ([]byte, []int) {
return file_messages_management_proto_rawDescGZIP(), []int{17, 0} return file_messages_management_proto_rawDescGZIP(), []int{17, 0}
} }
//* // *
// Type of Recovery Word request // Type of Recovery Word request
type WordRequest_WordRequestType int32 type WordRequest_WordRequestType int32
@ -210,7 +210,7 @@ func (WordRequest_WordRequestType) EnumDescriptor() ([]byte, []int) {
return file_messages_management_proto_rawDescGZIP(), []int{18, 0} return file_messages_management_proto_rawDescGZIP(), []int{18, 0}
} }
//* // *
// Request: Reset device to default state and ask for device details // Request: Reset device to default state and ask for device details
// @start // @start
// @next Features // @next Features
@ -269,7 +269,7 @@ func (x *Initialize) GetSkipPassphrase() bool {
return false return false
} }
//* // *
// Request: Ask for device details (no device reset) // Request: Ask for device details (no device reset)
// @start // @start
// @next Features // @next Features
@ -569,7 +569,7 @@ func (x *Features) GetNoBackup() bool {
return false return false
} }
//* // *
// Request: clear session (removes cached PIN, passphrase, etc). // Request: clear session (removes cached PIN, passphrase, etc).
// @start // @start
// @next Success // @next Success
@ -711,7 +711,7 @@ func (x *ApplySettings) GetDisplayRotation() uint32 {
return 0 return 0
} }
//* // *
// Request: set flags of the device // Request: set flags of the device
// @start // @start
// @next Success // @next Success
@ -763,7 +763,7 @@ func (x *ApplyFlags) GetFlags() uint32 {
return 0 return 0
} }
//* // *
// Request: Starts workflow for setting/changing/removing the PIN // Request: Starts workflow for setting/changing/removing the PIN
// @start // @start
// @next Success // @next Success
@ -815,7 +815,7 @@ func (x *ChangePin) GetRemove() bool {
return false return false
} }
//* // *
// Request: Test if the device is alive, device sends back the message in Success response // Request: Test if the device is alive, device sends back the message in Success response
// @start // @start
// @next Success // @next Success
@ -890,7 +890,7 @@ func (x *Ping) GetPassphraseProtection() bool {
return false return false
} }
//* // *
// Request: Abort last operation that required user interaction // Request: Abort last operation that required user interaction
// @start // @start
// @next Failure // @next Failure
@ -984,7 +984,7 @@ func (x *GetEntropy) GetSize() uint32 {
return 0 return 0
} }
//* // *
// Response: Reply with random data generated by internal RNG // Response: Reply with random data generated by internal RNG
// @end // @end
type Entropy struct { type Entropy struct {
@ -1034,7 +1034,7 @@ func (x *Entropy) GetEntropy() []byte {
return nil return nil
} }
//* // *
// Request: Request device to wipe all sensitive data and settings // Request: Request device to wipe all sensitive data and settings
// @start // @start
// @next Success // @next Success
@ -1190,7 +1190,7 @@ func (x *LoadDevice) GetU2FCounter() uint32 {
return 0 return 0
} }
//* // *
// Request: Ask device to do initialization involving user interaction // Request: Ask device to do initialization involving user interaction
// @start // @start
// @next EntropyRequest // @next EntropyRequest
@ -1312,7 +1312,7 @@ func (x *ResetDevice) GetNoBackup() bool {
return false return false
} }
//* // *
// Request: Perform backup of the device seed if not backed up using ResetDevice // Request: Perform backup of the device seed if not backed up using ResetDevice
// @start // @start
// @next Success // @next Success
@ -1445,7 +1445,7 @@ func (x *EntropyAck) GetEntropy() []byte {
return nil return nil
} }
//* // *
// Request: Start recovery workflow asking user for specific words of mnemonic // Request: Start recovery workflow asking user for specific words of mnemonic
// Used to recovery device safely even on untrusted computer. // Used to recovery device safely even on untrusted computer.
// @start // @start
@ -1567,7 +1567,7 @@ func (x *RecoveryDevice) GetDryRun() bool {
return false return false
} }
//* // *
// Response: Device is waiting for user to enter word of the mnemonic // Response: Device is waiting for user to enter word of the mnemonic
// Its position is shown only on device's internal display. // Its position is shown only on device's internal display.
// @next WordAck // @next WordAck
@ -1618,7 +1618,7 @@ func (x *WordRequest) GetType() WordRequest_WordRequestType {
return WordRequest_WordRequestType_Plain return WordRequest_WordRequestType_Plain
} }
//* // *
// Request: Computer replies with word from the mnemonic // Request: Computer replies with word from the mnemonic
// @next WordRequest // @next WordRequest
// @next Success // @next Success
@ -1670,7 +1670,7 @@ func (x *WordAck) GetWord() string {
return "" return ""
} }
//* // *
// Request: Set U2F counter // Request: Set U2F counter
// @start // @start
// @next Success // @next Success

View file

@ -25,7 +25,7 @@ const (
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
) )
//* // *
// Mapping between TREZOR wire identifier (uint) and a protobuf message // Mapping between TREZOR wire identifier (uint) and a protobuf message
type MessageType int32 type MessageType int32

View file

@ -19,4 +19,3 @@ import (
_ "github.com/XinFinOrg/XDPoSChain/crypto/secp256k1/libsecp256k1/src" _ "github.com/XinFinOrg/XDPoSChain/crypto/secp256k1/libsecp256k1/src"
_ "github.com/XinFinOrg/XDPoSChain/crypto/secp256k1/libsecp256k1/src/modules/recovery" _ "github.com/XinFinOrg/XDPoSChain/crypto/secp256k1/libsecp256k1/src/modules/recovery"
) )

View file

@ -477,6 +477,7 @@ func (q *queue) ReserveReceipts(p *peerConnection, count int) (*fetchRequest, bo
// to access the queue, so they already need a lock anyway. // to access the queue, so they already need a lock anyway.
// //
// Returns: // Returns:
//
// item - the fetchRequest // item - the fetchRequest
// progress - whether any progress was made // progress - whether any progress was made
// throttle - if the caller should throttle for a while // throttle - if the caller should throttle for a while

View file

@ -71,6 +71,7 @@ func (r *resultStore) SetThrottleThreshold(threshold uint64) uint64 {
// wants to reserve headers for fetching. // wants to reserve headers for fetching.
// //
// It returns the following: // It returns the following:
//
// stale - if true, this item is already passed, and should not be requested again // stale - if true, this item is already passed, and should not be requested again
// throttled - if true, the store is at capacity, this particular header is not prio now // throttled - if true, the store is at capacity, this particular header is not prio now
// item - the result to store data into // item - the result to store data into

View file

@ -14,6 +14,7 @@
// You should have received a copy of the GNU Lesser General Public License // You should have received a copy of the GNU Lesser General Public License
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>. // along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
//go:build go1.4 && nacl && faketime_simulation
// +build go1.4,nacl,faketime_simulation // +build go1.4,nacl,faketime_simulation
package discv5 package discv5

View file

@ -14,7 +14,8 @@
// You should have received a copy of the GNU Lesser General Public License // You should have received a copy of the GNU Lesser General Public License
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>. // along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
//+build !windows //go:build !windows
// +build !windows
package netutil package netutil

View file

@ -14,7 +14,8 @@
// You should have received a copy of the GNU Lesser General Public License // You should have received a copy of the GNU Lesser General Public License
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>. // along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
//+build windows //go:build windows
// +build windows
package netutil package netutil

View file

@ -28,20 +28,20 @@ import (
"github.com/XinFinOrg/XDPoSChain/p2p/discover" "github.com/XinFinOrg/XDPoSChain/p2p/discover"
) )
//a map of mocker names to its function // a map of mocker names to its function
var mockerList = map[string]func(net *Network, quit chan struct{}, nodeCount int){ var mockerList = map[string]func(net *Network, quit chan struct{}, nodeCount int){
"startStop": startStop, "startStop": startStop,
"probabilistic": probabilistic, "probabilistic": probabilistic,
"boot": boot, "boot": boot,
} }
//Lookup a mocker by its name, returns the mockerFn // Lookup a mocker by its name, returns the mockerFn
func LookupMocker(mockerType string) func(net *Network, quit chan struct{}, nodeCount int) { func LookupMocker(mockerType string) func(net *Network, quit chan struct{}, nodeCount int) {
return mockerList[mockerType] return mockerList[mockerType]
} }
//Get a list of mockers (keys of the map) // Get a list of mockers (keys of the map)
//Useful for frontend to build available mocker selection // Useful for frontend to build available mocker selection
func GetMockerList() []string { func GetMockerList() []string {
list := make([]string, 0, len(mockerList)) list := make([]string, 0, len(mockerList))
for k := range mockerList { for k := range mockerList {
@ -50,7 +50,7 @@ func GetMockerList() []string {
return list return list
} }
//The boot mockerFn only connects the node in a ring and doesn't do anything else // The boot mockerFn only connects the node in a ring and doesn't do anything else
func boot(net *Network, quit chan struct{}, nodeCount int) { func boot(net *Network, quit chan struct{}, nodeCount int) {
_, err := connectNodesInRing(net, nodeCount) _, err := connectNodesInRing(net, nodeCount)
if err != nil { if err != nil {
@ -58,7 +58,7 @@ func boot(net *Network, quit chan struct{}, nodeCount int) {
} }
} }
//The startStop mockerFn stops and starts nodes in a defined period (ticker) // The startStop mockerFn stops and starts nodes in a defined period (ticker)
func startStop(net *Network, quit chan struct{}, nodeCount int) { func startStop(net *Network, quit chan struct{}, nodeCount int) {
nodes, err := connectNodesInRing(net, nodeCount) nodes, err := connectNodesInRing(net, nodeCount)
if err != nil { if err != nil {
@ -95,10 +95,10 @@ func startStop(net *Network, quit chan struct{}, nodeCount int) {
} }
} }
//The probabilistic mocker func has a more probabilistic pattern // The probabilistic mocker func has a more probabilistic pattern
//(the implementation could probably be improved): // (the implementation could probably be improved):
//nodes are connected in a ring, then a varying number of random nodes is selected, // nodes are connected in a ring, then a varying number of random nodes is selected,
//mocker then stops and starts them in random intervals, and continues the loop // mocker then stops and starts them in random intervals, and continues the loop
func probabilistic(net *Network, quit chan struct{}, nodeCount int) { func probabilistic(net *Network, quit chan struct{}, nodeCount int) {
nodes, err := connectNodesInRing(net, nodeCount) nodes, err := connectNodesInRing(net, nodeCount)
if err != nil { if err != nil {
@ -161,7 +161,7 @@ func probabilistic(net *Network, quit chan struct{}, nodeCount int) {
} }
//connect nodeCount number of nodes in a ring // connect nodeCount number of nodes in a ring
func connectNodesInRing(net *Network, nodeCount int) ([]discover.NodeID, error) { func connectNodesInRing(net *Network, nodeCount int) ([]discover.NodeID, error) {
ids := make([]discover.NodeID, nodeCount) ids := make([]discover.NodeID, nodeCount)
for i := 0; i < nodeCount; i++ { for i := 0; i < nodeCount; i++ {

View file

@ -15,7 +15,6 @@
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>. // along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
/* /*
Package rpc implements bi-directional JSON-RPC 2.0 on multiple transports. Package rpc implements bi-directional JSON-RPC 2.0 on multiple transports.
It provides access to the exported methods of an object across a network or other I/O It provides access to the exported methods of an object across a network or other I/O
@ -23,7 +22,7 @@ connection. After creating a server or client instance, objects can be registere
them visible as 'services'. Exported methods that follow specific conventions can be them visible as 'services'. Exported methods that follow specific conventions can be
called remotely. It also has support for the publish/subscribe pattern. called remotely. It also has support for the publish/subscribe pattern.
RPC Methods # RPC Methods
Methods that satisfy the following criteria are made available for remote access: Methods that satisfy the following criteria are made available for remote access:
@ -75,7 +74,7 @@ An example server which uses the JSON codec:
l, _ := net.ListenUnix("unix", &net.UnixAddr{Net: "unix", Name: "/tmp/calculator.sock"}) l, _ := net.ListenUnix("unix", &net.UnixAddr{Net: "unix", Name: "/tmp/calculator.sock"})
server.ServeListener(l) server.ServeListener(l)
Subscriptions # Subscriptions
The package also supports the publish subscribe pattern through the use of subscriptions. The package also supports the publish subscribe pattern through the use of subscriptions.
A method that is considered eligible for notifications must satisfy the following A method that is considered eligible for notifications must satisfy the following
@ -101,7 +100,7 @@ the client and server. The server will close the connection for any write error.
For more information about subscriptions, see https://geth.ethereum.org/docs/interacting-with-geth/rpc/pubsub For more information about subscriptions, see https://geth.ethereum.org/docs/interacting-with-geth/rpc/pubsub
Reverse Calls # Reverse Calls
In any method handler, an instance of rpc.Client can be accessed through the In any method handler, an instance of rpc.Client can be accessed through the
ClientFromContext method. Using this client instance, server-to-client method calls can be ClientFromContext method. Using this client instance, server-to-client method calls can be