Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Actor ¶
type Actor interface { // Act is to act the callback function when received the e event with the instance of Actor. Act(e *Event, callback func(m interface{})) }
Actor represents a computation unit for actor pattern: https://www.brianstorti.com/the-actor-model/
type ActorContext ¶
type ActorContext struct {
// contains filtered or unexported fields
}
ActorContext is the context of the Actors.
func NewActorContext ¶
func NewActorContext() *ActorContext
NewActorContext makes a new instance of ActorContext.
func (ActorContext) ActorStarted ¶
func (ctx ActorContext) ActorStarted(a Actor) bool
ActorStarted checks whether the given Actor is started.
TODO(wangruichao@mtv.ac): need to consider concurrent safety.
func (ActorContext) Send ¶
func (ctx ActorContext) Send(a Actor, e *Event, callback func(m interface{}))
Send sends instruction to the given Actor.
func (ActorContext) SendAndWait ¶
func (ctx ActorContext) SendAndWait(a Actor, e *Event) interface{}
SendAndWait sends the given Event to the given Actor and wait until getting response.
func (ActorContext) StartActor ¶
func (ctx ActorContext) StartActor(a Actor)
StartActor starts the process of the given Actor.
type Event ¶
type Event struct { Topic EventTopic Extra interface{} }
Event has a topic and a kind of message that needs to be processed by actors.
func NewEvent ¶
func NewEvent(t EventTopic, e interface{}) *Event
NewEvent returns a new instance of Event.
type EventTopic ¶
type EventTopic int
EventTopic represents the subscription topic
const ( // EvtSyncStart is the flag of SyncStart Event. EvtSyncStart EventTopic = iota // EvtSyncComplete is the flag of SyncComplete Event. EvtSyncComplete // EvtSyncAbort is the flag of SyncAbort Event. EvtSyncAbort // EvtLedgerFallBehind is the flag of UpdateLedger Event. // It is triggered when the consensus module detects that the round is behind. EvtLedgerFallBehind // EvtTxPoolInitFinished is the flag of TxPoolInitFinished Event. EvtTxPoolInitFinished )
type EventType ¶
type EventType int
EventType represents types for an event, which is used for internal communication within the application.
const ( // RPCGetAllShardsInfo nonsharded request // args: [] // return: *btcjson.ShardsInfo RPCGetAllShardsInfo EventType = iota // RPCGetOutState sharded request (storage node only) // args: [*wire.Outpoint] // return: *wire.OutSrate RPCGetOutState // RPCGetBlockInfo sharded request // args: [startHeight int64] // return: []*wire.MsgBlock RPCGetBlockInfo // RPCGetSlimBlockInfo sharded request (storage node only) // args: [toShard shard.Index, height int64] // return: []*wire.SlimBlock RPCGetSlimBlockInfo // RPCGetBlockSliceInfo sharded request (storage node only) // args: [startHeight int64, optional<endHeight int64>] // return: []*wire.MsgBlock RPCGetBlockSliceInfo // RPCGetSlimBlockSliceInfo sharded request (storage node only) // args: [toShard shard.Index, startHeight int64, optional<endHeight int64>] // return: []*wire.SlimBlock RPCGetSlimBlockSliceInfo // RPCGetSCInfo sharded request, get smart contract info (storage node only) // args: [contractAddr multivacaddress.Address] // return: *wire.SmartContractInfo RPCGetSCInfo // RPCSendRawTx sharded request, send raw transaction (storage node only) // args [*wire.MsgTx] // return: nil RPCSendRawTx )
type PubSubManager ¶
type PubSubManager struct {
// contains filtered or unexported fields
}
PubSubManager represents a computation unit for pub-sub pattern: https://en.wikipedia.org/wiki/Publish–subscribe_pattern This is applied to internal in-shard broadcast communication.
func NewPubSubManager ¶
func NewPubSubManager() *PubSubManager
NewPubSubManager gives a new PubSubManager.
func (*PubSubManager) Pub ¶
func (pubSubMgr *PubSubManager) Pub(evt Event)
Pub publishes the given Event to the subscribers.
func (*PubSubManager) Sub ¶
func (pubSubMgr *PubSubManager) Sub(subscr Subscriber)
Sub subscribes the given EventTopic with the given Subscriber.
TODO (wangruichao@mtv.ac): need to consider concurrent safety.
type RPCReq ¶
type RPCReq struct { Event EventType TargetShard shard.Index Args []interface{} // contains filtered or unexported fields }
RPCReq indicates request from RPCServer to application business logic.
func NewNonShardedRPCReq ¶
NewNonShardedRPCReq creates a new RPCReq.
func NewShardedRPCReq ¶
NewShardedRPCReq creates a new RPCReq which targets for a particular shard.
type RPCResp ¶
type RPCResp struct { Status RPCStatus Result interface{} }
RPCResp indicates a response from application business logic for the relevant RPCReq
func NewFailedRPCResp ¶
func NewFailedRPCResp() *RPCResp
NewFailedRPCResp creates a new RPCResp with status RPCFail
func NewSuccessRPCResp ¶
func NewSuccessRPCResp(r interface{}) *RPCResp
NewSuccessRPCResp creates a new RPCResp with status RPCOk
type RPCStatus ¶
type RPCStatus int
RPCStatus indicates if a RPCReq to business logic succeeds or not.
type Subscriber ¶
type Subscriber interface {
Recv(evt Event)
}
Subscriber is a interface that contains a method for receiving Event.