This repository has been archived by the owner on Nov 16, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2569 from bandprotocol/yoda-multi-report
yoda: Queued and combine report msgs to one transaction + Gas estimation on multi-report transaction
- Loading branch information
Showing
8 changed files
with
219 additions
and
72 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
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 |
---|---|---|
@@ -1,24 +1,42 @@ | ||
package yoda | ||
|
||
import ( | ||
"sync/atomic" | ||
"time" | ||
|
||
"github.com/cosmos/cosmos-sdk/crypto/keys" | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
rpcclient "github.com/tendermint/tendermint/rpc/client" | ||
|
||
"github.com/bandprotocol/bandchain/chain/pkg/filecache" | ||
"github.com/bandprotocol/bandchain/chain/x/oracle/types" | ||
"github.com/bandprotocol/bandchain/chain/yoda/executor" | ||
) | ||
|
||
type ReportMsgWithKey struct { | ||
msg types.MsgReportData | ||
execVersion []string | ||
keyIndex int64 | ||
} | ||
|
||
type Context struct { | ||
client rpcclient.Client | ||
validator sdk.ValAddress | ||
gasPrices sdk.DecCoins | ||
keys chan keys.Info | ||
keys []keys.Info | ||
executor executor.Executor | ||
fileCache filecache.Cache | ||
broadcastTimeout time.Duration | ||
maxTry uint64 | ||
rpcPollInterval time.Duration | ||
maxReport uint64 | ||
|
||
pendingMsgs chan ReportMsgWithKey | ||
freeKeys chan int64 | ||
keyRoundRobinIndex int64 // Must use in conjunction with sync/atomic | ||
} | ||
|
||
func (c *Context) nextKeyIndex() int64 { | ||
keyIndex := atomic.AddInt64(&c.keyRoundRobinIndex, 1) % int64(len(c.keys)) | ||
return keyIndex | ||
} |
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
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
Oops, something went wrong.