mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-17 18:30:45 +00:00
all: format golang files (#1548)
Co-authored-by: wit <wit765765346@gmail>
This commit is contained in:
parent
03c18e9d47
commit
d9ae317a38
16 changed files with 122 additions and 119 deletions
|
|
@ -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 {
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -298,9 +298,9 @@ func TestShouldNotSendVoteMsgIfBlockInfoRoundNotEqualCurrentRound(t *testing.T)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Block and round relationship diagram for this test
|
Block and round relationship diagram for this test
|
||||||
... - 13(3) - 14(4) - 15(5) - 16(6)
|
... - 13(3) - 14(4) - 15(5) - 16(6)
|
||||||
\ 14'(7)
|
\ 14'(7)
|
||||||
*/
|
*/
|
||||||
func TestShouldNotSendVoteMsgIfBlockNotExtendedFromAncestor(t *testing.T) {
|
func TestShouldNotSendVoteMsgIfBlockNotExtendedFromAncestor(t *testing.T) {
|
||||||
// Block number 905, 906 have forks and forkedBlock is the 906th
|
// Block number 905, 906 have forks and forkedBlock is the 906th
|
||||||
|
|
|
||||||
|
|
@ -19,19 +19,19 @@ var _ = (*genesisSpecMarshaling)(nil)
|
||||||
// MarshalJSON marshals as JSON.
|
// MarshalJSON marshals as JSON.
|
||||||
func (g Genesis) MarshalJSON() ([]byte, error) {
|
func (g Genesis) MarshalJSON() ([]byte, error) {
|
||||||
type Genesis struct {
|
type Genesis struct {
|
||||||
Config *params.ChainConfig `json:"config"`
|
Config *params.ChainConfig `json:"config"`
|
||||||
Nonce math.HexOrDecimal64 `json:"nonce"`
|
Nonce math.HexOrDecimal64 `json:"nonce"`
|
||||||
Timestamp math.HexOrDecimal64 `json:"timestamp"`
|
Timestamp math.HexOrDecimal64 `json:"timestamp"`
|
||||||
ExtraData hexutil.Bytes `json:"extraData"`
|
ExtraData hexutil.Bytes `json:"extraData"`
|
||||||
GasLimit math.HexOrDecimal64 `json:"gasLimit" gencodec:"required"`
|
GasLimit math.HexOrDecimal64 `json:"gasLimit" gencodec:"required"`
|
||||||
Difficulty *math.HexOrDecimal256 `json:"difficulty" gencodec:"required"`
|
Difficulty *math.HexOrDecimal256 `json:"difficulty" gencodec:"required"`
|
||||||
Mixhash common.Hash `json:"mixHash"`
|
Mixhash common.Hash `json:"mixHash"`
|
||||||
Coinbase common.Address `json:"coinbase"`
|
Coinbase common.Address `json:"coinbase"`
|
||||||
Alloc map[common.UnprefixedAddress]types.Account `json:"alloc" gencodec:"required"`
|
Alloc map[common.UnprefixedAddress]types.Account `json:"alloc" gencodec:"required"`
|
||||||
Number math.HexOrDecimal64 `json:"number"`
|
Number math.HexOrDecimal64 `json:"number"`
|
||||||
GasUsed math.HexOrDecimal64 `json:"gasUsed"`
|
GasUsed math.HexOrDecimal64 `json:"gasUsed"`
|
||||||
ParentHash common.Hash `json:"parentHash"`
|
ParentHash common.Hash `json:"parentHash"`
|
||||||
BaseFee *math.HexOrDecimal256 `json:"baseFeePerGas"`
|
BaseFee *math.HexOrDecimal256 `json:"baseFeePerGas"`
|
||||||
}
|
}
|
||||||
var enc Genesis
|
var enc Genesis
|
||||||
enc.Config = g.Config
|
enc.Config = g.Config
|
||||||
|
|
@ -58,19 +58,19 @@ func (g Genesis) MarshalJSON() ([]byte, error) {
|
||||||
// UnmarshalJSON unmarshals from JSON.
|
// UnmarshalJSON unmarshals from JSON.
|
||||||
func (g *Genesis) UnmarshalJSON(input []byte) error {
|
func (g *Genesis) UnmarshalJSON(input []byte) error {
|
||||||
type Genesis struct {
|
type Genesis struct {
|
||||||
Config *params.ChainConfig `json:"config"`
|
Config *params.ChainConfig `json:"config"`
|
||||||
Nonce *math.HexOrDecimal64 `json:"nonce"`
|
Nonce *math.HexOrDecimal64 `json:"nonce"`
|
||||||
Timestamp *math.HexOrDecimal64 `json:"timestamp"`
|
Timestamp *math.HexOrDecimal64 `json:"timestamp"`
|
||||||
ExtraData *hexutil.Bytes `json:"extraData"`
|
ExtraData *hexutil.Bytes `json:"extraData"`
|
||||||
GasLimit *math.HexOrDecimal64 `json:"gasLimit" gencodec:"required"`
|
GasLimit *math.HexOrDecimal64 `json:"gasLimit" gencodec:"required"`
|
||||||
Difficulty *math.HexOrDecimal256 `json:"difficulty" gencodec:"required"`
|
Difficulty *math.HexOrDecimal256 `json:"difficulty" gencodec:"required"`
|
||||||
Mixhash *common.Hash `json:"mixHash"`
|
Mixhash *common.Hash `json:"mixHash"`
|
||||||
Coinbase *common.Address `json:"coinbase"`
|
Coinbase *common.Address `json:"coinbase"`
|
||||||
Alloc map[common.UnprefixedAddress]types.Account `json:"alloc" gencodec:"required"`
|
Alloc map[common.UnprefixedAddress]types.Account `json:"alloc" gencodec:"required"`
|
||||||
Number *math.HexOrDecimal64 `json:"number"`
|
Number *math.HexOrDecimal64 `json:"number"`
|
||||||
GasUsed *math.HexOrDecimal64 `json:"gasUsed"`
|
GasUsed *math.HexOrDecimal64 `json:"gasUsed"`
|
||||||
ParentHash *common.Hash `json:"parentHash"`
|
ParentHash *common.Hash `json:"parentHash"`
|
||||||
BaseFee *math.HexOrDecimal256 `json:"baseFeePerGas"`
|
BaseFee *math.HexOrDecimal256 `json:"baseFeePerGas"`
|
||||||
}
|
}
|
||||||
var dec Genesis
|
var dec Genesis
|
||||||
if err := json.Unmarshal(input, &dec); err != nil {
|
if err := json.Unmarshal(input, &dec); err != nil {
|
||||||
|
|
|
||||||
|
|
@ -489,7 +489,7 @@ func (h *priceHeap) Pop() interface{} {
|
||||||
// better candidates for inclusion while in other cases (at the top of the baseFee peak)
|
// better candidates for inclusion while in other cases (at the top of the baseFee peak)
|
||||||
// the floating heap is better. When baseFee is decreasing they behave similarly.
|
// the floating heap is better. When baseFee is decreasing they behave similarly.
|
||||||
type pricedList struct {
|
type pricedList struct {
|
||||||
all *lookup // Pointer to the map of all transactions
|
all *lookup // Pointer to the map of all transactions
|
||||||
urgent, floating priceHeap // Heaps of prices of all the stored **remote** transactions
|
urgent, floating priceHeap // Heaps of prices of all the stored **remote** transactions
|
||||||
stales int64 // Number of stale price points to (re-heap trigger)
|
stales int64 // Number of stale price points to (re-heap trigger)
|
||||||
reheapMu sync.Mutex // Mutex asserts that only one routine is reheaping the list
|
reheapMu sync.Mutex // Mutex asserts that only one routine is reheaping the list
|
||||||
|
|
|
||||||
|
|
@ -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"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -477,9 +477,10 @@ 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
|
//
|
||||||
// progress - whether any progress was made
|
// item - the fetchRequest
|
||||||
// throttle - if the caller should throttle for a while
|
// progress - whether any progress was made
|
||||||
|
// throttle - if the caller should throttle for a while
|
||||||
func (q *queue) reserveHeaders(p *peerConnection, count int, taskPool map[common.Hash]*types.Header, taskQueue *prque.Prque[int64, *types.Header],
|
func (q *queue) reserveHeaders(p *peerConnection, count int, taskPool map[common.Hash]*types.Header, taskQueue *prque.Prque[int64, *types.Header],
|
||||||
pendPool map[string]*fetchRequest, kind uint) (*fetchRequest, bool, bool) {
|
pendPool map[string]*fetchRequest, kind uint) (*fetchRequest, bool, bool) {
|
||||||
// Short circuit if the pool has been depleted, or if the peer's already
|
// Short circuit if the pool has been depleted, or if the peer's already
|
||||||
|
|
|
||||||
|
|
@ -71,10 +71,11 @@ 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
|
//
|
||||||
// throttled - if true, the store is at capacity, this particular header is not prio now
|
// stale - if true, this item is already passed, and should not be requested again
|
||||||
// item - the result to store data into
|
// throttled - if true, the store is at capacity, this particular header is not prio now
|
||||||
// err - any error that occurred
|
// item - the result to store data into
|
||||||
|
// err - any error that occurred
|
||||||
func (r *resultStore) AddFetch(header *types.Header, fastSync bool) (stale, throttled bool, item *fetchResult, err error) {
|
func (r *resultStore) AddFetch(header *types.Header, fastSync bool) (stale, throttled bool, item *fetchResult, err error) {
|
||||||
r.lock.Lock()
|
r.lock.Lock()
|
||||||
defer r.lock.Unlock()
|
defer r.lock.Unlock()
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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++ {
|
||||||
|
|
|
||||||
57
rpc/doc.go
57
rpc/doc.go
|
|
@ -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,16 +22,16 @@ 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:
|
||||||
|
|
||||||
- method must be exported
|
- method must be exported
|
||||||
- method returns 0, 1 (response or error) or 2 (response and error) values
|
- method returns 0, 1 (response or error) or 2 (response and error) values
|
||||||
|
|
||||||
An example method:
|
An example method:
|
||||||
|
|
||||||
func (s *CalcService) Add(a, b int) (int, error)
|
func (s *CalcService) Add(a, b int) (int, error)
|
||||||
|
|
||||||
When the returned error isn't nil the returned integer is ignored and the error is sent
|
When the returned error isn't nil the returned integer is ignored and the error is sent
|
||||||
back to the client. Otherwise the returned integer is sent back to the client.
|
back to the client. Otherwise the returned integer is sent back to the client.
|
||||||
|
|
@ -41,7 +40,7 @@ Optional arguments are supported by accepting pointer values as arguments. E.g.
|
||||||
to do the addition in an optional finite field we can accept a mod argument as pointer
|
to do the addition in an optional finite field we can accept a mod argument as pointer
|
||||||
value.
|
value.
|
||||||
|
|
||||||
func (s *CalcService) Add(a, b int, mod *int) (int, error)
|
func (s *CalcService) Add(a, b int, mod *int) (int, error)
|
||||||
|
|
||||||
This RPC method can be called with 2 integers and a null value as third argument. In that
|
This RPC method can be called with 2 integers and a null value as third argument. In that
|
||||||
case the mod argument will be nil. Or it can be called with 3 integers, in that case mod
|
case the mod argument will be nil. Or it can be called with 3 integers, in that case mod
|
||||||
|
|
@ -56,40 +55,40 @@ to the client out of order.
|
||||||
|
|
||||||
An example server which uses the JSON codec:
|
An example server which uses the JSON codec:
|
||||||
|
|
||||||
type CalculatorService struct {}
|
type CalculatorService struct {}
|
||||||
|
|
||||||
func (s *CalculatorService) Add(a, b int) int {
|
func (s *CalculatorService) Add(a, b int) int {
|
||||||
return a + b
|
return a + b
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *CalculatorService) Div(a, b int) (int, error) {
|
func (s *CalculatorService) Div(a, b int) (int, error) {
|
||||||
if b == 0 {
|
if b == 0 {
|
||||||
return 0, errors.New("divide by zero")
|
return 0, errors.New("divide by zero")
|
||||||
}
|
}
|
||||||
return a/b, nil
|
return a/b, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
calculator := new(CalculatorService)
|
calculator := new(CalculatorService)
|
||||||
server := NewServer()
|
server := NewServer()
|
||||||
server.RegisterName("calculator", calculator)
|
server.RegisterName("calculator", calculator)
|
||||||
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
|
||||||
criteria:
|
criteria:
|
||||||
|
|
||||||
- method must be exported
|
- method must be exported
|
||||||
- first method argument type must be context.Context
|
- first method argument type must be context.Context
|
||||||
- method must have return types (rpc.Subscription, error)
|
- method must have return types (rpc.Subscription, error)
|
||||||
|
|
||||||
An example method:
|
An example method:
|
||||||
|
|
||||||
func (s *BlockChainService) NewBlocks(ctx context.Context) (rpc.Subscription, error) {
|
func (s *BlockChainService) NewBlocks(ctx context.Context) (rpc.Subscription, error) {
|
||||||
...
|
...
|
||||||
}
|
}
|
||||||
|
|
||||||
When the service containing the subscription method is registered to the server, for
|
When the service containing the subscription method is registered to the server, for
|
||||||
example under the "blockchain" namespace, a subscription is created by calling the
|
example under the "blockchain" namespace, a subscription is created by calling the
|
||||||
|
|
@ -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
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue