Add abstraction method of processTxs to StateDB

- Update GHA lint.yml increasing timeout time to avoid GHA Lint errors
- Update common.BatchNum & common.Idx & common.Nonce usage in StateDB
- Add abstraction method of processTxs to StateDB
    - Which will be used by Synchronizer & BatchBuilder
This commit is contained in:
arnaucube
2020-08-24 13:01:31 +02:00
parent 118ebf70b7
commit b4044a2ef7
15 changed files with 149 additions and 85 deletions

View File

@@ -1,6 +1,8 @@
package common
import (
"encoding/binary"
"fmt"
"math/big"
ethCommon "github.com/ethereum/go-ethereum/common"
@@ -26,3 +28,19 @@ type Batch struct {
// BatchNum identifies a batch
type BatchNum uint32
// Bytes returns a byte array of length 4 representing the BatchNum
func (bn BatchNum) Bytes() []byte {
var batchNumBytes [4]byte
binary.LittleEndian.PutUint32(batchNumBytes[:], uint32(bn))
return batchNumBytes[:]
}
// BatchNumFromBytes returns BatchNum from a []byte
func BatchNumFromBytes(b []byte) (BatchNum, error) {
if len(b) != 4 {
return 0, fmt.Errorf("can not parse BatchNumFromBytes, bytes len %d, expected 4", len(b))
}
batchNum := binary.LittleEndian.Uint32(b[:4])
return BatchNum(batchNum), nil
}