Documentation ¶
Index ¶
- Constants
- Variables
- func BuildProofFromBlocks(requestedHashes []*BlockStore) map[int64]interface{}
- func FindRequestedBlockHash(requestedHashes []*BlockStore, requestBlock, toBlock, fromBlock int64, ...) (requestedBlockHash []byte, finalizedBlockHashesMapRet map[int64]interface{})
- func LatestArgToBlockNum(request, latestBlock int64) int64
- func RegisterChainTrackerServiceServer(s grpc1.Server, 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
- func (ct *ChainTracker) AddBlockGap(newData time.Duration, blocks uint64)
- func (cs *ChainTracker) GetAtomicLatestBlockNum() int64
- func (cs *ChainTracker) GetLatestBlockData(fromBlock, toBlock, specificBlock int64) (latestBlock int64, requestedHashes []*BlockStore, changeTime time.Time, ...)
- func (cs *ChainTracker) GetLatestBlockNum() (int64, time.Time)
- func (cs *ChainTracker) RegisterForBlockTimeUpdates(updatable blockTimeUpdatable)
- type ChainTrackerConfig
- type ChainTrackerService
- type ChainTrackerServiceClient
- type ChainTrackerServiceServer
- type GetLatestBlockNumResponse
- func (*GetLatestBlockNumResponse) Descriptor() ([]byte, []int)
- func (m *GetLatestBlockNumResponse) GetBlock() uint64
- func (m *GetLatestBlockNumResponse) GetTimestamp() int64
- func (m *GetLatestBlockNumResponse) Marshal() (dAtA []byte, err error)
- func (m *GetLatestBlockNumResponse) MarshalTo(dAtA []byte) (int, error)
- func (m *GetLatestBlockNumResponse) MarshalToSizedBuffer(dAtA []byte) (int, error)
- func (*GetLatestBlockNumResponse) ProtoMessage()
- func (m *GetLatestBlockNumResponse) Reset()
- func (m *GetLatestBlockNumResponse) Size() (n int)
- func (m *GetLatestBlockNumResponse) String() string
- func (m *GetLatestBlockNumResponse) Unmarshal(dAtA []byte) error
- func (m *GetLatestBlockNumResponse) XXX_DiscardUnknown()
- func (m *GetLatestBlockNumResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *GetLatestBlockNumResponse) XXX_Merge(src proto.Message)
- func (m *GetLatestBlockNumResponse) XXX_Size() int
- func (m *GetLatestBlockNumResponse) XXX_Unmarshal(b []byte) error
- 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 WantedBlocksData
Constants ¶
const ( BACKOFF_MAX_TIME = 10 * time.Minute GoodStabilityThreshold = 0.3 PollingUpdateLength = 10 MostFrequentPollingMultiplier = 16 )
const ( DefualtAssumedBlockMemory = 20 DefaultBlockCheckpointDistance = 100 )
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") InvalidRequestedSpecificBlock = sdkerrors.New("Error InvalidRequestedSpecificBlock", 10709, "provided requested specific blocks for function do not compose a stored entry") )
Functions ¶
func BuildProofFromBlocks ¶
func BuildProofFromBlocks(requestedHashes []*BlockStore) map[int64]interface{}
func FindRequestedBlockHash ¶
func FindRequestedBlockHash(requestedHashes []*BlockStore, requestBlock, toBlock, fromBlock int64, finalizedBlockHashes map[int64]interface{}) (requestedBlockHash []byte, finalizedBlockHashesMapRet map[int64]interface{})
func LatestArgToBlockNum ¶
func RegisterChainTrackerServiceServer ¶
func RegisterChainTrackerServiceServer(s grpc1.Server, srv ChainTrackerServiceServer)
Types ¶
type BlockRange ¶
type BlockRange struct {
// contains filtered or unexported fields
}
func NewBlockRange ¶
func NewBlockRange(fromBlock, toBlock, earliestBlockSaved, latestBlock int64) (br *BlockRange, err error)
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 NewChainTracker ¶
func NewChainTracker(ctx context.Context, chainFetcher ChainFetcher, config ChainTrackerConfig) (chainTracker *ChainTracker, err error)
func (*ChainTracker) AddBlockGap ¶
func (ct *ChainTracker) AddBlockGap(newData time.Duration, blocks uint64)
func (*ChainTracker) GetAtomicLatestBlockNum ¶
func (cs *ChainTracker) GetAtomicLatestBlockNum() int64
func (*ChainTracker) GetLatestBlockData ¶
func (cs *ChainTracker) GetLatestBlockData(fromBlock, toBlock, specificBlock int64) (latestBlock int64, requestedHashes []*BlockStore, changeTime time.Time, err error)
this function returns block hashes of the blocks: [from block - to block] 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, time.Time)
func (*ChainTracker) RegisterForBlockTimeUpdates ¶
func (cs *ChainTracker) RegisterForBlockTimeUpdates(updatable blockTimeUpdatable)
type ChainTrackerConfig ¶
type ChainTrackerConfig struct { ForkCallback func(block int64) // a function to be called when a fork is detected NewLatestCallback func(block int64, hash string) // a function to be called when a new block is detected ConsistencyCallback func(oldBlock int64, block int64) 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 BlocksCheckpointDistance uint64 // this causes the chainTracker to trigger it's checkpoint every X blocks Pmetrics *metrics.ProviderMetricsManager }
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) (*GetLatestBlockNumResponse, error)
type ChainTrackerServiceClient ¶
type ChainTrackerServiceClient interface { GetLatestBlockNum(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*GetLatestBlockNumResponse, 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://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
func NewChainTrackerServiceClient ¶
func NewChainTrackerServiceClient(cc grpc1.ClientConn) ChainTrackerServiceClient
type ChainTrackerServiceServer ¶
type ChainTrackerServiceServer interface { GetLatestBlockNum(context.Context, *emptypb.Empty) (*GetLatestBlockNumResponse, error) GetLatestBlockData(context.Context, *LatestBlockData) (*LatestBlockDataResponse, error) }
ChainTrackerServiceServer is the server API for ChainTrackerService service.
type GetLatestBlockNumResponse ¶
type GetLatestBlockNumResponse struct { Block uint64 `protobuf:"varint,1,opt,name=block,proto3" json:"block,omitempty"` Timestamp int64 `protobuf:"varint,2,opt,name=timestamp,proto3" json:"timestamp,omitempty"` }
func (*GetLatestBlockNumResponse) Descriptor ¶
func (*GetLatestBlockNumResponse) Descriptor() ([]byte, []int)
func (*GetLatestBlockNumResponse) GetBlock ¶
func (m *GetLatestBlockNumResponse) GetBlock() uint64
func (*GetLatestBlockNumResponse) GetTimestamp ¶
func (m *GetLatestBlockNumResponse) GetTimestamp() int64
func (*GetLatestBlockNumResponse) Marshal ¶
func (m *GetLatestBlockNumResponse) Marshal() (dAtA []byte, err error)
func (*GetLatestBlockNumResponse) MarshalTo ¶
func (m *GetLatestBlockNumResponse) MarshalTo(dAtA []byte) (int, error)
func (*GetLatestBlockNumResponse) MarshalToSizedBuffer ¶
func (m *GetLatestBlockNumResponse) MarshalToSizedBuffer(dAtA []byte) (int, error)
func (*GetLatestBlockNumResponse) ProtoMessage ¶
func (*GetLatestBlockNumResponse) ProtoMessage()
func (*GetLatestBlockNumResponse) Reset ¶
func (m *GetLatestBlockNumResponse) Reset()
func (*GetLatestBlockNumResponse) Size ¶
func (m *GetLatestBlockNumResponse) Size() (n int)
func (*GetLatestBlockNumResponse) String ¶
func (m *GetLatestBlockNumResponse) String() string
func (*GetLatestBlockNumResponse) Unmarshal ¶
func (m *GetLatestBlockNumResponse) Unmarshal(dAtA []byte) error
func (*GetLatestBlockNumResponse) XXX_DiscardUnknown ¶
func (m *GetLatestBlockNumResponse) XXX_DiscardUnknown()
func (*GetLatestBlockNumResponse) XXX_Marshal ¶
func (m *GetLatestBlockNumResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*GetLatestBlockNumResponse) XXX_Merge ¶
func (m *GetLatestBlockNumResponse) XXX_Merge(src proto.Message)
func (*GetLatestBlockNumResponse) XXX_Size ¶
func (m *GetLatestBlockNumResponse) XXX_Size() int
func (*GetLatestBlockNumResponse) XXX_Unmarshal ¶
func (m *GetLatestBlockNumResponse) XXX_Unmarshal(b []byte) error
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 can be embedded to have forward compatible implementations.
func (*UnimplementedChainTrackerServiceServer) GetLatestBlockData ¶
func (*UnimplementedChainTrackerServiceServer) GetLatestBlockData(ctx context.Context, req *LatestBlockData) (*LatestBlockDataResponse, error)
func (*UnimplementedChainTrackerServiceServer) GetLatestBlockNum ¶
func (*UnimplementedChainTrackerServiceServer) GetLatestBlockNum(ctx context.Context, req *emptypb.Empty) (*GetLatestBlockNumResponse, error)
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) New ¶
func (wbd *WantedBlocksData) New(fromBlock, toBlock, specificBlock, latestBlock, earliestBlockSaved int64) (err error)
func (*WantedBlocksData) String ¶
func (wbd *WantedBlocksData) String() string