mirror of
https://github.com/QuilibriumNetwork/ceremonyclient.git
synced 2026-02-25 20:37:27 +08:00
さよなら
This commit is contained in:
parent
e836b00852
commit
75716be4fa
@ -121,7 +121,7 @@ type DataClockConsensusEngine struct {
|
||||
dependencyMapMx sync.Mutex
|
||||
stagedTransactions *protobufs.TokenRequests
|
||||
stagedTransactionsSet map[string]struct{}
|
||||
stagedTransactionsMx sync.Mutex
|
||||
stagedTransactionsMx sync.RWMutex
|
||||
peerMapMx sync.RWMutex
|
||||
peerAnnounceMapMx sync.Mutex
|
||||
lastKeyBundleAnnouncementFrame uint64
|
||||
@ -270,7 +270,8 @@ func NewDataClockConsensusEngine(
|
||||
rateLimit,
|
||||
time.Minute,
|
||||
),
|
||||
requestSyncCh: make(chan struct{}, 1),
|
||||
requestSyncCh: make(chan struct{}, 1),
|
||||
stagedTransactionsSet: map[string]struct{}{},
|
||||
}
|
||||
|
||||
logger.Info("constructing consensus engine")
|
||||
|
||||
@ -2,6 +2,7 @@ package data
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/binary"
|
||||
"fmt"
|
||||
"sync"
|
||||
"time"
|
||||
@ -381,6 +382,9 @@ func TokenRequestIdentifiers(transition *protobufs.TokenRequest) []string {
|
||||
case *protobufs.TokenRequest_Mint:
|
||||
if len(t.Mint.Proofs) == 1 {
|
||||
return []string{fmt.Sprintf("mint-proof-%x", sha3.Sum512(t.Mint.Proofs[0]))}
|
||||
} else if len(t.Mint.Proofs) >= 3 {
|
||||
frameNumber := binary.BigEndian.Uint64(t.Mint.Proofs[2])
|
||||
return []string{fmt.Sprintf("mint-sign-%d-%x", frameNumber, t.Mint.Signature.PublicKey.KeyValue)}
|
||||
}
|
||||
return []string{fmt.Sprintf("mint-sign-%x", t.Mint.Signature.PublicKey.KeyValue)}
|
||||
case *protobufs.TokenRequest_Announce:
|
||||
|
||||
@ -2,6 +2,7 @@ package data
|
||||
|
||||
import (
|
||||
"encoding/binary"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/libp2p/go-libp2p/core/peer"
|
||||
@ -61,11 +62,34 @@ func (e *DataClockConsensusEngine) validateTxMessage(peerID peer.ID, message *pb
|
||||
if len(mint.Proofs[2]) != 8 {
|
||||
return p2p.ValidationResultReject
|
||||
}
|
||||
if mint.Signature == nil ||
|
||||
mint.Signature.PublicKey == nil ||
|
||||
mint.Signature.PublicKey.KeyValue == nil {
|
||||
return p2p.ValidationResultReject
|
||||
}
|
||||
head, err := e.dataTimeReel.Head()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if frameNumber := binary.BigEndian.Uint64(mint.Proofs[2]); frameNumber+2 < head.FrameNumber {
|
||||
|
||||
// cheap hack for handling protobuf trickery: because protobufs can be
|
||||
// serialized in infinite ways, message ids can be regenerated simply by
|
||||
// modifying the data without affecting the underlying signed message.
|
||||
// if this is encountered, go scorched earth on the sender – a thank you
|
||||
// message for destabilizing the network.
|
||||
frameNumber := binary.BigEndian.Uint64(mint.Proofs[2])
|
||||
id := fmt.Sprintf(
|
||||
"mint-sign-%d-%x",
|
||||
frameNumber,
|
||||
mint.Signature.PublicKey.KeyValue,
|
||||
)
|
||||
e.stagedTransactionsMx.RLock()
|
||||
_, ok := e.stagedTransactionsSet[id]
|
||||
e.stagedTransactionsMx.RUnlock()
|
||||
if ok {
|
||||
return p2p.ValidationResultReject
|
||||
}
|
||||
if frameNumber+2 < head.FrameNumber {
|
||||
return p2p.ValidationResultIgnore
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user