-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add placeholder EventBus methods (#3)
* Add methods to PrivValidator interface * Add placeholder methods to EventBus * Add methods to Store interface
- Loading branch information
1 parent
eb2a7af
commit 965284f
Showing
11 changed files
with
345 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// TODO: Generate | ||
|
||
// Event allows application developers to attach additional information to | ||
// ResponseBeginBlock, ResponseEndBlock, ResponseCheckTx and ResponseDeliverTx. | ||
// Later, transactions may be queried using these events. | ||
export class Event {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// TODO: Implement using libp2p pubsub | ||
|
||
// Query defines an interface for a query to be used for subscribing. A query | ||
// matches against a map of events. Each key in this map is a composite of the | ||
// even type and an attribute key (e.g. "{eventType}.{eventAttrKey}") and the | ||
// values are the event values that are contained under that relationship. This | ||
// allows event types to repeat themselves with the same set of keys and | ||
// different values. | ||
// TODO: Implement | ||
export interface Query {} | ||
|
||
// Server allows clients to subscribe/unsubscribe for messages, publishing | ||
// messages with or without events, and manages internal state. | ||
// TODO: Implement | ||
export class Server {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// TODO: Generate | ||
|
||
// ABCIResponses retains the responses | ||
// of the various ABCI calls during block processing. | ||
// It is persisted to disk for each height before calling Commit. | ||
export class ABCIResponses {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// TODO: Generate | ||
|
||
// Vote represents a prevote, precommit, or commit vote from validators for | ||
// consensus. | ||
export class Vote {} | ||
|
||
export class Proposal {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// ----------------------------------------------------------------------------- | ||
|
||
// State is a short description of the latest committed block of the consensus protocol. | ||
// It keeps all information necessary to validate new blocks, | ||
// including the last validator set and the consensus params. | ||
// All fields are exposed so the struct can be easily serialized, | ||
// but none of them should be mutated directly. | ||
// Instead, use state.Copy() or state.NextState(...). | ||
// NOTE: not goroutine-safe. | ||
// TODO: Implement | ||
export class State {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,51 @@ | ||
import { ABCIResponses } from '../proto/tendermint/state/types.pb'; | ||
import { GenesisDoc } from '../types/genesis'; | ||
import { ConsensusParams } from '../types/params'; | ||
import { ValidatorSet } from '../types/validator-set'; | ||
import { State } from './state'; | ||
|
||
// Store defines the state store interface | ||
// | ||
// It is used to retrieve current state and save and load ABCI responses, | ||
// validators and consensus parameters | ||
// TODO: Implement | ||
export interface Store {} | ||
export interface Store { | ||
// LoadFromDBOrGenesisFile loads the most recent state. | ||
// If the chain is new it will use the genesis file from the provided genesis file path as the current state. | ||
// TODO: Can throw an error | ||
loadFromDBOrGenesisFile(f: string): State | ||
// LoadFromDBOrGenesisDoc loads the most recent state. | ||
// If the chain is new it will use the genesis doc as the current state. | ||
// TODO: Can throw an error | ||
loadFromDBOrGenesisDoc(g: GenesisDoc): State | ||
// Load loads the current state of the blockchain | ||
// TODO: Can throw an error | ||
load(): State | ||
// LoadValidators loads the validator set at a given height | ||
// TODO: Can throw an error | ||
loadValidators(h: bigint): ValidatorSet | ||
// LoadABCIResponses loads the abciResponse for a given height | ||
// TODO: Can throw an error | ||
loadABCIResponses(h: bigint): ABCIResponses | ||
// LoadLastABCIResponse loads the last abciResponse for a given height | ||
// TODO: Can throw an error | ||
loadLastABCIResponse(h: bigint): ABCIResponses | ||
// LoadConsensusParams loads the consensus params for a given height | ||
// TODO: Can throw an error | ||
loadConsensusParams(h: bigint): ConsensusParams | ||
// Save overwrites the previous state with the updated one | ||
// TODO: Can throw an error | ||
save(s: State): void | ||
// SaveABCIResponses saves ABCIResponses for a given height | ||
// TODO: Can throw an error | ||
saveABCIResponses(h: bigint, r: ABCIResponses): void | ||
// Bootstrap is used for bootstrapping state when not starting from a initial height. | ||
// TODO: Can throw an error | ||
bootstrap(s: State): void | ||
// PruneStates takes the height from which to start prning and which height stop at | ||
// TODO: Can throw an error | ||
pruneStates(start: bigint, stop: bigint): void | ||
// Close closes the connection with the database | ||
// TODO: Can throw an error | ||
close(): void | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,183 @@ | ||
import { BaseService } from '../libs/service/service'; | ||
import { BaseService, BaseServiceParams } from '../libs/service/service'; | ||
import * as cmtpubsub from '../libs/pubsub/pubsub'; | ||
import { Logger } from '../libs/log/logger'; | ||
import { | ||
EventDataCompleteProposal, | ||
EventDataNewBlock, | ||
EventDataNewBlockHeader, | ||
EventDataNewEvidence, | ||
EventDataNewRound, | ||
EventDataRoundState, | ||
EventDataTx, | ||
EventDataValidatorSetUpdates, | ||
EventDataVote, | ||
TMEventData | ||
} from './events'; | ||
import * as types from '../abci/types/types.pb'; | ||
|
||
const defaultCapacity = 0; | ||
|
||
// TODO: Implement | ||
export interface EventBusSubscriber {} | ||
|
||
// TODO: Implement | ||
export interface Subscription {} | ||
|
||
interface EventBusParams extends BaseServiceParams { | ||
pubsub?: cmtpubsub.Server; | ||
} | ||
|
||
// EventBus is a common bus for all events going through the system. All calls | ||
// are proxied to underlying pubsub server. All events must be published using | ||
// EventBus to ensure correct data types. | ||
// TODO: Implement | ||
export class EventBus extends BaseService {} | ||
export class EventBus extends BaseService { | ||
pubsub?: cmtpubsub.Server; | ||
|
||
constructor (params: EventBusParams) { | ||
super(params); | ||
Object.assign(this, params); | ||
} | ||
|
||
// NewEventBus returns a new event bus. | ||
static newEventBus (): EventBus { | ||
return EventBus.newEventBusWithBufferCapacity(defaultCapacity); | ||
} | ||
|
||
// NewEventBusWithBufferCapacity returns a new event bus with the given buffer capacity. | ||
static newEventBusWithBufferCapacity (cap: number): EventBus { | ||
return {} as EventBus; | ||
} | ||
|
||
// TODO: Implement | ||
setLogger (l: Logger) {} | ||
|
||
// TODO: Implement | ||
// TODO: Can throw an error | ||
onStart (): void {} | ||
|
||
// TODO: Implement | ||
onStop (): void {} | ||
|
||
// TODO: Implement | ||
numClients (): number { | ||
return 0; | ||
} | ||
|
||
// TODO: Implement | ||
numClientSubscriptions (clientID: string): number { | ||
return 0; | ||
} | ||
|
||
// TODO: Implement | ||
// TODO: Can throw an error | ||
subscribe ( | ||
// TODO: Implement Context | ||
ctx: any, | ||
subscriber: string, | ||
query: cmtpubsub.Query, | ||
...outCapacity: number[] | ||
): Subscription { | ||
return {} as Subscription; | ||
} | ||
|
||
// This method can be used for a local consensus explorer and synchronous | ||
// testing. Do not use for for public facing / untrusted subscriptions! | ||
// TODO: Implement | ||
// TODO: Can throw an error | ||
subscribeUnbuffered ( | ||
ctx: any, | ||
subscriber: string, | ||
query: cmtpubsub.Query | ||
): Subscription { | ||
return {} as Subscription; | ||
} | ||
|
||
// TODO: Implement | ||
// TODO: Can throw an error | ||
unsubscribe (ctx: any, subscriber: string, query: cmtpubsub.Query): void {} | ||
|
||
// TODO: Implement | ||
// TODO: Can throw an error | ||
unsubscribeAll (ctx: any, subscriber: string): void {} | ||
|
||
// TODO: Implement | ||
// TODO: Can throw an error | ||
publish (eventType: string, eventData: TMEventData): void {} | ||
|
||
// validateAndStringifyEvents takes a slice of event objects and creates a | ||
// map of stringified events where each key is composed of the event | ||
// type and each of the event's attributes keys in the form of | ||
// "{event.Type}.{attribute.Key}" and the value is each attribute's value. | ||
// TODO: Implement | ||
private validateAndStringifyEvents (events: types.Event[], logger: Logger): Map<string, string[]> { | ||
return new Map(); | ||
} | ||
|
||
// TODO: Implement | ||
// TODO: Can throw an error | ||
publishEventNewBlock (data: EventDataNewBlock): void {} | ||
|
||
// TODO: Implement | ||
// TODO: Can throw an error | ||
publishEventNewBlockHeader (data: EventDataNewBlockHeader): void {} | ||
|
||
// TODO: Implement | ||
// TODO: Can throw an error | ||
PublishEventNewEvidence (evidence: EventDataNewEvidence): void {} | ||
|
||
// TODO: Implement | ||
// TODO: Can throw an error | ||
publishEventVote (data: EventDataVote): void {} | ||
|
||
// TODO: Implement | ||
// TODO: Can throw an error | ||
publishEventValidBlock (data: EventDataRoundState): void {} | ||
|
||
// PublishEventTx publishes tx event with events from Result. Note it will add | ||
// predefined keys (EventTypeKey, TxHashKey). Existing events with the same keys | ||
// will be overwritten. | ||
// TODO: Implement | ||
// TODO: Can throw an error | ||
publishEventTx (data: EventDataTx): void {} | ||
|
||
// TODO: Implement | ||
// TODO: Can throw an error | ||
publishEventNewRoundStep (data: EventDataRoundState): void {} | ||
|
||
// TODO: Implement | ||
// TODO: Can throw an error | ||
publishEventTimeoutPropose (data: EventDataRoundState): void {} | ||
|
||
// TODO: Implement | ||
// TODO: Can throw an error | ||
publishEventTimeoutWait (data: EventDataRoundState): void {} | ||
|
||
// TODO: Implement | ||
// TODO: Can throw an error | ||
publishEventNewRound (data: EventDataNewRound): void {} | ||
|
||
// TODO: Implement | ||
// TODO: Can throw an error | ||
publishEventCompleteProposal (data: EventDataCompleteProposal): void {} | ||
|
||
// TODO: Implement | ||
// TODO: Can throw an error | ||
publishEventPolka (data: EventDataRoundState): void {} | ||
|
||
// TODO: Implement | ||
// TODO: Can throw an error | ||
publishEventUnlock (data: EventDataRoundState): void {} | ||
|
||
// TODO: Implement | ||
// TODO: Can throw an error | ||
publishEventRelock (data: EventDataRoundState): void {} | ||
|
||
// TODO: Implement | ||
// TODO: Can throw an error | ||
publishEventLock (data: EventDataRoundState): void {} | ||
|
||
// TODO: Implement | ||
// TODO: Can throw an error | ||
publishEventValidatorSetUpdates (data: EventDataValidatorSetUpdates): void {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// TMEventData implements events.EventData. | ||
export interface TMEventData { | ||
// empty interface | ||
} | ||
|
||
// Most event messages are basic types (a block, a transaction) | ||
// but some (an input to a call tx or a receive) are more exotic | ||
|
||
// TODO: Implement | ||
export interface EventDataNewBlock {} | ||
|
||
// TODO: Implement | ||
export interface EventDataNewBlockHeader {} | ||
|
||
// TODO: Implement | ||
export interface EventDataNewEvidence {} | ||
|
||
// All txs fire EventDataTx | ||
// TODO: Implement | ||
export interface EventDataTx {} | ||
|
||
// NOTE: This goes into the replay WAL | ||
// TODO: Implement | ||
export interface EventDataRoundState {} | ||
|
||
// TODO: Implement | ||
export interface ValidatorInfo {} | ||
|
||
// TODO: Implement | ||
export interface EventDataNewRound {} | ||
|
||
// TODO: Implement | ||
export interface EventDataCompleteProposal {} | ||
|
||
// TODO: Implement | ||
export interface EventDataVote {} | ||
|
||
// TODO: Implement | ||
export type EventDataString = string | ||
|
||
// TODO: Implement | ||
export interface EventDataValidatorSetUpdates {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.