Fix some consensus code which was broken by refactoring

This commit is contained in:
ChronosX88 2021-04-16 00:01:27 +03:00
parent 9fcd925dcb
commit 1b5f9a0d30
Signed by: ChronosXYZ
GPG Key ID: 085A69A82C8C511A
5 changed files with 25 additions and 18 deletions

View File

@ -169,7 +169,7 @@ func (pcm *PBFTConsensusManager) handleCommit(message *types.Message) {
return
}
err = pcm.ethereumClient.SubmitRequestAnswer(reqID, callbackAddress, request.RequestParams, request.Deadline, consensusMsg.Task.Payload)
err = pcm.ethereumClient.SubmitRequestAnswer(reqID, callbackAddress, request.CallbackMethodID, request.RequestParams, request.Deadline, consensusMsg.Task.Payload)
if err != nil {
logrus.Errorf("Failed to submit on-chain result: %v", err)
}
@ -180,12 +180,14 @@ func (pcm *PBFTConsensusManager) handleCommit(message *types.Message) {
}
func (pcm *PBFTConsensusManager) createConsensusInfo(task *types2.DioneTask, isLeader bool) {
if _, ok := pcm.consensusMap[task.ConsensusID]; !ok {
pcm.consensusMap[task.ConsensusID] = &Consensus{
IsCurrentMinerLeader: isLeader,
Task: task,
Finished: false,
}
}
}
func (pcm *PBFTConsensusManager) GetConsensusInfo(consensusID string) *Consensus {
c, ok := pcm.consensusMap[consensusID]

View File

@ -137,6 +137,10 @@ func (m *Miner) MineTask(ctx context.Context, event *dioneOracle.DioneOracleNewO
OriginChain: event.OriginChain,
RequestType: event.RequestType,
RequestParams: event.RequestParams,
RequestID: event.ReqID.String(),
ConsensusID: event.ReqID.String(),
CallbackAddress: event.CallbackAddress.Bytes(),
CallbackMethodID: event.CallbackMethodID[:],
Miner: m.address,
MinerEth: m.ethAddress.Hex(),
Ticket: ticket,

View File

@ -10,7 +10,7 @@ import (
)
func verifyTaskSignature(msg types.ConsensusMessage) error {
cHash, err := hashstructure.Hash(msg, hashstructure.FormatV2, nil)
cHash, err := hashstructure.Hash(msg.Task, hashstructure.FormatV2, nil)
if err != nil {
return err
}

View File

@ -184,8 +184,8 @@ func (c *EthereumClient) SubscribeOnOracleEvents(ctx context.Context) (chan *dio
return resChan, subscription, err
}
func (c *EthereumClient) SubmitRequestAnswer(reqID *big.Int, callbackAddress common.Address, requestParams string, requestDeadline *big.Int, data []byte) error {
_, err := c.dioneOracle.SubmitOracleRequest(requestParams, callbackAddress, [4]byte{}, reqID, requestDeadline, data)
func (c *EthereumClient) SubmitRequestAnswer(reqID *big.Int, callbackAddress common.Address, callbackMethodID [4]byte, requestParams string, requestDeadline *big.Int, data []byte) error {
_, err := c.dioneOracle.SubmitOracleRequest(requestParams, callbackAddress, callbackMethodID, reqID, requestDeadline, data)
if err != nil {
return err
}

View File

@ -307,6 +307,7 @@ func (n *Node) setupRPCClients() error {
fc := filecoin.NewLotusClient()
rpc.RegisterRPC(rtypes.RPCTypeFilecoin, map[string]func(string) ([]byte, error){
"getTransaction": fc.GetTransaction,
"getBlock": fc.GetBlock,
})
sl := solana2.NewSolanaClient()