Include block number in csv filename
This commit is contained in:
parent
74bcf49aa4
commit
ecd34978d3
@ -22,16 +22,17 @@ var (
|
||||
updatedAccountAction = "updated"
|
||||
)
|
||||
|
||||
func createCSVFilePath(path string) string {
|
||||
func createCSVFilePath(path, blockNumber string) string {
|
||||
now := time.Now()
|
||||
timeStamp := now.Format(timeStampFormat)
|
||||
filePath := filepath.Join(path, timeStamp)
|
||||
suffix := timeStamp + "-" + blockNumber
|
||||
filePath := filepath.Join(path, suffix)
|
||||
filePath = filePath + ".csv"
|
||||
return filePath
|
||||
}
|
||||
|
||||
func (p *publisher) publishStateDiffToCSV(sd builder.StateDiff) (string, error) {
|
||||
filePath := createCSVFilePath(p.Config.Path)
|
||||
filePath := createCSVFilePath(p.Config.Path, strconv.FormatInt(sd.BlockNumber, 10))
|
||||
|
||||
file, err := os.OpenFile(filePath, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
|
||||
if err != nil {
|
||||
|
@ -116,6 +116,10 @@ func testFileName(t *testing.T) {
|
||||
if !strings.HasPrefix(fileName, dir) {
|
||||
t.Errorf(testhelpers.TestFailureFormatString, t.Name(), dir, fileName)
|
||||
}
|
||||
blockNumberWithFileExt := strconv.FormatInt(testhelpers.BlockNumber, 10) + ".csv"
|
||||
if !strings.HasSuffix(fileName, blockNumberWithFileExt) {
|
||||
t.Errorf(testhelpers.TestFailureFormatString, t.Name(), blockNumberWithFileExt, fileName)
|
||||
}
|
||||
}
|
||||
|
||||
func testColumnHeaders(t *testing.T) {
|
||||
|
Loading…
Reference in New Issue
Block a user