Add is_enqueued_vaa query to governor (#1395)
This commit is contained in:
parent
f0b7225591
commit
126c9dcf57
|
@ -30,6 +30,11 @@
|
|||
// {"emitterChain":1, "emitterAddress":"c69a1b1a65dd336bf1df6a77afb501fc25db7fc0938cb08595a9ef473265cb4f", "sequence":"2"}
|
||||
// ]}
|
||||
//
|
||||
// Query: http://localhost:7071/v1/governor/is_vaa_enqueued/1/c69a1b1a65dd336bf1df6a77afb501fc25db7fc0938cb08595a9ef473265cb4f/3
|
||||
//
|
||||
// Returns:
|
||||
// {"isEnqueued":true}
|
||||
//
|
||||
// Query: http://localhost:7071/v1/governor/token_list
|
||||
//
|
||||
// Returns:
|
||||
|
@ -256,6 +261,29 @@ func (gov *ChainGovernor) GetEnqueuedVAAs() []*publicrpcv1.GovernorGetEnqueuedVA
|
|||
return resp
|
||||
}
|
||||
|
||||
// REST query to get the list of enqueued VAAs.
|
||||
func (gov *ChainGovernor) IsVAAEnqueued(msgId *publicrpcv1.MessageID) (bool, error) {
|
||||
gov.mutex.Lock()
|
||||
defer gov.mutex.Unlock()
|
||||
|
||||
emitterChain := vaa.ChainID(msgId.EmitterChain)
|
||||
|
||||
emitterAddress, err := vaa.StringToAddress(msgId.EmitterAddress)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
for _, ce := range gov.chains {
|
||||
for _, pe := range ce.pending {
|
||||
if pe.msg.EmitterChain == emitterChain && pe.msg.EmitterAddress == emitterAddress && pe.msg.Sequence == msgId.Sequence {
|
||||
return true, nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false, nil
|
||||
}
|
||||
|
||||
// REST query to get the list of tokens being monitored by the governor.
|
||||
func (gov *ChainGovernor) GetTokenList() []*publicrpcv1.GovernorGetTokenListResponse_Entry {
|
||||
gov.mutex.Lock()
|
||||
|
|
|
@ -142,6 +142,22 @@ func (s *PublicrpcServer) GovernorGetEnqueuedVAAs(ctx context.Context, req *publ
|
|||
return resp, nil
|
||||
}
|
||||
|
||||
func (s *PublicrpcServer) GovernorIsVAAEnqueued(ctx context.Context, req *publicrpcv1.GovernorIsVAAEnqueuedRequest) (*publicrpcv1.GovernorIsVAAEnqueuedResponse, error) {
|
||||
resp := &publicrpcv1.GovernorIsVAAEnqueuedResponse{}
|
||||
|
||||
if s.gov != nil {
|
||||
var err error
|
||||
resp.IsEnqueued, err = s.gov.IsVAAEnqueued(req.MessageId)
|
||||
if err != nil {
|
||||
return resp, err
|
||||
}
|
||||
} else {
|
||||
resp.IsEnqueued = false
|
||||
}
|
||||
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
func (s *PublicrpcServer) GovernorGetTokenList(ctx context.Context, req *publicrpcv1.GovernorGetTokenListRequest) (*publicrpcv1.GovernorGetTokenListResponse, error) {
|
||||
resp := &publicrpcv1.GovernorGetTokenListResponse{}
|
||||
|
||||
|
|
|
@ -85,6 +85,12 @@ service PublicRPCService {
|
|||
};
|
||||
}
|
||||
|
||||
rpc GovernorIsVAAEnqueued (GovernorIsVAAEnqueuedRequest) returns (GovernorIsVAAEnqueuedResponse) {
|
||||
option (google.api.http) = {
|
||||
get: "/v1/governor/is_vaa_enqueued/{message_id.emitter_chain}/{message_id.emitter_address}/{message_id.sequence}"
|
||||
};
|
||||
}
|
||||
|
||||
rpc GovernorGetTokenList (GovernorGetTokenListRequest) returns (GovernorGetTokenListResponse) {
|
||||
option (google.api.http) = {
|
||||
get: "/v1/governor/token_list"
|
||||
|
@ -166,6 +172,14 @@ message GovernorGetEnqueuedVAAsResponse {
|
|||
repeated Entry entries = 1;
|
||||
}
|
||||
|
||||
message GovernorIsVAAEnqueuedRequest {
|
||||
MessageID message_id = 1;
|
||||
}
|
||||
|
||||
message GovernorIsVAAEnqueuedResponse {
|
||||
bool is_enqueued = 1;
|
||||
}
|
||||
|
||||
message GovernorGetTokenListRequest {
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue