mirror of
https://github.com/arnaucube/hermez-node.git
synced 2026-02-07 03:16:45 +01:00
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:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user