Skip to content

Commit

Permalink
revise (#255)
Browse files Browse the repository at this point in the history
Signed-off-by: ReyisaRuby <yisa@reddio.com>
  • Loading branch information
ReyisaRuby authored Dec 23, 2024
1 parent b9ff970 commit e446185
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 10 deletions.
2 changes: 0 additions & 2 deletions core/kernel/handle_input.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ func (k *Kernel) HandleTxn(signedWrCall *protocol.SignedWrCall) error {

func (k *Kernel) handleTxnLocally(stxn *SignedTxn) error {
metrics.KernelHandleTxnCounter.WithLabelValues().Inc()
k.mutex.Lock()
defer k.mutex.Unlock()
tri := k.Land.GetTripod(stxn.TripodName())
if tri != nil {
err := tri.PreTxnHandler.PreHandleTxn(stxn)
Expand Down
4 changes: 1 addition & 3 deletions core/kernel/kernel.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,17 @@ package kernel

import (
"github.com/sirupsen/logrus"

"github.com/yu-org/yu/common"
"github.com/yu-org/yu/config"
"github.com/yu-org/yu/core/env"
"github.com/yu-org/yu/core/tripod"
"github.com/yu-org/yu/core/tripod/dev"
"github.com/yu-org/yu/core/types"
"github.com/yu-org/yu/utils/ip"
"sync"
)

type Kernel struct {
mutex sync.Mutex

cfg *config.KernelConf

RunMode common.RunMode
Expand Down
2 changes: 1 addition & 1 deletion core/txpool/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ type ItxPool interface {
}

type IunpackedTxns interface {
Insert(input *SignedTxn)
Insert(input *SignedTxn) error
Deletes(txnHashes []Hash)
Exist(txnHash Hash) bool
Get(txnHash Hash) *SignedTxn
Expand Down
8 changes: 6 additions & 2 deletions core/txpool/ordered.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package txpool

import (
"fmt"
"sync"

"github.com/sirupsen/logrus"
Expand All @@ -25,14 +26,17 @@ func newOrderedTxns() *orderedTxns {
}
}

func (ot *orderedTxns) Insert(input *SignedTxn) {
func (ot *orderedTxns) Insert(input *SignedTxn) error {
//logrus.WithField("txpool", "ordered-txns").
// Tracef("Insert txn(%s) to Txpool, txn content: %v", input.TxnHash, input.Raw.WrCall)

ot.Lock()
defer ot.Unlock()
if _, ok := ot.idx[input.TxnHash]; ok {
return fmt.Errorf("insert txn %s duplicated", input.TxnHash.String())
}
ot.idx[input.TxnHash] = input
ot.txns = append(ot.txns, input)
return nil
}

func (ot *orderedTxns) SetOrder(order map[int]Hash) {
Expand Down
3 changes: 1 addition & 2 deletions core/txpool/txpool.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,7 @@ func (tp *TxPool) Insert(stxn *SignedTxn) error {
if tp.nodeType == LightNode {
return nil
}
tp.unpackedTxns.Insert(stxn)
return nil
return tp.unpackedTxns.Insert(stxn)
}

func (tp *TxPool) SetOrder(order map[int]Hash) {
Expand Down

0 comments on commit e446185

Please sign in to comment.