Skip to content

Commit a34617e

Browse files
committedJan 11, 2023
lints
Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
1 parent 4c8f1f5 commit a34617e

File tree

1 file changed

+12
-70
lines changed

1 file changed

+12
-70
lines changed
 

‎tree.go

+12-70
Original file line numberDiff line numberDiff line change
@@ -954,7 +954,7 @@ func (n *LeafNode) getOldCn(index byte) (*Point, *Fr) {
954954
return c, &oldc
955955
}
956956

957-
func (n *LeafNode) updateC(stem []byte, index byte, c *Point, oldc *Fr) {
957+
func (n *LeafNode) updateC(index byte, c *Point, oldc *Fr) {
958958
var (
959959
newc Fr
960960
poly [256]Fr
@@ -963,13 +963,6 @@ func (n *LeafNode) updateC(stem []byte, index byte, c *Point, oldc *Fr) {
963963
toFr(&newc, c)
964964
newc.Sub(&newc, oldc)
965965
poly[2+(index/128)] = newc
966-
967-
if n.commitment == nil {
968-
poly[0].SetUint64(1)
969-
StemFromBytes(&poly[1], stem)
970-
n.commitment = cfg.CommitToPoly(poly[:], 0)
971-
return
972-
}
973966
n.commitment.Add(n.commitment, cfg.CommitToPoly(poly[:], 0))
974967
}
975968

@@ -1026,22 +1019,6 @@ func (n *LeafNode) updateLeaf(index byte, value []byte) {
10261019
n.values[index] = value
10271020
}
10281021

1029-
/*
1030-
func (n *LeafNode) updateLeaf(index byte, value []byte) {
1031-
if n.commitment == nil {
1032-
panic("nil commitment")
1033-
}
1034-
1035-
c, oldc := n.getOldCn(index)
1036-
1037-
n.updateCn(index, value, c)
1038-
1039-
n.updateC(index, c, oldc)
1040-
1041-
n.values[index] = value
1042-
}
1043-
*/
1044-
10451022
func (n *LeafNode) updateMultipleLeaves(values [][]byte) {
10461023
for i := range values {
10471024
if values[i] != nil {
@@ -1050,41 +1027,6 @@ func (n *LeafNode) updateMultipleLeaves(values [][]byte) {
10501027
}
10511028
}
10521029

1053-
/*
1054-
func (n *LeafNode) updateMultipleLeaves(values [][]byte) {
1055-
if n.commitment == nil {
1056-
panic("nil commitment")
1057-
}
1058-
1059-
var c1, c2 *Point
1060-
var old1, old2 *Fr
1061-
for i, v := range values {
1062-
if len(v) != 0 && !bytes.Equal(v, n.values[i]) {
1063-
if i < 128 {
1064-
if c1 == nil {
1065-
c1, old1 = n.getOldCn(byte(i))
1066-
}
1067-
n.updateCn(byte(i), v, c1)
1068-
} else {
1069-
if c2 == nil {
1070-
c2, old2 = n.getOldCn(byte(i))
1071-
}
1072-
n.updateCn(byte(i), v, c2)
1073-
}
1074-
1075-
n.values[i] = v
1076-
}
1077-
}
1078-
1079-
if c1 != nil {
1080-
n.updateC(0, c1, old1)
1081-
}
1082-
if c2 != nil {
1083-
n.updateC(128, c2, old2)
1084-
}
1085-
}
1086-
*/
1087-
10881030
func (n *LeafNode) InsertOrdered(key []byte, value []byte, _ NodeFlushFn) error {
10891031
// In the previous version, this value used to be flushed on insert.
10901032
// This is no longer the case, as all values at the last level get
@@ -1154,14 +1096,14 @@ func (leaf *LeafNode) Commit() *Point {
11541096
frPool.Put(c1polyp)
11551097
}()
11561098

1157-
count = fillSuffixTreePoly(c1poly[:], leaf.values[:128])
1158-
leaf.c1 = cfg.CommitToPoly(c1poly[:], 256-count)
1099+
count = fillSuffixTreePoly(c1poly, leaf.values[:128])
1100+
leaf.c1 = cfg.CommitToPoly(c1poly, 256-count)
11591101

11601102
for i := 0; i < 256; i++ {
11611103
c1poly[i] = Fr{}
11621104
}
1163-
count = fillSuffixTreePoly(c1poly[:], leaf.values[128:])
1164-
leaf.c2 = cfg.CommitToPoly(c1poly[:], 256-count)
1105+
count = fillSuffixTreePoly(c1poly, leaf.values[128:])
1106+
leaf.c2 = cfg.CommitToPoly(c1poly, 256-count)
11651107

11661108
for i := 0; i < 256; i++ {
11671109
c1poly[i] = Fr{}
@@ -1170,7 +1112,7 @@ func (leaf *LeafNode) Commit() *Point {
11701112
StemFromBytes(&c1poly[1], leaf.stem)
11711113

11721114
toFrMultiple([]*Fr{&c1poly[2], &c1poly[3]}, []*Point{leaf.c1, leaf.c2})
1173-
leaf.commitment = cfg.CommitToPoly(c1poly[:], 252)
1115+
leaf.commitment = cfg.CommitToPoly(c1poly, 252)
11741116

11751117
} else if len(leaf.cow) != 0 {
11761118
// If we've already have a calculated commitment, and there're touched leaf values, we do a diff update.
@@ -1180,23 +1122,23 @@ func (leaf *LeafNode) Commit() *Point {
11801122
if !bytes.Equal(oldValue, leaf.values[i]) {
11811123
if i < 128 {
11821124
if c1 == nil {
1183-
c1, old1 = leaf.getOldCn(byte(i))
1125+
c1, old1 = leaf.getOldCn(i)
11841126
}
1185-
leaf.updateCn(byte(i), oldValue, c1)
1127+
leaf.updateCn(i, oldValue, c1)
11861128
} else {
11871129
if c2 == nil {
1188-
c2, old2 = leaf.getOldCn(byte(i))
1130+
c2, old2 = leaf.getOldCn(i)
11891131
}
1190-
leaf.updateCn(byte(i), oldValue, c2)
1132+
leaf.updateCn(i, oldValue, c2)
11911133
}
11921134
}
11931135
}
11941136

11951137
if c1 != nil {
1196-
leaf.updateC(leaf.stem, 0, c1, old1)
1138+
leaf.updateC(0, c1, old1)
11971139
}
11981140
if c2 != nil {
1199-
leaf.updateC(leaf.stem, 128, c2, old2)
1141+
leaf.updateC(128, c2, old2)
12001142
}
12011143
leaf.cow = nil
12021144
}

0 commit comments

Comments
 (0)