Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

all: implement simple checkpoint syncing #19543

Merged
merged 11 commits into from
Jun 28, 2019
Prev Previous commit
Next Next commit
cmd/registrar, contracts/registrar: fix lints
  • Loading branch information
rjl493456442 authored and karalabe committed Jun 26, 2019
commit 7ca0916ab902692c9a449c115ce4b2c741b56e80
5 changes: 1 addition & 4 deletions cmd/registrar/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,10 +262,7 @@ func registerCheckpoint(ctx *cli.Context) error {
}
sigStrs := strings.Split(ctx.GlobalString(signatureFlag.Name), ",")
for _, sig := range sigStrs {
trimmed := strings.TrimSpace(sig)
if strings.HasPrefix(trimmed, "0x") {
trimmed = trimmed[2:]
}
trimmed := strings.TrimPrefix(strings.TrimSpace(sig), "0x")
if len(trimmed) != 130 {
utils.Fatalf("Invalid signature in --signature: %s", trimmed)
} else {
Expand Down
4 changes: 2 additions & 2 deletions contracts/registrar/registrar_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ func assertSignature(addr common.Address, index uint64, hash [32]byte, r, s [32]
}
var signer common.Address
copy(signer[:], crypto.Keccak256(pubkey[1:])[12:])
return bytes.Compare(signer.Bytes(), expect.Bytes()) == 0
return bytes.Equal(signer.Bytes(), expect.Bytes())
}

type Account struct {
Expand Down Expand Up @@ -213,7 +213,7 @@ func TestCheckpointRegister(t *testing.T) {
if lindex != index {
return errors.New("latest checkpoint index mismatch")
}
if bytes.Compare(lhash[:], hash[:]) != 0 {
if !bytes.Equal(lhash[:], hash[:]) {
return errors.New("latest checkpoint hash mismatch")
}
if lheight.Cmp(height) != 0 {
Expand Down