Skip to content

Commit f73f73c

Browse files
authored
Merge pull request #6412 from oasisprotocol/peternose/trivial/refactor-code
go/worker/client/committee: Refactor code
2 parents fb61f5e + f142ceb commit f73f73c

12 files changed

Lines changed: 232 additions & 719 deletions

File tree

.changelog/6412.trivial.md

Whitespace-only changes.

go/runtime/api/info.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
consensus "github.com/oasisprotocol/oasis-core/go/consensus/api"
66
registry "github.com/oasisprotocol/oasis-core/go/registry/api"
77
"github.com/oasisprotocol/oasis-core/go/roothash/api/block"
8+
"github.com/oasisprotocol/oasis-core/go/roothash/api/message"
89
)
910

1011
// BlockInfo contains information related to the given runtime block.
@@ -15,6 +16,9 @@ type BlockInfo struct {
1516
// ConsensusBlock is the consensus light block the runtime block belongs to.
1617
ConsensusBlock *consensus.LightBlock
1718

19+
// IncomingMessages contains runtime's queued incoming messages.
20+
IncomingMessages []*message.IncomingMessage
21+
1822
// Epoch is the epoch the runtime block belongs to.
1923
Epoch beacon.EpochTime
2024

go/runtime/nodes/runtime.go

Lines changed: 0 additions & 226 deletions
This file was deleted.

go/runtime/nodes/runtime_test.go

Lines changed: 0 additions & 23 deletions
This file was deleted.

go/runtime/txpool/transaction.go

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,16 @@ import (
44
"github.com/oasisprotocol/oasis-core/go/runtime/host/protocol"
55
)
66

7-
// txCheckFlags are the flags describing how a transaction should be checked.
8-
type txCheckFlags uint8
9-
10-
const (
11-
// txCheckRecheck is a flag indicating that the transaction already passed checking earlier.
12-
txCheckRecheck = 1 << 0
13-
)
14-
15-
func (f txCheckFlags) isRecheck() bool {
16-
return (f * txCheckRecheck) != 0
17-
}
18-
197
// PendingCheckTransaction is a transaction pending checks.
208
type PendingCheckTransaction struct {
219
*TxQueueMeta
2210

23-
// flags are the transaction check flags.
24-
flags txCheckFlags
2511
// local indicates whether the transaction came from our own node.
2612
local bool
2713
// discard indicates whether the transaction should be discarded after validation.
2814
discard bool
15+
// checked indicates whether the transaction already passed check.
16+
checked bool
2917
// notifyCh is a channel for sending back the transaction check result.
3018
notifyCh chan *protocol.CheckTxResult
3119
}

go/runtime/txpool/txpool.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ func (t *txPool) addToCheckQueue(pct *PendingCheckTransaction) error {
263263
t.logger.Debug("queuing transaction for check",
264264
"tx", pct.Raw(),
265265
"hash", pct.Hash(),
266-
"recheck", pct.flags.isRecheck(),
266+
"recheck", pct.checked,
267267
)
268268
if err := t.checkTxQueue.add(pct); err != nil {
269269
t.logger.Warn("unable to queue transaction",
@@ -529,7 +529,7 @@ func (t *txPool) checkTxBatch(ctx context.Context) error {
529529
"tx", batch[i].Raw(),
530530
"hash", batch[i].Hash(),
531531
"result", res,
532-
"recheck", batch[i].flags.isRecheck(),
532+
"recheck", batch[i].checked,
533533
)
534534

535535
// Make sure a failed transaction is removed from the seen cache as the transaction may
@@ -548,7 +548,7 @@ func (t *txPool) checkTxBatch(ctx context.Context) error {
548548

549549
// For any transactions that are to be queued, we defer notification until queued.
550550

551-
if !batch[i].flags.isRecheck() {
551+
if !batch[i].checked {
552552
acceptedTransactions.With(t.getMetricLabels()).Inc()
553553
newTxs = append(newTxs, batch[i])
554554
}
@@ -605,7 +605,7 @@ func (t *txPool) checkTxBatch(ctx context.Context) error {
605605
// Notify submitter of success.
606606
notifySubmitter(idx)
607607

608-
if !pct.flags.isRecheck() {
608+
if !pct.checked {
609609
// Mark new transactions as never having been published. The republish worker will
610610
// publish these immediately.
611611
var publishTime time.Time
@@ -831,7 +831,7 @@ func (t *txPool) recheck() {
831831
notifyCh := make(chan *protocol.CheckTxResult, 1)
832832
pcts = append(pcts, &PendingCheckTransaction{
833833
TxQueueMeta: tx,
834-
flags: txCheckRecheck,
834+
checked: true,
835835
notifyCh: notifyCh,
836836
})
837837
results = append(results, notifyCh)

go/worker/client/committee/node.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,10 +172,9 @@ func (n *Node) Query(ctx context.Context, round uint64, method string, args []by
172172
// Fetch the active descriptor so we can get the current message limits.
173173
n.commonNode.CrossNode.Lock()
174174
dsc := n.commonNode.CurrentDescriptor
175-
blk := n.commonNode.CurrentBlock
176175
n.commonNode.CrossNode.Unlock()
177176

178-
if dsc == nil || blk == nil {
177+
if dsc == nil {
179178
return nil, api.ErrNoHostedRuntime
180179
}
181180
maxMessages := dsc.Executor.MaxMessages

0 commit comments

Comments
 (0)