Skip to content

Commit

Permalink
add documentation for consensus_topic_info_query
Browse files Browse the repository at this point in the history
  • Loading branch information
QuestofIranon committed Feb 20, 2020
1 parent bf6cf13 commit a5f06c1
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions consensus_topic_info_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@ type ConsensusTopicInfo struct {
RunningHash []byte
SequenceNumber uint64
ExpirationTime time.Time
AdminKey *Ed25519PublicKey
AdminKey *Ed25519PublicKey
SubmitKey *Ed25519PublicKey
AutoRenewPeriod time.Duration
AutoRenewAccountID *AccountID
}

// NewConsensusTopicInfoQuery creates a ConsensusTopicInfoQuery builder which can be used to construct and execute a
// Consensus Get Topic Info Query.
func NewConsensusTopicInfoQuery() *ConsensusTopicInfoQuery {
pb := &proto.ConsensusGetTopicInfoQuery{Header: &proto.QueryHeader{}}

Expand All @@ -30,11 +32,13 @@ func NewConsensusTopicInfoQuery() *ConsensusTopicInfoQuery {
return &ConsensusTopicInfoQuery{inner, pb}
}

// SetTopicId sets the topic to retrieve info about (the parameters and running state of).
func (builder *ConsensusTopicInfoQuery) SetTopicID(id ConsensusTopicID) *ConsensusTopicInfoQuery {
builder.pb.TopicID = id.toProto()
return builder
}

// Execute executes the ConsensusTopicInfoQuery using the provided client
func (builder *ConsensusTopicInfoQuery) Execute(client *Client) (ConsensusTopicInfo, error) {
resp, err := builder.execute(client)
if err != nil {
Expand All @@ -44,11 +48,11 @@ func (builder *ConsensusTopicInfoQuery) Execute(client *Client) (ConsensusTopicI
ti := resp.GetConsensusGetTopicInfo().TopicInfo

consensusTopicInfo := ConsensusTopicInfo{
Memo: ti.GetMemo(),
RunningHash: ti.RunningHash,
SequenceNumber: ti.SequenceNumber,
ExpirationTime: timeFromProto(ti.ExpirationTime),
AutoRenewPeriod: durationFromProto(ti.AutoRenewPeriod),
Memo: ti.GetMemo(),
RunningHash: ti.RunningHash,
SequenceNumber: ti.SequenceNumber,
ExpirationTime: timeFromProto(ti.ExpirationTime),
AutoRenewPeriod: durationFromProto(ti.AutoRenewPeriod),
}

if adminKey := ti.AdminKey; adminKey != nil {
Expand All @@ -69,7 +73,6 @@ func (builder *ConsensusTopicInfoQuery) Execute(client *Client) (ConsensusTopicI
consensusTopicInfo.AutoRenewAccountID = &ID
}


return consensusTopicInfo, nil
}

Expand Down

0 comments on commit a5f06c1

Please sign in to comment.