-
Notifications
You must be signed in to change notification settings - Fork 250
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #490 from vechain/randomized-scheduler
Randomized scheduler
- Loading branch information
Showing
25 changed files
with
1,790 additions
and
332 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// Copyright (c) 2020 The VeChainThor developers | ||
|
||
// Distributed under the GNU Lesser General Public License v3.0 software license, see the accompanying | ||
// file LICENSE or <https://www.gnu.org/licenses/lgpl-3.0.html> | ||
|
||
package block | ||
|
||
import ( | ||
"errors" | ||
) | ||
|
||
// ComplexSignature is the signature composed by[ECDSA(Secp256k1) Signature(65 bytes)+VRF Proof(81 bytes)] | ||
type ComplexSignature []byte | ||
|
||
// NewComplexSignature creates a new signature. | ||
func NewComplexSignature(signature, proof []byte) (ComplexSignature, error) { | ||
if len(signature) != 65 { | ||
return nil, errors.New("invalid signature length, 65 bytes required") | ||
} | ||
if len(proof) != 81 { | ||
return nil, errors.New("invalid proof length, 81 bytes required") | ||
} | ||
|
||
var ms ComplexSignature | ||
ms = make([]byte, 0, ComplexSigSize) | ||
ms = append(ms, signature...) | ||
ms = append(ms, proof...) | ||
|
||
return ms, nil | ||
} | ||
|
||
// Signature returns the ECDSA signature. | ||
func (ms ComplexSignature) Signature() []byte { | ||
return ms[:65] | ||
} | ||
|
||
// Proof returns the VRF proof. | ||
func (ms ComplexSignature) Proof() []byte { | ||
return ms[65:] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// Copyright (c) 2020 The VeChainThor developers | ||
|
||
// Distributed under the GNU Lesser General Public License v3.0 software license, see the accompanying | ||
// file LICENSE or <https://www.gnu.org/licenses/lgpl-3.0.html> | ||
|
||
package block | ||
|
||
import ( | ||
"errors" | ||
"io" | ||
|
||
"github.com/ethereum/go-ethereum/rlp" | ||
) | ||
|
||
type extension struct { | ||
Alpha []byte | ||
} | ||
|
||
type _extension extension | ||
|
||
// EncodeRLP implements rlp.Encoder. | ||
func (ex *extension) EncodeRLP(w io.Writer) error { | ||
// trim extension before VIP214 | ||
// this is mainly for backward compatibility | ||
if len(ex.Alpha) == 0 { | ||
return nil | ||
} | ||
return rlp.Encode(w, (*_extension)(ex)) | ||
} | ||
|
||
// DecodeRLP implements rlp.Decoder. | ||
func (ex *extension) DecodeRLP(s *rlp.Stream) error { | ||
var obj _extension | ||
if err := s.Decode(&obj); err != nil { | ||
// Error(end-of-list) means this field is not present, return default value | ||
// for backward compatibility | ||
if err == rlp.EOL { | ||
*ex = extension{ | ||
nil, | ||
} | ||
return nil | ||
} | ||
return err | ||
} | ||
if len(obj.Alpha) == 0 { | ||
return errors.New("rlp: extension must be trimmed") | ||
} | ||
*ex = extension(obj) | ||
return nil | ||
} |
Oops, something went wrong.