Documentation ¶
Index ¶
- Constants
- Variables
- func Mean(gasPrices []float64) float64
- func RegisterGasEstimationService(qrt gogogrpc.Server, clientCtx client.Context, simulateFn baseAppSimulateFn)
- func RegisterGasEstimatorServer(s grpc1.Server, srv GasEstimatorServer)
- func StandardDeviation(meanGasPrice float64, gasPrices []float64) float64
- type EstimateGasPriceAndUsageRequest
- func (*EstimateGasPriceAndUsageRequest) Descriptor() ([]byte, []int)
- func (m *EstimateGasPriceAndUsageRequest) GetTxBytes() []byte
- func (m *EstimateGasPriceAndUsageRequest) GetTxPriority() TxPriority
- func (m *EstimateGasPriceAndUsageRequest) Marshal() (dAtA []byte, err error)
- func (m *EstimateGasPriceAndUsageRequest) MarshalTo(dAtA []byte) (int, error)
- func (m *EstimateGasPriceAndUsageRequest) MarshalToSizedBuffer(dAtA []byte) (int, error)
- func (*EstimateGasPriceAndUsageRequest) ProtoMessage()
- func (m *EstimateGasPriceAndUsageRequest) Reset()
- func (m *EstimateGasPriceAndUsageRequest) Size() (n int)
- func (m *EstimateGasPriceAndUsageRequest) String() string
- func (m *EstimateGasPriceAndUsageRequest) Unmarshal(dAtA []byte) error
- func (m *EstimateGasPriceAndUsageRequest) XXX_DiscardUnknown()
- func (m *EstimateGasPriceAndUsageRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *EstimateGasPriceAndUsageRequest) XXX_Merge(src proto.Message)
- func (m *EstimateGasPriceAndUsageRequest) XXX_Size() int
- func (m *EstimateGasPriceAndUsageRequest) XXX_Unmarshal(b []byte) error
- type EstimateGasPriceAndUsageResponse
- func (*EstimateGasPriceAndUsageResponse) Descriptor() ([]byte, []int)
- func (m *EstimateGasPriceAndUsageResponse) GetEstimatedGasPrice() float64
- func (m *EstimateGasPriceAndUsageResponse) GetEstimatedGasUsed() uint64
- func (m *EstimateGasPriceAndUsageResponse) Marshal() (dAtA []byte, err error)
- func (m *EstimateGasPriceAndUsageResponse) MarshalTo(dAtA []byte) (int, error)
- func (m *EstimateGasPriceAndUsageResponse) MarshalToSizedBuffer(dAtA []byte) (int, error)
- func (*EstimateGasPriceAndUsageResponse) ProtoMessage()
- func (m *EstimateGasPriceAndUsageResponse) Reset()
- func (m *EstimateGasPriceAndUsageResponse) Size() (n int)
- func (m *EstimateGasPriceAndUsageResponse) String() string
- func (m *EstimateGasPriceAndUsageResponse) Unmarshal(dAtA []byte) error
- func (m *EstimateGasPriceAndUsageResponse) XXX_DiscardUnknown()
- func (m *EstimateGasPriceAndUsageResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *EstimateGasPriceAndUsageResponse) XXX_Merge(src proto.Message)
- func (m *EstimateGasPriceAndUsageResponse) XXX_Size() int
- func (m *EstimateGasPriceAndUsageResponse) XXX_Unmarshal(b []byte) error
- type EstimateGasPriceRequest
- func (*EstimateGasPriceRequest) Descriptor() ([]byte, []int)
- func (m *EstimateGasPriceRequest) GetTxPriority() TxPriority
- func (m *EstimateGasPriceRequest) Marshal() (dAtA []byte, err error)
- func (m *EstimateGasPriceRequest) MarshalTo(dAtA []byte) (int, error)
- func (m *EstimateGasPriceRequest) MarshalToSizedBuffer(dAtA []byte) (int, error)
- func (*EstimateGasPriceRequest) ProtoMessage()
- func (m *EstimateGasPriceRequest) Reset()
- func (m *EstimateGasPriceRequest) Size() (n int)
- func (m *EstimateGasPriceRequest) String() string
- func (m *EstimateGasPriceRequest) Unmarshal(dAtA []byte) error
- func (m *EstimateGasPriceRequest) XXX_DiscardUnknown()
- func (m *EstimateGasPriceRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *EstimateGasPriceRequest) XXX_Merge(src proto.Message)
- func (m *EstimateGasPriceRequest) XXX_Size() int
- func (m *EstimateGasPriceRequest) XXX_Unmarshal(b []byte) error
- type EstimateGasPriceResponse
- func (*EstimateGasPriceResponse) Descriptor() ([]byte, []int)
- func (m *EstimateGasPriceResponse) GetEstimatedGasPrice() float64
- func (m *EstimateGasPriceResponse) Marshal() (dAtA []byte, err error)
- func (m *EstimateGasPriceResponse) MarshalTo(dAtA []byte) (int, error)
- func (m *EstimateGasPriceResponse) MarshalToSizedBuffer(dAtA []byte) (int, error)
- func (*EstimateGasPriceResponse) ProtoMessage()
- func (m *EstimateGasPriceResponse) Reset()
- func (m *EstimateGasPriceResponse) Size() (n int)
- func (m *EstimateGasPriceResponse) String() string
- func (m *EstimateGasPriceResponse) Unmarshal(dAtA []byte) error
- func (m *EstimateGasPriceResponse) XXX_DiscardUnknown()
- func (m *EstimateGasPriceResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *EstimateGasPriceResponse) XXX_Merge(src proto.Message)
- func (m *EstimateGasPriceResponse) XXX_Size() int
- func (m *EstimateGasPriceResponse) XXX_Unmarshal(b []byte) error
- type GasEstimatorClient
- type GasEstimatorServer
- type TxPriority
- type UnimplementedGasEstimatorServer
- func (*UnimplementedGasEstimatorServer) EstimateGasPrice(ctx context.Context, req *EstimateGasPriceRequest) (*EstimateGasPriceResponse, error)
- func (*UnimplementedGasEstimatorServer) EstimateGasPriceAndUsage(ctx context.Context, req *EstimateGasPriceAndUsageRequest) (*EstimateGasPriceAndUsageResponse, error)
Constants ¶
const EstimationZScore = 1.28
EstimationZScore is the z-score corresponding to 10% and 90% of the gas prices distribution. More information can be found in: https://en.wikipedia.org/wiki/Standard_normal_table#Cumulative_(less_than_Z)
Variables ¶
var ( ErrInvalidLengthGasEstimator = fmt.Errorf("proto: negative length found during unmarshaling") ErrIntOverflowGasEstimator = fmt.Errorf("proto: integer overflow") ErrUnexpectedEndOfGroupGasEstimator = fmt.Errorf("proto: unexpected end of group") )
var TxPriority_name = map[int32]string{
0: "TX_PRIORITY_UNSPECIFIED",
1: "TX_PRIORITY_LOW",
2: "TX_PRIORITY_MEDIUM",
3: "TX_PRIORITY_HIGH",
}
var TxPriority_value = map[string]int32{
"TX_PRIORITY_UNSPECIFIED": 0,
"TX_PRIORITY_LOW": 1,
"TX_PRIORITY_MEDIUM": 2,
"TX_PRIORITY_HIGH": 3,
}
Functions ¶
func RegisterGasEstimationService ¶
func RegisterGasEstimationService(qrt gogogrpc.Server, clientCtx client.Context, simulateFn baseAppSimulateFn)
RegisterGasEstimationService registers the gas estimation service on the gRPC router.
func RegisterGasEstimatorServer ¶
func RegisterGasEstimatorServer(s grpc1.Server, srv GasEstimatorServer)
func StandardDeviation ¶
StandardDeviation calculates the standard deviation of the provided gas prices.
Types ¶
type EstimateGasPriceAndUsageRequest ¶
type EstimateGasPriceAndUsageRequest struct { TxPriority TxPriority `` /* 140-byte string literal not displayed */ TxBytes []byte `protobuf:"bytes,2,opt,name=tx_bytes,json=txBytes,proto3" json:"tx_bytes,omitempty"` }
EstimateGasPriceAndUsageRequest the request to estimate the gas price of the network and also the gas used for the provided transaction.
func (*EstimateGasPriceAndUsageRequest) Descriptor ¶
func (*EstimateGasPriceAndUsageRequest) Descriptor() ([]byte, []int)
func (*EstimateGasPriceAndUsageRequest) GetTxBytes ¶
func (m *EstimateGasPriceAndUsageRequest) GetTxBytes() []byte
func (*EstimateGasPriceAndUsageRequest) GetTxPriority ¶
func (m *EstimateGasPriceAndUsageRequest) GetTxPriority() TxPriority
func (*EstimateGasPriceAndUsageRequest) Marshal ¶
func (m *EstimateGasPriceAndUsageRequest) Marshal() (dAtA []byte, err error)
func (*EstimateGasPriceAndUsageRequest) MarshalTo ¶
func (m *EstimateGasPriceAndUsageRequest) MarshalTo(dAtA []byte) (int, error)
func (*EstimateGasPriceAndUsageRequest) MarshalToSizedBuffer ¶
func (m *EstimateGasPriceAndUsageRequest) MarshalToSizedBuffer(dAtA []byte) (int, error)
func (*EstimateGasPriceAndUsageRequest) ProtoMessage ¶
func (*EstimateGasPriceAndUsageRequest) ProtoMessage()
func (*EstimateGasPriceAndUsageRequest) Reset ¶
func (m *EstimateGasPriceAndUsageRequest) Reset()
func (*EstimateGasPriceAndUsageRequest) Size ¶
func (m *EstimateGasPriceAndUsageRequest) Size() (n int)
func (*EstimateGasPriceAndUsageRequest) String ¶
func (m *EstimateGasPriceAndUsageRequest) String() string
func (*EstimateGasPriceAndUsageRequest) Unmarshal ¶
func (m *EstimateGasPriceAndUsageRequest) Unmarshal(dAtA []byte) error
func (*EstimateGasPriceAndUsageRequest) XXX_DiscardUnknown ¶
func (m *EstimateGasPriceAndUsageRequest) XXX_DiscardUnknown()
func (*EstimateGasPriceAndUsageRequest) XXX_Marshal ¶
func (m *EstimateGasPriceAndUsageRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*EstimateGasPriceAndUsageRequest) XXX_Merge ¶
func (m *EstimateGasPriceAndUsageRequest) XXX_Merge(src proto.Message)
func (*EstimateGasPriceAndUsageRequest) XXX_Size ¶
func (m *EstimateGasPriceAndUsageRequest) XXX_Size() int
func (*EstimateGasPriceAndUsageRequest) XXX_Unmarshal ¶
func (m *EstimateGasPriceAndUsageRequest) XXX_Unmarshal(b []byte) error
type EstimateGasPriceAndUsageResponse ¶
type EstimateGasPriceAndUsageResponse struct { EstimatedGasPrice float64 `protobuf:"fixed64,1,opt,name=estimated_gas_price,json=estimatedGasPrice,proto3" json:"estimated_gas_price,omitempty"` EstimatedGasUsed uint64 `protobuf:"varint,2,opt,name=estimated_gas_used,json=estimatedGasUsed,proto3" json:"estimated_gas_used,omitempty"` }
EstimateGasPriceAndUsageResponse the response of the gas price and used estimation.
func (*EstimateGasPriceAndUsageResponse) Descriptor ¶
func (*EstimateGasPriceAndUsageResponse) Descriptor() ([]byte, []int)
func (*EstimateGasPriceAndUsageResponse) GetEstimatedGasPrice ¶
func (m *EstimateGasPriceAndUsageResponse) GetEstimatedGasPrice() float64
func (*EstimateGasPriceAndUsageResponse) GetEstimatedGasUsed ¶
func (m *EstimateGasPriceAndUsageResponse) GetEstimatedGasUsed() uint64
func (*EstimateGasPriceAndUsageResponse) Marshal ¶
func (m *EstimateGasPriceAndUsageResponse) Marshal() (dAtA []byte, err error)
func (*EstimateGasPriceAndUsageResponse) MarshalTo ¶
func (m *EstimateGasPriceAndUsageResponse) MarshalTo(dAtA []byte) (int, error)
func (*EstimateGasPriceAndUsageResponse) MarshalToSizedBuffer ¶
func (m *EstimateGasPriceAndUsageResponse) MarshalToSizedBuffer(dAtA []byte) (int, error)
func (*EstimateGasPriceAndUsageResponse) ProtoMessage ¶
func (*EstimateGasPriceAndUsageResponse) ProtoMessage()
func (*EstimateGasPriceAndUsageResponse) Reset ¶
func (m *EstimateGasPriceAndUsageResponse) Reset()
func (*EstimateGasPriceAndUsageResponse) Size ¶
func (m *EstimateGasPriceAndUsageResponse) Size() (n int)
func (*EstimateGasPriceAndUsageResponse) String ¶
func (m *EstimateGasPriceAndUsageResponse) String() string
func (*EstimateGasPriceAndUsageResponse) Unmarshal ¶
func (m *EstimateGasPriceAndUsageResponse) Unmarshal(dAtA []byte) error
func (*EstimateGasPriceAndUsageResponse) XXX_DiscardUnknown ¶
func (m *EstimateGasPriceAndUsageResponse) XXX_DiscardUnknown()
func (*EstimateGasPriceAndUsageResponse) XXX_Marshal ¶
func (m *EstimateGasPriceAndUsageResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*EstimateGasPriceAndUsageResponse) XXX_Merge ¶
func (m *EstimateGasPriceAndUsageResponse) XXX_Merge(src proto.Message)
func (*EstimateGasPriceAndUsageResponse) XXX_Size ¶
func (m *EstimateGasPriceAndUsageResponse) XXX_Size() int
func (*EstimateGasPriceAndUsageResponse) XXX_Unmarshal ¶
func (m *EstimateGasPriceAndUsageResponse) XXX_Unmarshal(b []byte) error
type EstimateGasPriceRequest ¶
type EstimateGasPriceRequest struct {
TxPriority TxPriority `` /* 140-byte string literal not displayed */
}
EstimateGasPriceRequest the request to estimate the gas price of the network. Takes a priority enum to define the priority level.
func (*EstimateGasPriceRequest) Descriptor ¶
func (*EstimateGasPriceRequest) Descriptor() ([]byte, []int)
func (*EstimateGasPriceRequest) GetTxPriority ¶
func (m *EstimateGasPriceRequest) GetTxPriority() TxPriority
func (*EstimateGasPriceRequest) Marshal ¶
func (m *EstimateGasPriceRequest) Marshal() (dAtA []byte, err error)
func (*EstimateGasPriceRequest) MarshalTo ¶
func (m *EstimateGasPriceRequest) MarshalTo(dAtA []byte) (int, error)
func (*EstimateGasPriceRequest) MarshalToSizedBuffer ¶
func (m *EstimateGasPriceRequest) MarshalToSizedBuffer(dAtA []byte) (int, error)
func (*EstimateGasPriceRequest) ProtoMessage ¶
func (*EstimateGasPriceRequest) ProtoMessage()
func (*EstimateGasPriceRequest) Reset ¶
func (m *EstimateGasPriceRequest) Reset()
func (*EstimateGasPriceRequest) Size ¶
func (m *EstimateGasPriceRequest) Size() (n int)
func (*EstimateGasPriceRequest) String ¶
func (m *EstimateGasPriceRequest) String() string
func (*EstimateGasPriceRequest) Unmarshal ¶
func (m *EstimateGasPriceRequest) Unmarshal(dAtA []byte) error
func (*EstimateGasPriceRequest) XXX_DiscardUnknown ¶
func (m *EstimateGasPriceRequest) XXX_DiscardUnknown()
func (*EstimateGasPriceRequest) XXX_Marshal ¶
func (m *EstimateGasPriceRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*EstimateGasPriceRequest) XXX_Merge ¶
func (m *EstimateGasPriceRequest) XXX_Merge(src proto.Message)
func (*EstimateGasPriceRequest) XXX_Size ¶
func (m *EstimateGasPriceRequest) XXX_Size() int
func (*EstimateGasPriceRequest) XXX_Unmarshal ¶
func (m *EstimateGasPriceRequest) XXX_Unmarshal(b []byte) error
type EstimateGasPriceResponse ¶
type EstimateGasPriceResponse struct {
EstimatedGasPrice float64 `protobuf:"fixed64,1,opt,name=estimated_gas_price,json=estimatedGasPrice,proto3" json:"estimated_gas_price,omitempty"`
}
EstimateGasPriceResponse the response of the gas price estimation.
func (*EstimateGasPriceResponse) Descriptor ¶
func (*EstimateGasPriceResponse) Descriptor() ([]byte, []int)
func (*EstimateGasPriceResponse) GetEstimatedGasPrice ¶
func (m *EstimateGasPriceResponse) GetEstimatedGasPrice() float64
func (*EstimateGasPriceResponse) Marshal ¶
func (m *EstimateGasPriceResponse) Marshal() (dAtA []byte, err error)
func (*EstimateGasPriceResponse) MarshalTo ¶
func (m *EstimateGasPriceResponse) MarshalTo(dAtA []byte) (int, error)
func (*EstimateGasPriceResponse) MarshalToSizedBuffer ¶
func (m *EstimateGasPriceResponse) MarshalToSizedBuffer(dAtA []byte) (int, error)
func (*EstimateGasPriceResponse) ProtoMessage ¶
func (*EstimateGasPriceResponse) ProtoMessage()
func (*EstimateGasPriceResponse) Reset ¶
func (m *EstimateGasPriceResponse) Reset()
func (*EstimateGasPriceResponse) Size ¶
func (m *EstimateGasPriceResponse) Size() (n int)
func (*EstimateGasPriceResponse) String ¶
func (m *EstimateGasPriceResponse) String() string
func (*EstimateGasPriceResponse) Unmarshal ¶
func (m *EstimateGasPriceResponse) Unmarshal(dAtA []byte) error
func (*EstimateGasPriceResponse) XXX_DiscardUnknown ¶
func (m *EstimateGasPriceResponse) XXX_DiscardUnknown()
func (*EstimateGasPriceResponse) XXX_Marshal ¶
func (m *EstimateGasPriceResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*EstimateGasPriceResponse) XXX_Merge ¶
func (m *EstimateGasPriceResponse) XXX_Merge(src proto.Message)
func (*EstimateGasPriceResponse) XXX_Size ¶
func (m *EstimateGasPriceResponse) XXX_Size() int
func (*EstimateGasPriceResponse) XXX_Unmarshal ¶
func (m *EstimateGasPriceResponse) XXX_Unmarshal(b []byte) error
type GasEstimatorClient ¶
type GasEstimatorClient interface { // estimateGasPrice takes a transaction priority and estimates the gas price based // on the gas prices of the transactions in the last five blocks. // If no transaction is found in the last five blocks, return the network // min gas price. // It's up to the light client to set the gas price in this case // to the minimum gas price set by that node. EstimateGasPrice(ctx context.Context, in *EstimateGasPriceRequest, opts ...grpc.CallOption) (*EstimateGasPriceResponse, error) // EstimateGasPriceAndUsage takes a transaction priority and a transaction bytes // and estimates the gas price and the gas used for that transaction. // The gas price estimation is based on the gas prices of the transactions in the last five blocks. // If no transaction is found in the last five blocks, return the network // min gas price. // It's up to the light client to set the gas price in this case // to the minimum gas price set by that node. // The gas used is estimated using the state machine simulation. EstimateGasPriceAndUsage(ctx context.Context, in *EstimateGasPriceAndUsageRequest, opts ...grpc.CallOption) (*EstimateGasPriceAndUsageResponse, error) }
GasEstimatorClient is the client API for GasEstimator service.
For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
func NewGasEstimatorClient ¶
func NewGasEstimatorClient(cc grpc1.ClientConn) GasEstimatorClient
type GasEstimatorServer ¶
type GasEstimatorServer interface { // estimateGasPrice takes a transaction priority and estimates the gas price based // on the gas prices of the transactions in the last five blocks. // If no transaction is found in the last five blocks, return the network // min gas price. // It's up to the light client to set the gas price in this case // to the minimum gas price set by that node. EstimateGasPrice(context.Context, *EstimateGasPriceRequest) (*EstimateGasPriceResponse, error) // EstimateGasPriceAndUsage takes a transaction priority and a transaction bytes // and estimates the gas price and the gas used for that transaction. // The gas price estimation is based on the gas prices of the transactions in the last five blocks. // If no transaction is found in the last five blocks, return the network // min gas price. // It's up to the light client to set the gas price in this case // to the minimum gas price set by that node. // The gas used is estimated using the state machine simulation. EstimateGasPriceAndUsage(context.Context, *EstimateGasPriceAndUsageRequest) (*EstimateGasPriceAndUsageResponse, error) }
GasEstimatorServer is the server API for GasEstimator service.
func NewGasEstimatorServer ¶
func NewGasEstimatorServer(clientCtx client.Context, simulateFn baseAppSimulateFn) GasEstimatorServer
type TxPriority ¶
type TxPriority int32
TxPriority is the priority level of the requested gas price. The following priority levels are defined: - High Priority: The gas price is the price at the start of the top 10% of transactions’ gas prices from the last 5 blocks. - Medium Priority: The gas price is the mean of all gas prices from the last 5 blocks. - Low Priority: The gas price is the value at the end of the lowest 10% of gas prices from the last 5 blocks. - Unspecified Priority (default): This is equivalent to the Medium priority, using the mean of all gas prices from the last 5 blocks.
const ( // TX_PRIORITY_UNSPECIFIED none priority, the default priority level, which is equivalent to // the TX_PRIORITY_MEDIUM priority. TxPriority_TX_PRIORITY_UNSPECIFIED TxPriority = 0 // TX_PRIORITY_LOW low priority. TxPriority_TX_PRIORITY_LOW TxPriority = 1 // TX_PRIORITY_MEDIUM medium priority. TxPriority_TX_PRIORITY_MEDIUM TxPriority = 2 // TX_PRIORITY_HIGH high priority. TxPriority_TX_PRIORITY_HIGH TxPriority = 3 )
func (TxPriority) EnumDescriptor ¶
func (TxPriority) EnumDescriptor() ([]byte, []int)
func (TxPriority) String ¶
func (x TxPriority) String() string
type UnimplementedGasEstimatorServer ¶
type UnimplementedGasEstimatorServer struct { }
UnimplementedGasEstimatorServer can be embedded to have forward compatible implementations.
func (*UnimplementedGasEstimatorServer) EstimateGasPrice ¶
func (*UnimplementedGasEstimatorServer) EstimateGasPrice(ctx context.Context, req *EstimateGasPriceRequest) (*EstimateGasPriceResponse, error)
func (*UnimplementedGasEstimatorServer) EstimateGasPriceAndUsage ¶
func (*UnimplementedGasEstimatorServer) EstimateGasPriceAndUsage(ctx context.Context, req *EstimateGasPriceAndUsageRequest) (*EstimateGasPriceAndUsageResponse, error)