2020-10-28 17:35:56 +00:00
|
|
|
package types
|
|
|
|
|
|
|
|
import (
|
|
|
|
"strconv"
|
|
|
|
|
2020-11-12 14:18:30 +00:00
|
|
|
"github.com/libp2p/go-libp2p-core/peer"
|
|
|
|
|
2020-10-28 17:35:56 +00:00
|
|
|
"github.com/Secured-Finance/dione/config"
|
2020-11-12 14:18:30 +00:00
|
|
|
)
|
|
|
|
|
2020-11-27 16:16:08 +00:00
|
|
|
// DrandRound represents the round number in DRAND
|
2020-11-14 00:03:47 +00:00
|
|
|
type DrandRound int64
|
2020-10-28 17:35:56 +00:00
|
|
|
|
2020-11-14 00:03:47 +00:00
|
|
|
const TicketRandomnessLookback = DrandRound(1)
|
2020-10-31 03:48:15 +00:00
|
|
|
|
2020-11-14 00:03:47 +00:00
|
|
|
func (e DrandRound) String() string {
|
2020-10-28 17:35:56 +00:00
|
|
|
return strconv.FormatInt(int64(e), 10)
|
|
|
|
}
|
|
|
|
|
2020-11-27 16:16:08 +00:00
|
|
|
// DioneTask represents the values of task computation
|
2020-10-28 17:35:56 +00:00
|
|
|
type DioneTask struct {
|
2020-11-27 16:16:08 +00:00
|
|
|
_ struct{} `cbor:",toarray" hash:"-"`
|
|
|
|
OriginChain uint8
|
|
|
|
RequestType string
|
|
|
|
RequestParams string
|
2020-11-25 18:54:59 +00:00
|
|
|
Miner peer.ID
|
2020-11-27 16:16:08 +00:00
|
|
|
MinerEth string
|
2020-10-28 17:35:56 +00:00
|
|
|
Ticket *Ticket
|
|
|
|
ElectionProof *ElectionProof
|
|
|
|
BeaconEntries []BeaconEntry
|
2020-11-14 00:03:47 +00:00
|
|
|
DrandRound DrandRound
|
2020-10-31 04:38:51 +00:00
|
|
|
Payload []byte
|
2020-11-15 05:59:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func NewDioneTask(
|
2020-11-27 16:16:08 +00:00
|
|
|
originChain uint8,
|
|
|
|
requestType string,
|
|
|
|
requestParams string,
|
2020-11-15 05:59:46 +00:00
|
|
|
miner peer.ID,
|
|
|
|
ticket *Ticket,
|
|
|
|
electionProof *ElectionProof,
|
|
|
|
beacon []BeaconEntry,
|
|
|
|
drand DrandRound,
|
|
|
|
payload []byte,
|
|
|
|
) *DioneTask {
|
|
|
|
return &DioneTask{
|
2020-11-27 16:16:08 +00:00
|
|
|
OriginChain: originChain,
|
|
|
|
RequestType: requestType,
|
|
|
|
RequestParams: requestParams,
|
2020-11-25 18:54:59 +00:00
|
|
|
Miner: miner,
|
2020-11-15 05:59:46 +00:00
|
|
|
Ticket: ticket,
|
|
|
|
ElectionProof: electionProof,
|
|
|
|
BeaconEntries: beacon,
|
|
|
|
DrandRound: drand,
|
|
|
|
Payload: payload,
|
|
|
|
}
|
2020-10-28 17:35:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
var tasksPerEpoch = NewInt(config.TasksPerEpoch)
|
|
|
|
|
|
|
|
const sha256bits = 256
|