Commit 3139fa6c authored by Richer Maximilien's avatar Richer Maximilien Committed by Loïck Bonniot

[c] Fix some signature issues

- Fix missing sequence initialization
- Fix missing answer in grpc handlers
- Fix hashToID key issue
- Do all rounds of promises
parent ffe662f0
......@@ -36,7 +36,7 @@ func (m *SignatureManager) Sign() error {
// Promess rounds
// Follow the sequence until there is no next occurence of me
for nextIndex > 0 {
for m.currentIndex >= 0 {
dAPI.DLog("Starting round at index [" + fmt.Sprintf("%d", m.currentIndex) + "]")
log.Println("Starting round at index [" + fmt.Sprintf("%d", m.currentIndex) + "]")
......@@ -105,7 +105,7 @@ func (m *SignatureManager) promiseRound(pendingSet, sendSet []uint32, myID uint3
// TODO this ctx needs a timeout !
for len(pendingSet) > 0 {
promise := <-incomingPromises
senderID, exist := hashToID[string(promise.SenderKeyHash)]
senderID, exist := hashToID[fmt.Sprintf("%x", promise.SenderKeyHash)]
if exist {
var err error
pendingSet, err = common.Remove(pendingSet, senderID)
......
......@@ -5,6 +5,7 @@ import (
cAPI "dfss/dfssc/api"
pAPI "dfss/dfssp/api"
"dfss/net"
"fmt"
"golang.org/x/net/context"
"google.golang.org/grpc"
)
......@@ -18,16 +19,25 @@ func (s *clientServer) TreatPromise(ctx context.Context, in *cAPI.Promise) (*pAP
// Pass the message to Sign()
if incomingPromises != nil {
incomingPromises <- in
// Maybe we can add another channel here for better error management
return &pAPI.ErrorCode{Code: pAPI.ErrorCode_SUCCESS}, nil
}
return nil, nil
return &pAPI.ErrorCode{Code: pAPI.ErrorCode_INVARG}, fmt.Errorf("Cannot pass incoming promise")
}
// TreatSignature handler
//
// Handle incoming TreatSignature messages
func (s *clientServer) TreatSignature(ctx context.Context, in *cAPI.Signature) (*pAPI.ErrorCode, error) {
// TODO
if incomingSignatures != nil {
incomingSignatures <- in
// Maybe we can add another channel here for better error management
return &pAPI.ErrorCode{Code: pAPI.ErrorCode_SUCCESS}, nil
}
return &pAPI.ErrorCode{Code: pAPI.ErrorCode_INVARG}, fmt.Errorf("Cannot pass incoming signature")
return nil, nil
}
......
......@@ -94,7 +94,7 @@ func (m *SignatureManager) RecieveAllSigns() error {
// TODO this ctx needs a timeout !
for len(pendingSet) > 0 {
signature := <-incomingSignatures
senderID, exist := hashToID[string(signature.SenderKeyHash)]
senderID, exist := hashToID[fmt.Sprintf("%x", signature.SenderKeyHash)]
if exist {
var err error
pendingSet, err = common.Remove(pendingSet, senderID)
......
......@@ -57,6 +57,7 @@ func ReadySign(db *mgdb.MongoManager, rooms *common.WaitingGroupMap, ctx *contex
ErrorCode: &api.ErrorCode{Code: api.ErrorCode_SUCCESS},
SignatureUuid: s.data,
KeyHash: s.chain,
Sequence: s.sequence,
}
} // data == "" means the contractUUID is bad
return &api.LaunchSignature{ErrorCode: &api.ErrorCode{Code: api.ErrorCode_INVARG}}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment