Documentation ¶
Index ¶
- Constants
- Variables
- func LatestArgToBlockNum(request int64, latestBlock int64) int64
- func RegisterChainTrackerServiceServer(s grpc.ServiceRegistrar, srv ChainTrackerServiceServer)
- type BlockRange
- type BlockStore
- func (*BlockStore) Descriptor() ([]byte, []int)
- func (m *BlockStore) GetBlock() int64
- func (m *BlockStore) GetHash() string
- func (m *BlockStore) Marshal() (dAtA []byte, err error)
- func (m *BlockStore) MarshalTo(dAtA []byte) (int, error)
- func (m *BlockStore) MarshalToSizedBuffer(dAtA []byte) (int, error)
- func (*BlockStore) ProtoMessage()
- func (m *BlockStore) Reset()
- func (m *BlockStore) Size() (n int)
- func (m *BlockStore) String() string
- func (m *BlockStore) Unmarshal(dAtA []byte) error
- func (m *BlockStore) XXX_DiscardUnknown()
- func (m *BlockStore) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *BlockStore) XXX_Merge(src proto.Message)
- func (m *BlockStore) XXX_Size() int
- func (m *BlockStore) XXX_Unmarshal(b []byte) error
- type ChainFetcher
- type ChainTracker
- type ChainTrackerConfig
- type ChainTrackerService
- type ChainTrackerServiceClient
- type ChainTrackerServiceServer
- type LatestBlockData
- func (*LatestBlockData) Descriptor() ([]byte, []int)
- func (m *LatestBlockData) GetFromBlock() int64
- func (m *LatestBlockData) GetSpecificBlock() int64
- func (m *LatestBlockData) GetToBlock() int64
- func (m *LatestBlockData) Marshal() (dAtA []byte, err error)
- func (m *LatestBlockData) MarshalTo(dAtA []byte) (int, error)
- func (m *LatestBlockData) MarshalToSizedBuffer(dAtA []byte) (int, error)
- func (*LatestBlockData) ProtoMessage()
- func (m *LatestBlockData) Reset()
- func (m *LatestBlockData) Size() (n int)
- func (m *LatestBlockData) String() string
- func (m *LatestBlockData) Unmarshal(dAtA []byte) error
- func (m *LatestBlockData) XXX_DiscardUnknown()
- func (m *LatestBlockData) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *LatestBlockData) XXX_Merge(src proto.Message)
- func (m *LatestBlockData) XXX_Size() int
- func (m *LatestBlockData) XXX_Unmarshal(b []byte) error
- type LatestBlockDataResponse
- func (*LatestBlockDataResponse) Descriptor() ([]byte, []int)
- func (m *LatestBlockDataResponse) GetLatestBlock() int64
- func (m *LatestBlockDataResponse) GetRequestedHashes() []*BlockStore
- func (m *LatestBlockDataResponse) Marshal() (dAtA []byte, err error)
- func (m *LatestBlockDataResponse) MarshalTo(dAtA []byte) (int, error)
- func (m *LatestBlockDataResponse) MarshalToSizedBuffer(dAtA []byte) (int, error)
- func (*LatestBlockDataResponse) ProtoMessage()
- func (m *LatestBlockDataResponse) Reset()
- func (m *LatestBlockDataResponse) Size() (n int)
- func (m *LatestBlockDataResponse) String() string
- func (m *LatestBlockDataResponse) Unmarshal(dAtA []byte) error
- func (m *LatestBlockDataResponse) XXX_DiscardUnknown()
- func (m *LatestBlockDataResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *LatestBlockDataResponse) XXX_Merge(src proto.Message)
- func (m *LatestBlockDataResponse) XXX_Size() int
- func (m *LatestBlockDataResponse) XXX_Unmarshal(b []byte) error
- type UnimplementedChainTrackerServiceServer
- type UnsafeChainTrackerServiceServer
- type WantedBlocksData
Constants ¶
const (
DefualtAssumedBlockMemory = 20
)
Variables ¶
var ( ErrInvalidLengthChainTracker = fmt.Errorf("proto: negative length found during unmarshaling") ErrIntOverflowChainTracker = fmt.Errorf("proto: integer overflow") ErrUnexpectedEndOfGroupChainTracker = fmt.Errorf("proto: unexpected end of group") )
var ( InvalidConfigErrorBlocksToSave = sdkerrors.New("Invalid blocks to save", 10701, "blocks to save wasn't defined in config") InvalidConfigBlockTime = sdkerrors.New("Invalid average block time", 10702, "average block time wasn't defined in config") InvalidLatestBlockNumValue = sdkerrors.New("Invalid value for latestBlockNum", 10703, "returned latest block num should be greater than 0, but it's not") InvalidReturnedHashes = sdkerrors.New("Invalid value for requestedHashes length", 10704, "returned requestedHashes key count should be greater than 0, but it's not") ErrorFailedToFetchLatestBlock = sdkerrors.New("Error FailedToFetchLatestBlock", 10705, "Failed to fetch latest block from node") InvalidRequestedBlocks = sdkerrors.New("Error InvalidRequestedBlocks", 10706, "provided requested blocks for function do not compse a valid request") RequestedBlocksOutOfRange = sdkerrors.New("RequestedBlocksOutOfRange", 10707, "requested blocks are outside the supported range by the state tracker") ErrorFailedToFetchTooEarlyBlock = sdkerrors.New("Error ErrorFailedToFetchTooEarlyBlock", 10708, "server memory protection triggered, requested block is too early") )
var ChainTrackerService_ServiceDesc = grpc.ServiceDesc{ ServiceName: "chainTracker.ChainTrackerService", HandlerType: (*ChainTrackerServiceServer)(nil), Methods: []grpc.MethodDesc{ { MethodName: "GetLatestBlockNum", Handler: _ChainTrackerService_GetLatestBlockNum_Handler, }, { MethodName: "GetLatestBlockData", Handler: _ChainTrackerService_GetLatestBlockData_Handler, }, }, Streams: []grpc.StreamDesc{}, Metadata: "chainTracker.proto", }
ChainTrackerService_ServiceDesc is the grpc.ServiceDesc for ChainTrackerService service. It's only intended for direct use with grpc.RegisterService, and not to be introspected or modified (even as a copy)
Functions ¶
func LatestArgToBlockNum ¶
func RegisterChainTrackerServiceServer ¶
func RegisterChainTrackerServiceServer(s grpc.ServiceRegistrar, srv ChainTrackerServiceServer)
Types ¶
type BlockRange ¶
type BlockRange struct {
// contains filtered or unexported fields
}
func NewBlockRange ¶
func (*BlockRange) IsWanted ¶
func (br *BlockRange) IsWanted(blockNum int64) bool
func (*BlockRange) IterationIndexes ¶
func (br *BlockRange) IterationIndexes() []int
type BlockStore ¶
type BlockStore struct { Block int64 `protobuf:"varint,1,opt,name=block,proto3" json:"block,omitempty"` Hash string `protobuf:"bytes,2,opt,name=hash,proto3" json:"hash,omitempty"` }
func (*BlockStore) Descriptor ¶
func (*BlockStore) Descriptor() ([]byte, []int)
func (*BlockStore) GetBlock ¶
func (m *BlockStore) GetBlock() int64
func (*BlockStore) GetHash ¶
func (m *BlockStore) GetHash() string
func (*BlockStore) Marshal ¶
func (m *BlockStore) Marshal() (dAtA []byte, err error)
func (*BlockStore) MarshalToSizedBuffer ¶
func (m *BlockStore) MarshalToSizedBuffer(dAtA []byte) (int, error)
func (*BlockStore) ProtoMessage ¶
func (*BlockStore) ProtoMessage()
func (*BlockStore) Reset ¶
func (m *BlockStore) Reset()
func (*BlockStore) Size ¶
func (m *BlockStore) Size() (n int)
func (*BlockStore) String ¶
func (m *BlockStore) String() string
func (*BlockStore) Unmarshal ¶
func (m *BlockStore) Unmarshal(dAtA []byte) error
func (*BlockStore) XXX_DiscardUnknown ¶
func (m *BlockStore) XXX_DiscardUnknown()
func (*BlockStore) XXX_Marshal ¶
func (m *BlockStore) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*BlockStore) XXX_Merge ¶
func (m *BlockStore) XXX_Merge(src proto.Message)
func (*BlockStore) XXX_Size ¶
func (m *BlockStore) XXX_Size() int
func (*BlockStore) XXX_Unmarshal ¶
func (m *BlockStore) XXX_Unmarshal(b []byte) error
type ChainFetcher ¶
type ChainTracker ¶
type ChainTracker struct {
// contains filtered or unexported fields
}
func New ¶ added in v0.4.5
func New(ctx context.Context, chainFetcher ChainFetcher, config ChainTrackerConfig) (chainTracker *ChainTracker, err error)
func (*ChainTracker) GetLatestBlockData ¶
func (cs *ChainTracker) GetLatestBlockData(fromBlock int64, toBlock int64, specificBlock int64) (latestBlock int64, requestedHashes []*BlockStore, err error)
this function returns block hashes of the blocks: [from block - to block) non inclusive. an additional specific block hash can be provided. order is sorted ascending it supports requests for [spectypes.LATEST_BLOCK-distance1, spectypes.LATEST_BLOCK-distance2) spectypes.NOT_APPLICABLE in fromBlock or toBlock results in only returning specific block. if specific block is spectypes.NOT_APPLICABLE it is ignored
func (*ChainTracker) GetLatestBlockNum ¶
func (cs *ChainTracker) GetLatestBlockNum() int64
type ChainTrackerConfig ¶
type ChainTrackerConfig struct { ForkCallback func(int64) // a function to be called when a fork is detected NewLatestCallback func(int64) // a function to be called when a new block is detected ServerAddress string // if not empty will open up a grpc server for that address BlocksToSave uint64 AverageBlockTime time.Duration // how often to query latest block ServerBlockMemory uint64 }
type ChainTrackerService ¶
type ChainTrackerService struct { UnimplementedChainTrackerServiceServer ChainTracker *ChainTracker }
func (*ChainTrackerService) GetLatestBlockData ¶
func (cts *ChainTrackerService) GetLatestBlockData(ctx context.Context, latestBlockData *LatestBlockData) (*LatestBlockDataResponse, error)
func (*ChainTrackerService) GetLatestBlockNum ¶
func (cts *ChainTrackerService) GetLatestBlockNum(context.Context, *empty.Empty) (*wrappers.UInt64Value, error)
type ChainTrackerServiceClient ¶
type ChainTrackerServiceClient interface { GetLatestBlockNum(ctx context.Context, in *empty.Empty, opts ...grpc.CallOption) (*wrappers.UInt64Value, error) GetLatestBlockData(ctx context.Context, in *LatestBlockData, opts ...grpc.CallOption) (*LatestBlockDataResponse, error) }
ChainTrackerServiceClient is the client API for ChainTrackerService service.
For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
func NewChainTrackerServiceClient ¶
func NewChainTrackerServiceClient(cc grpc.ClientConnInterface) ChainTrackerServiceClient
type ChainTrackerServiceServer ¶
type ChainTrackerServiceServer interface { GetLatestBlockNum(context.Context, *empty.Empty) (*wrappers.UInt64Value, error) GetLatestBlockData(context.Context, *LatestBlockData) (*LatestBlockDataResponse, error) // contains filtered or unexported methods }
ChainTrackerServiceServer is the server API for ChainTrackerService service. All implementations must embed UnimplementedChainTrackerServiceServer for forward compatibility
type LatestBlockData ¶
type LatestBlockData struct { FromBlock int64 `protobuf:"varint,1,opt,name=fromBlock,proto3" json:"fromBlock,omitempty"` ToBlock int64 `protobuf:"varint,2,opt,name=toBlock,proto3" json:"toBlock,omitempty"` SpecificBlock int64 `protobuf:"varint,3,opt,name=specificBlock,proto3" json:"specificBlock,omitempty"` }
func (*LatestBlockData) Descriptor ¶
func (*LatestBlockData) Descriptor() ([]byte, []int)
func (*LatestBlockData) GetFromBlock ¶
func (m *LatestBlockData) GetFromBlock() int64
func (*LatestBlockData) GetSpecificBlock ¶
func (m *LatestBlockData) GetSpecificBlock() int64
func (*LatestBlockData) GetToBlock ¶
func (m *LatestBlockData) GetToBlock() int64
func (*LatestBlockData) Marshal ¶
func (m *LatestBlockData) Marshal() (dAtA []byte, err error)
func (*LatestBlockData) MarshalToSizedBuffer ¶
func (m *LatestBlockData) MarshalToSizedBuffer(dAtA []byte) (int, error)
func (*LatestBlockData) ProtoMessage ¶
func (*LatestBlockData) ProtoMessage()
func (*LatestBlockData) Reset ¶
func (m *LatestBlockData) Reset()
func (*LatestBlockData) Size ¶
func (m *LatestBlockData) Size() (n int)
func (*LatestBlockData) String ¶
func (m *LatestBlockData) String() string
func (*LatestBlockData) Unmarshal ¶
func (m *LatestBlockData) Unmarshal(dAtA []byte) error
func (*LatestBlockData) XXX_DiscardUnknown ¶
func (m *LatestBlockData) XXX_DiscardUnknown()
func (*LatestBlockData) XXX_Marshal ¶
func (m *LatestBlockData) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*LatestBlockData) XXX_Merge ¶
func (m *LatestBlockData) XXX_Merge(src proto.Message)
func (*LatestBlockData) XXX_Size ¶
func (m *LatestBlockData) XXX_Size() int
func (*LatestBlockData) XXX_Unmarshal ¶
func (m *LatestBlockData) XXX_Unmarshal(b []byte) error
type LatestBlockDataResponse ¶
type LatestBlockDataResponse struct { LatestBlock int64 `protobuf:"varint,1,opt,name=latestBlock,proto3" json:"latestBlock,omitempty"` RequestedHashes []*BlockStore `protobuf:"bytes,2,rep,name=requestedHashes,proto3" json:"requestedHashes,omitempty"` }
func (*LatestBlockDataResponse) Descriptor ¶
func (*LatestBlockDataResponse) Descriptor() ([]byte, []int)
func (*LatestBlockDataResponse) GetLatestBlock ¶
func (m *LatestBlockDataResponse) GetLatestBlock() int64
func (*LatestBlockDataResponse) GetRequestedHashes ¶
func (m *LatestBlockDataResponse) GetRequestedHashes() []*BlockStore
func (*LatestBlockDataResponse) Marshal ¶
func (m *LatestBlockDataResponse) Marshal() (dAtA []byte, err error)
func (*LatestBlockDataResponse) MarshalTo ¶
func (m *LatestBlockDataResponse) MarshalTo(dAtA []byte) (int, error)
func (*LatestBlockDataResponse) MarshalToSizedBuffer ¶
func (m *LatestBlockDataResponse) MarshalToSizedBuffer(dAtA []byte) (int, error)
func (*LatestBlockDataResponse) ProtoMessage ¶
func (*LatestBlockDataResponse) ProtoMessage()
func (*LatestBlockDataResponse) Reset ¶
func (m *LatestBlockDataResponse) Reset()
func (*LatestBlockDataResponse) Size ¶
func (m *LatestBlockDataResponse) Size() (n int)
func (*LatestBlockDataResponse) String ¶
func (m *LatestBlockDataResponse) String() string
func (*LatestBlockDataResponse) Unmarshal ¶
func (m *LatestBlockDataResponse) Unmarshal(dAtA []byte) error
func (*LatestBlockDataResponse) XXX_DiscardUnknown ¶
func (m *LatestBlockDataResponse) XXX_DiscardUnknown()
func (*LatestBlockDataResponse) XXX_Marshal ¶
func (m *LatestBlockDataResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*LatestBlockDataResponse) XXX_Merge ¶
func (m *LatestBlockDataResponse) XXX_Merge(src proto.Message)
func (*LatestBlockDataResponse) XXX_Size ¶
func (m *LatestBlockDataResponse) XXX_Size() int
func (*LatestBlockDataResponse) XXX_Unmarshal ¶
func (m *LatestBlockDataResponse) XXX_Unmarshal(b []byte) error
type UnimplementedChainTrackerServiceServer ¶
type UnimplementedChainTrackerServiceServer struct { }
UnimplementedChainTrackerServiceServer must be embedded to have forward compatible implementations.
func (UnimplementedChainTrackerServiceServer) GetLatestBlockData ¶
func (UnimplementedChainTrackerServiceServer) GetLatestBlockData(context.Context, *LatestBlockData) (*LatestBlockDataResponse, error)
func (UnimplementedChainTrackerServiceServer) GetLatestBlockNum ¶
func (UnimplementedChainTrackerServiceServer) GetLatestBlockNum(context.Context, *empty.Empty) (*wrappers.UInt64Value, error)
type UnsafeChainTrackerServiceServer ¶ added in v0.4.5
type UnsafeChainTrackerServiceServer interface {
// contains filtered or unexported methods
}
UnsafeChainTrackerServiceServer may be embedded to opt out of forward compatibility for this service. Use of this interface is not recommended, as added methods to ChainTrackerServiceServer will result in compilation errors.
type WantedBlocksData ¶
type WantedBlocksData struct {
// contains filtered or unexported fields
}
func (*WantedBlocksData) IsWanted ¶
func (wbd *WantedBlocksData) IsWanted(blockNum int64) bool
func (*WantedBlocksData) IterationIndexes ¶
func (wbd *WantedBlocksData) IterationIndexes() (returnedIdxs []int)
func (*WantedBlocksData) String ¶
func (wbd *WantedBlocksData) String() string